Can’t build the compiler due to DebuggerSupport.swift:36:14

i’m not sure what i’m doing wrong, but when i try to build the compiler following the steps here, the build fails with these errors:

FAILED: bootstrapping0/stdlib/public/core/LINUX/x86_64/Swift.o /swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/bootstrapping0/stdlib/public/core/LINUX/x86_64/Swift.o 
cd /swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/stdlib/public/core && /swift/swift-project/build/cmake-linux-x86_64/bin/cmake -E make_directory /swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/bootstrapping0/stdlib/public/core/LINUX/x86_64 && /swift/swift-project/build/cmake-linux-x86_64/bin/cmake -E env PYTHONIOENCODING=UTF8 /usr/bin/python3.7 /swift/swift-project/swift/utils/line-directive @/swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/stdlib/public/core/33770abecc5fc8b51116d79734a1c622fb00d29b.txt -- /swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/bootstrapping0/bin/swiftc -c -sdk / -target x86_64-unknown-linux-gnu -resource-dir /swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/./lib/swift -O -g -D INTERNAL_CHECKS_ENABLED -D SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY -D SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED -D SWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS -D SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING -D SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING -D SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION -D SWIFT_RUNTIME_OS_VERSIONING -D SWIFT_STDLIB_ENABLE_UNICODE_DATA -D SWIFT_STDLIB_ENABLE_VECTOR_TYPES -D SWIFT_STDLIB_HAS_COMMANDLINE -D SWIFT_STDLIB_HAS_STDIN -D SWIFT_STDLIB_HAS_ENVIRON -Xcc -DSWIFT_STDLIB_HAS_ENVIRON -D SWIFT_STDLIB_OVERRIDABLE_RETAIN_RELEASE -D SWIFT_THREADING_LINUX -tools-directory /swift/swift-project/build/Ninja-RelWithDebInfoAssert/llvm-linux-x86_64/./bin -module-cache-path /swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/./module-cache -no-link-objc-runtime -enable-library-evolution -library-level api -Xfrontend -require-explicit-availability=ignore -Xfrontend -enforce-exclusivity=unchecked -D SWIFT_ENABLE_REFLECTION -nostdimport -parse-stdlib -module-name Swift -Xfrontend -group-info-path -Xfrontend /swift/swift-project/swift/stdlib/public/core/GroupInfo.json -swift-version 5 -runtime-compatibility-version none -disable-autolinking-runtime-compatibility-dynamic-replacements -Xfrontend -disable-autolinking-runtime-compatibility-concurrency -warn-swift3-objc-inference-complete -Xfrontend -disable-objc-interop -diagnostic-style swift -Xllvm -sil-inline-generics -Xllvm -sil-partial-specialization -Xfrontend -enable-experimental-concise-pound-file -enable-experimental-feature Macros -enable-experimental-feature FreestandingMacros -enable-experimental-feature Extern -enable-experimental-feature BitwiseCopyable -Xcc -DswiftCore_EXPORTS -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 9999:macOS\ 9999,\ iOS\ 9999,\ watchOS\ 9999,\ tvOS\ 9999 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.0:macOS\ 10.14.4,\ iOS\ 12.2,\ watchOS\ 5.2,\ tvOS\ 12.2 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.1:macOS\ 10.15,\ iOS\ 13.0,\ watchOS\ 6.0,\ tvOS\ 13.0 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.2:macOS\ 10.15.4,\ iOS\ 13.4,\ watchOS\ 6.2,\ tvOS\ 13.4 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.3:macOS\ 11.0,\ iOS\ 14.0,\ watchOS\ 7.0,\ tvOS\ 14.0 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.4:macOS\ 11.3,\ iOS\ 14.5,\ watchOS\ 7.4,\ tvOS\ 14.5 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.5:macOS\ 12.0,\ iOS\ 15.0,\ watchOS\ 8.0,\ tvOS\ 15.0 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.6:macOS\ 12.3,\ iOS\ 15.4,\ watchOS\ 8.5,\ tvOS\ 15.4 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.7:macOS\ 13.0,\ iOS\ 16.0,\ watchOS\ 9.0,\ tvOS\ 16.0 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.8:macOS\ 13.3,\ iOS\ 16.4,\ watchOS\ 9.4,\ tvOS\ 16.4 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.9:macOS\ 14.0,\ iOS\ 17.0,\ watchOS\ 10.0,\ tvOS\ 17.0 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.10:macOS\ 9999,\ iOS\ 9999,\ watchOS\ 9999,\ tvOS\ 9999 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.11:macOS\ 9999,\ iOS\ 9999,\ watchOS\ 9999,\ tvOS\ 9999 -Xfrontend -target-min-inlining-version -Xfrontend min -Xcc -fno-omit-frame-pointer -module-link-name swiftCore -whole-module-optimization -color-diagnostics -parse-as-library -resource-dir /swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/bootstrapping0/lib/swift -I /swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/bootstrapping0/lib/swift/linux -o /swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/bootstrapping0/stdlib/public/core/LINUX/x86_64/Swift.o @/swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/stdlib/public/core/33770abecc5fc8b51116d79734a1c622fb00d29b.txt
/swift/swift-project/swift/stdlib/public/core/DebuggerSupport.swift:36:14: error: macros are not supported in this compiler
public macro _DebugDescription() =
             ^
