swift-backtrace icon indicating copy to clipboard operation
swift-backtrace copied to clipboard

Swift 5.0 Raspbian linker fail

Open AleyRobotics opened this issue 4 years ago • 4 comments

Swift version 5.0 (swift-5.0-RELEASE) Target: armv6-unknown-linux-gnueabihf

linker LOG:

$ swift build -c release -Xswiftc -g -v
which clang
/usr/local/bin/swiftc -sdk / -g -L /home/pi/Swish/ProjectFolder/.build/armv6-unknown-linux-gnueabihf/debug -o /home/pi/Swish/ProjectFolder/.build/armv6-unknown-linux-gnueabihf/debug/ProjectFolder -module-name Project -emit-executable -Xlinker '-rpath=$ORIGIN' @/home/pi/Swish/ProjectFolder/.build/armv6-unknown-linux-gnueabihf/debug/ProjectFolder/Objects.LinkFileList
/home/pi/Swish/ProjectFolder/.build/checkouts/swift-backtrace/Sources/CBacktrace/backtrace.c:75: error: undefined reference to '_Unwind_GetIPInfo'
/home/pi/Swish/ProjectFolder/.build/checkouts/swift-backtrace/Sources/CBacktrace/simple.c:70: error: undefined reference to '_Unwind_GetIPInfo'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)

AleyRobotics avatar Apr 08 '20 20:04 AleyRobotics

@AleyRobotics could you try adding a -Xswiftc -lunwind to the command line? And do you have libunwind installed?

weissi avatar Apr 09 '20 12:04 weissi

@weissi I'm working through the same issue on a Raspberry Pi 4. I was able to install libunwind8 but get: /usr/bin/ld.gold: error: cannot find -lunwind

picnicbob avatar Jun 02 '21 14:06 picnicbob

I can build without -Xswiftc -lunwind by commenting out #define HAVE_GETIPINFO 1, but then when there's something to report it calls an illegal instruction: Current stack trace: Illegal instruction

picnicbob avatar Jun 02 '21 14:06 picnicbob

This is the output of swift test at 54a65d6 with #define HAVE_GETIPINFO 1 commented out. Should I see a stack trace?

dan@pi4:~/swift-backtrace $ swift test [5/5] Linking swift-backtracePackageTests.xctest Test Suite 'All tests' started at 2021-06-02 13:38:15.549 Test Suite 'debug.xctest' started at 2021-06-02 13:38:15.552 Test Suite 'BacktraceTests' started at 2021-06-02 13:38:15.553 Test Case 'BacktraceTests.testBacktrace' started at 2021-06-02 13:38:15.553 Fatal error: 9053EA13-E81B-44CB-B892-864CD6C72724: file /home/dan/swift-backtrace/Sources/Sample/main.swift, line 19 Current stack trace:

Test Case 'BacktraceTests.testBacktrace' passed (0.509 seconds) Test Suite 'BacktraceTests' passed at 2021-06-02 13:38:16.062 Executed 1 test, with 0 failures (0 unexpected) in 0.509 (0.509) seconds Test Suite 'debug.xctest' passed at 2021-06-02 13:38:16.063 Executed 1 test, with 0 failures (0 unexpected) in 0.509 (0.509) seconds Test Suite 'All tests' passed at 2021-06-02 13:38:16.063 Executed 1 test, with 0 failures (0 unexpected) in 0.509 (0.509) second

picnicbob avatar Jun 02 '21 17:06 picnicbob