Swift 6.0.1 for Gentoo on GURU

Okay, this appears to somehow be a consequence of building and linking with lld. In a swift:5.10.1-fedora39 container, I built Swift 6.0.1 with the following preset:

[preset: fedora]
mixin-preset=buildbot_linux,no_assertions,no_test
build-ninja=0
llvm-targets-to-build=host
skip-build-curl
skip-build-zlib

and build command:

./swift/utils/build-script --preset=fedora install_destdir="$(pwd)/swift-6.0.1" installable_package=""

(I had to apply the patch from [ClangImporter] Make sure the `-resource-dir` is checked before the `-sdk`, as done everywhere else in the compiler by finagolfin · Pull Request #74814 · swiftlang/swift · GitHub to get things to build)

This yielded a working lldb:

[root@9e7ec6e19f12 bin]# echo "while true {}" >> Test.swift
[root@9e7ec6e19f12 bin]# ./swiftc Test.swift
[root@9e7ec6e19f12 bin]# ./lldb -- ./Test
(lldb) target create "./Test"
Current executable set to '/root/swift/swift-6.0.1/usr/bin/Test' (x86_64).
(lldb) settings set target.disable-aslr false
(lldb) run
Process 31240 launched: '/root/swift/swift-6.0.1/usr/bin/Test' (x86_64)
warning: (x86_64) /lib64/libm.so.6 No LZMA support found for reading .gnu_debugdata section
warning: (x86_64) /lib64/libgcc_s.so.1 No LZMA support found for reading .gnu_debugdata section
Process 31240 stopped
* thread #1, name = 'Test', stop reason = signal SIGSTOP
    frame #0: 0x00005560b3d299e6 Test`main + 6
Test`main:
->  0x5560b3d299e6 <+6>: jmp    0x5560b3d299e6 ; <+6>

Test`_fini:
    0x5560b3d299e8 <+0>: endbr64
    0x5560b3d299ec <+4>: subq   $0x8, %rsp
    0x5560b3d299f0 <+8>: addq   $0x8, %rsp
Target 0: (Test) stopped.
(lldb) settings set target.language swift
(lldb) expr import Foundation
(lldb)

Updating the preset to

[preset: fedora]
mixin-preset=buildbot_linux,no_assertions,no_test
build-ninja=0
extra-cmake-flags=-DLLVM_USE_LINKER:STRING=lld
llvm-targets-to-build=host
skip-build-curl
skip-build-zlib

yields a broken lldb:

[root@9e7ec6e19f12 bin]# echo "while true {}" >> Test.swift
[root@9e7ec6e19f12 bin]# ./swiftc Test.swift
[root@9e7ec6e19f12 bin]# ./lldb -- ./Test
(lldb) target create "./Test"
Current executable set to '/root/swift/swift-6.0.1/usr/bin/Test' (x86_64).
(lldb) settings set target.disable-aslr false
(lldb) run
Process 30380 launched: '/root/swift/swift-6.0.1/usr/bin/Test' (x86_64)
warning: (x86_64) /lib64/libm.so.6 No LZMA support found for reading .gnu_debugdata section
warning: (x86_64) /lib64/libgcc_s.so.1 No LZMA support found for reading .gnu_debugdata section
Process 30380 stopped
* thread #1, name = 'Test', stop reason = signal SIGSTOP
    frame #0: 0x00005560b3d299e6 Test`main + 6
Test`main:
->  0x5560b3d299e6 <+6>: jmp    0x5560b3d299e6 ; <+6>

Test`_fini:
    0x5560b3d299e8 <+0>: endbr64
    0x5560b3d299ec <+4>: subq   $0x8, %rsp
    0x5560b3d299f0 <+8>: addq   $0x8, %rsp
Target 0: (Test) stopped.
(lldb) settings set target.language swift
(lldb) expr import Foundation
Optimizer/Verifier.swift:22: Fatal error: instruction   %2 = tuple ()                                   // user: %3
should conform to ForwardingInstruction
LLDB diagnostics will be written to /tmp/diagnostics-4e1682
Please include the directory content when filing a bug report
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: ./lldb -- ./Test
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  lldb            0x00005642a5aca028
1  lldb            0x00005642a5ac83be
2  lldb            0x00005642a5aca958
3  libc.so.6       0x00007fade1f449a0
4  libswiftCore.so 0x00007fade1bb26bf $ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF + 351
5  liblldb.so.17   0x00007fade44afd26
6  liblldb.so.17   0x00007fade44afd3a
7  liblldb.so.17   0x00007fade489ac8c
8  liblldb.so.17   0x00007fade4a8f89b
9  liblldb.so.17   0x00007fade489a0be
10 liblldb.so.17   0x00007fade489b0df
11 liblldb.so.17   0x00007fade489cc9b
12 liblldb.so.17   0x00007fade4898518
13 liblldb.so.17   0x00007fade48984cd
14 liblldb.so.17   0x00007fade4b5d72a
15 liblldb.so.17   0x00007fade48b68ed
16 liblldb.so.17   0x00007fade489862c
17 liblldb.so.17   0x00007fade4b412be
18 liblldb.so.17   0x00007fade3f92a34
19 liblldb.so.17   0x00007fade3f71a09
20 liblldb.so.17   0x00007fade3f72920
21 liblldb.so.17   0x00007fade391e7e5
22 liblldb.so.17   0x00007fade3a73caa
23 liblldb.so.17   0x00007fade40fa5c8
24 liblldb.so.17   0x00007fade40fb795
25 liblldb.so.17   0x00007fade3965891
26 liblldb.so.17   0x00007fade3956bc1
27 liblldb.so.17   0x00007fade395a8de
28 liblldb.so.17   0x00007fade389162a
29 liblldb.so.17   0x00007fade386f5f6
30 liblldb.so.17   0x00007fade395c788
31 liblldb.so.17   0x00007fade368431c lldb::SBDebugger::RunCommandInterpreter(bool, bool) + 156
32 lldb            0x00005642a5ab085e
33 lldb            0x00005642a5ab14c8
34 libc.so.6       0x00007fade1f2e14a
35 libc.so.6       0x00007fade1f2e20b __libc_start_main + 139
36 lldb            0x00005642a5aacbb5

💣 Program crashed: Illegal instruction at 0x00007fade1bb26bf

Thread 0 "lldb" crashed:

0 0x00007fade1bb26bf

Backtrace took 0.36s

Illegal instruction

I'm going to confirm by building 6.0.1 in a swift:6.0.1-fedora39 container: if it works out-of-the-box with lld, then this is some combination of 5.10.1 and lld that doesn't work, which is unfortunate.

Edit: I took a random guess at building with -DLLDB_EXPORT_ALL_SYMBOLS:BOOL=YES but it doesn't appear to have made a difference

Edit 2: Can confirm that the exact same build that was producing a broken lldb in swift:5.10.1-fedora39 builds a working one in swift:6.0.1-fedora39 with LLVM_USE_LINKER=lld. So, this isn't unique to Gentoo

1 Like