/swift/swift-project/swift/stdlib/public/core/DebuggerSupport.swift:42:14: error: macros are not supported in this compiler
public macro _DebugDescriptionProperty(_ debugIdentifier: String, _ computedProperties: [String]) =

although i initially thought it might be related to --skip-early-swift-driver --skip-early-swiftsyntax, i also get the same error when omitting those options.

Bootstrapping the compiler on linux broke yesterday, as the linux CI only tests building the Swift portions of the compiler with a prebuilt Swift compiler now, ie the full bootstrap is turned off on the CI, and a pull adding macros to the stdlib cannot be built the way you are doing it. I reported the issue there and a fix is in the works.

However, you should switch over to building the Swift toolchain with a prebuilt Swift compiler, as I've been told that the plan is to stop supporting bootstrapping in the coming year and require a prebuilt Swift compiler.

Those options are irrelevant when there is no prebuilt Swift compiler in your PATH, as they look for one and are automatically skipped if they don't find it.

how do i do that anyway? i assumed that was what the --bootstrapping=hosttools option is supposed to do, but i get the same error.

$ utils/build-script --release-debuginfo --bootstrapping=hosttools

i definitely do have the toolchain installed in the docker container where i am building.

$ swift --version
Swift version 5.9.1 (swift-5.9.1-RELEASE)
Target: x86_64-unknown-linux-gnu

I was wondering why you were doing a full bootstrap anyway, as the CMake config forces a hosttools build on linux if building the new swift-syntax parser is enabled, but maybe your passing --skip-early-swiftsyntax disabled that. The build instructions for linux will need to be updated, I will submit a doc pull for that.

Try running utils/build-script --release-debuginfo --reconfigure and check for the following lines when CMake is run for the compiler build:

  • CMake found your Swift compiler (your prebuilt compiler version will be different)
-- Swift Compiler (/opt/swift/5.8.1/usr/bin/swiftc) Version: 5.8.1
  • the bootstrap is set to hosttools
--   Bootstrapping:  HOSTTOOLS
  • you are using the new swift-syntax parser
--   Swift parser:   TRUE

I copy-pasted those three lines from the log for a recent linux CI build, your build should pass just like that one if those are properly set. If reconfiguring doesn't work, try deleting the existing Swift compiler build directory with rm -rf build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/, then running build-script again without the skip-early flags from the doc.

1 Like

after a lot of trial and error i was finally able to build the toolchain using the tips you provided :D

there are some things i discovered that might help others:

  • it is not possible to build the toolchain using any prebuilt 5.9 toolchain, possibly due to this issue. this is probably why the CI is still using the 5.8.1 toolchain.

  • the dependencies list for Amazon Linux 2 installs too old of a version of gcc. i needed to modify the dockerfile with:

- RUN yum install -y gcc-c++
+ RUN yum remove -y gcc
+ RUN yum install -y gcc10.x86_64 gcc10-c++.x86_64
+ RUN ln -s /usr/bin/gcc10-gcc /usr/bin/gcc
+ RUN ln -s /usr/bin/gcc10-g++ /usr/bin/g++
+ RUN ln -s /usr/bin/gcc10-cc /usr/bin/cc
+ RUN ln -s /usr/bin/gcc10-c++ /usr/bin/c++

to get it to build successfully.

What is the exact build error you see? I've been building the trunk compiler with Swift 5.9 natively on Android without a problem.

i don’t have the log with me anymore but i remember it was a runtime segmentation fault in one of the compiler’s swift dependencies (swift-driver i think). it looked similar to the 5.9-only runtime crashes in the linked issue so i didn’t think much of it at the time and immediately downgraded to a 5.8 toolchain which resolved the issue.

i'll try to reproduce the crash later today.

here is the crash dump:

[1347/1510][ 89%][2303.850s] Generating /swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/lib/swift/embedded/Swift.swiftmodule/armv7em-none-none-eabi.swiftmodule
FAILED: lib/swift/embedded/Swift.swiftmodule/armv7em-none-none-eabi.swiftmodule lib/swift/embedded/Swift.swiftmodule/armv7em-none-none-eabi.swiftdoc /swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/lib/swift/embedded/Swift.swiftmodule/armv7em-none-none-eabi.swiftmodule /swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/lib/swift/embedded/Swift.swiftmodule/armv7em-none-none-eabi.swiftdoc 
cd /swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/stdlib/public/core && /swift/swift-project/build/cmake-linux-x86_64/bin/cmake -E make_directory /swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/stdlib/public/core/embedded/armv7em && /swift/swift-project/build/cmake-linux-x86_64/bin/cmake -E remove -f /swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/lib/swift/embedded/Swift.swiftmodule/armv7em-none-none-eabi.swiftmodule /swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/lib/swift/embedded/Swift.swiftmodule/armv7em-none-none-eabi.swiftdoc && /swift/swift-project/build/cmake-linux-x86_64/bin/cmake -E make_directory /swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/lib/swift/embedded /swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/lib/swift/embedded/Swift.swiftmodule && /swift/swift-project/build/cmake-linux-x86_64/bin/cmake -E env PYTHONIOENCODING=UTF8 LD_LIBRARY_PATH=/opt/swift/5.9.2/usr/lib/swift/linux /usr/bin/python3.9 /swift/swift-project/swift/utils/line-directive @/swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/stdlib/public/core/81eed2b71b4043f7a19f80514872f19668ede62c.txt -- /swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/./bin/swiftc -emit-module -o /swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/lib/swift/embedded/Swift.swiftmodule/armv7em-none-none-eabi.swiftmodule -avoid-emit-module-source-info -target armv7em-none-none-eabi -resource-dir /swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/./lib/swift -O -g -D INTERNAL_CHECKS_ENABLED -D SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY -D SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED -D SWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS -D SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING -D SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING -D SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION -D SWIFT_RUNTIME_OS_VERSIONING -D SWIFT_STDLIB_ENABLE_UNICODE_DATA -D SWIFT_STDLIB_ENABLE_VECTOR_TYPES -D SWIFT_STDLIB_HAS_COMMANDLINE -D SWIFT_STDLIB_HAS_STDIN -D SWIFT_STDLIB_HAS_ENVIRON -Xcc -DSWIFT_STDLIB_HAS_ENVIRON -D SWIFT_STDLIB_OVERRIDABLE_RETAIN_RELEASE -D SWIFT_THREADING_ -tools-directory /swift/swift-project/build/Ninja-RelWithDebInfoAssert/llvm-linux-x86_64/./bin -module-cache-path /swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/./module-cache -no-link-objc-runtime -Xfrontend -enforce-exclusivity=unchecked -nostdimport -parse-stdlib -module-name Swift -Xfrontend -group-info-path -Xfrontend /swift/swift-project/swift/stdlib/public/core/GroupInfo.json -swift-version 5 -runtime-compatibility-version none -disable-autolinking-runtime-compatibility-dynamic-replacements -Xfrontend -disable-autolinking-runtime-compatibility-concurrency -warn-swift3-objc-inference-complete -Xfrontend -disable-objc-interop -Xfrontend -enable-experimental-associated-type-inference -diagnostic-style swift -Xllvm -sil-inline-generics -Xllvm -sil-partial-specialization -Xfrontend -enable-experimental-concise-pound-file -enable-experimental-feature Macros -enable-experimental-feature FreestandingMacros -enable-experimental-feature Extern -enable-experimental-feature BitwiseCopyable -Xcc -D__MACH__ -Xcc -D__APPLE__ -Xcc -ffreestanding -enable-experimental-feature Embedded -Xfrontend -enable-ossa-modules -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 9999:macOS\ 9999,\ iOS\ 9999,\ watchOS\ 9999,\ tvOS\ 9999 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.0:macOS\ 10.14.4,\ iOS\ 12.2,\ watchOS\ 5.2,\ tvOS\ 12.2 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.1:macOS\ 10.15,\ iOS\ 13.0,\ watchOS\ 6.0,\ tvOS\ 13.0 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.2:macOS\ 10.15.4,\ iOS\ 13.4,\ watchOS\ 6.2,\ tvOS\ 13.4 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.3:macOS\ 11.0,\ iOS\ 14.0,\ watchOS\ 7.0,\ tvOS\ 14.0 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.4:macOS\ 11.3,\ iOS\ 14.5,\ watchOS\ 7.4,\ tvOS\ 14.5 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.5:macOS\ 12.0,\ iOS\ 15.0,\ watchOS\ 8.0,\ tvOS\ 15.0 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.6:macOS\ 12.3,\ iOS\ 15.4,\ watchOS\ 8.5,\ tvOS\ 15.4 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.7:macOS\ 13.0,\ iOS\ 16.0,\ watchOS\ 9.0,\ tvOS\ 16.0 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.8:macOS\ 13.3,\ iOS\ 16.4,\ watchOS\ 9.4,\ tvOS\ 16.4 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.9:macOS\ 14.0,\ iOS\ 17.0,\ watchOS\ 10.0,\ tvOS\ 17.0 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.10:macOS\ 9999,\ iOS\ 9999,\ watchOS\ 9999,\ tvOS\ 9999 -Xfrontend -define-availability -Xfrontend SwiftStdlib\ 5.11:macOS\ 9999,\ iOS\ 9999,\ watchOS\ 9999,\ tvOS\ 9999 -Xfrontend -target-min-inlining-version -Xfrontend min -module-link-name swiftCore -whole-module-optimization -color-diagnostics -parse-as-library -resource-dir /swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/./lib/swift -I /swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/./lib/swift/embedded @/swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/stdlib/public/core/81eed2b71b4043f7a19f80514872f19668ede62c.txt

*** Signal 11: Backtracing from 0x7efd0e874860... done ***

*** Program crashed: Bad pointer dereference at 0x0000000000000066 ***

Thread 0 "swift-driver" crashed:

0  0x00007efd0e874860 <unknown> in lib_InternalSwiftScan.so

Thread 1:

0  0x00007efd163ae86e epoll_wait + 94 in libc.so.6


Registers:

rax 0x00007efd12e21df0  80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ················
rdx 0x00007efd12e21d70  80 f1 c3 0f fd 7e 00 00 00 00 00 00 00 00 00 00  ·ñ÷ý~··········
rcx 0x0000000000000000  0
rbx 0x0000000000000000  0
rsi 0x00007efd12e21d70  80 f1 c3 0f fd 7e 00 00 00 00 00 00 00 00 00 00  ·ñ÷ý~··········
rdi 0x0000000000000000  0
rbp 0x00000000000000f8  248
rsp 0x00007ffd0a540618  fe 88 6e 08 fd 7e 00 00 08 72 60 0f fd 7e 00 00  þ·n·ý~···r`·ý~··
 r8 0x000055ea0083ac20  04 00 00 00 00 00 00 00 67 92 d2 91 d9 ed 55 c6  ········g·Ò·ÙíUÆ
 r9 0x0000000000000000  0
r10 0x00007efd1626f410  f7 09 00 00 12 00 0e 00 60 6b 05 00 00 00 00 00  ÷·······`k······
r11 0x00007efd162b6b60  f3 0f 1e fa 41 57 41 56 41 55 41 54 55 53 48 83  ó··úAWAVAUATUSH·
r12 0x00007ffd0a544cc8  73 64 54 0a fd 7f 00 00 cd 64 54 0a fd 7f 00 00  sdT·ý···ÍdT·ý···
r13 0x00007ffd0a545490  e0 89 54 0a fd 7f 00 00 f5 89 54 0a fd 7f 00 00  à·T·ý···õ·T·ý···
r14 0x00007efd12e21dc0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ················
r15 0x0000000000000000  0
rip 0x00007efd0e874860  00 66 66 66 66 66 66 2e 0f 1f 84 00 00 00 00 00  ·ffffff.········

rflags 0x0000000000010283  SF CF

cs 0x0033  fs 0x0000  gs 0x0000


Images (43 omitted):

0x00007efd07c00000–0x00007efd0f605e90 <no build ID>                            lib_InternalSwiftScan.so /swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/lib/lib_InternalSwiftScan.so
0x00007efd16260000–0x00007efd163fc04c a84b0b221620b4944c5940d3bed62056c7d7baa4 libc.so.6                /usr/lib64/libc.so.6

Backtrace took 0.02s

[1357/1510][ 89%][2428.842s] Generating /swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/./lib/swift/linux/Swift.swiftmodule/x86_64-unknown-linux-gnu.swiftmodule
warning: Could not read SDKSettings.json for SDK at: /
[1358/1510][ 89%][2515.994s] Compiling /swift/swift-project/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/stdlib/public/core//LINUX/x86_64/Swift.o
warning: Could not read SDKSettings.json for SDK at: /
ninja: build stopped: subcommand failed.
ERROR: command terminated with a non-zero exit status 1, aborting

i attempted this build on Amazon Linux 2023 using a 5.9.2 toolchain. i had previously built the toolchain successfully using 5.8.1.

Can you file a compiler issue for this? I last built the Nov. 20 trunk snapshot with Swift 5.9.1 natively on Android and didn't see this crash, but those lib/swift/embedded/ files are not built for me, maybe that's new in trunk or linux-only. No guarantee anyone will ever look into this crash, but may help someone.