I've verified that I can compile swift programs with that binary, use swift repl so I think the swift 5.10.1 is all good. However, when I build the 6.0.1 using my version of 5.10.1, I can't build the lldb-server, nor the lib/liblldb.so.17.0.0 with missing symbols, like:
/usr/bin/ld: /home/build/swift-project/build/buildbot_linux/swift-linux-aarch64/lib/libswiftASTGen.a(SourceFile.swift.o): undefined reference to symbol '$ss10SetAlgebraP9formUnionyyxnFTj'
/usr/bin/ld: /home/build/swift-project/build/buildbot_linux/swift-linux-aarch64/lib/swift/linux/aarch64/libswiftCore.so: error adding symbols: DSO missing from command line
clang-15: error: linker command failed with exit code 1 (use -v to see invocation)
I'm using the utils/build-script like so (leaving out the install location for clarity):
Just to verify: are you trying to build specifically with lld as your linker, or is your /usr/bin/ld an alias for gold?
If your /usr/bin/ld is lld, you need to set the LLVM_USE_LINKER=lld CMake variable in the build script to have LLVM, lldb, and the rest of the components know they're building with lld (which alters some of the linking behavior).
Is this your full build invocation (minus the install location), or are there any additional flags?
If you want to use the preset approach, you can add the CMake flag by editing swift/utils/build-presets.ini to add another preset at the bottom like so:
(Here you can see I'm passing multiple additional CMake options to the script; most of the other flags are likely irrelevant to your situation, though I would consider basing your build off the buildbot_linux,no_assertions,no_test preset to also disable assertions.)
Thanks for the reply, and I did see your gentoo related posts/links, thanks for those also. Yeah, I will try your suggestions, but I mainly wanted to rule out that I hadn't screwed something up with the building of 5.10.1. As in, is there a way that I may have built it somehow wrong, or missing something in 5.10.1, or can I rule that out as a potential problem for this link problem. Does that make sense? I'm not quite familiar enough to rule it out :)
Sorry, I meant to address this more clearly! If you managed to build the reset of Swift 6.0.1 and are running into a linker error with one component specifically, it looks like your Swift 5.10.1 is perfectly fine, and this is mostly a problem with the linker settings. (I've seen this before myself when the linker was incorrectly set.)
I tried with both ld.gold and lld and they are now both getting this error:
CMake Error at /home/build/swift-project/build/buildbot_linux/llvm-linux-aarch64/lib/cmake/llvm/HandleLLVMOptions.cmake:330 (message):
Host compiler does not support '-fuse-ld=lld'
And:
CMake Error at cmake/modules/HandleLLVMOptions.cmake:330 (message):
Host compiler does not support '-fuse-ld=ld.gold'
Call Stack (most recent call first):
CMakeLists.txt:918 (include)
I tried with the short modification you sent, as well as the full gentoo section one you had also provided.
CMake Deprecation Warning at /home/build/swift-project/llvm-project/cmake/Modules/CMakePolicy.cmake:11 (cmake_policy):
The OLD behavior for policy CMP0116 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
CMakeLists.txt:6 (include)
CMake Error at /home/build/swift-project/build/buildbot_linux/llvm-linux-aarch64/lib/cmake/llvm/HandleLLVMOptions.cmake:330 (message):
Host compiler does not support '-fuse-ld=lld'
Call Stack (most recent call first):
cmake/modules/LLDBStandalone.cmake:96 (include)
CMakeLists.txt:42 (include)
Just to sanity-check: is this after also deleting the build directory? CMake caches values like CC and LD from the environment when you run it, so it's possible it's still using the old values otherwise.
Hmm. Are you able to share the contents of your build/buildbot_linux/lldb-linux-x86_64/CMakeCache.txt and build/buildbot_linux/llvm-linux-x86_64/CMakeCache.txt? (These are going to be quite long, so I'd recommend uploading them to pastebin or similar)
One additional sanity check: it looks like lldb has CMAKE_EXE_LINKER_FLAGS:STRING=-Wl,--copy-dt-needed-entries set, which would turn the compilation invocation into
$ clang++ -fuse-ld=lld -Wl,--copy-dt-needed-entries Test.cpp
ld.lld: error: unknown argument '--copy-dt-needed-entries'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
which would indeed prevent compilation. I assume you see the same?
I'm not seeing the copy-dt-needed-entries flag referenced anywhere in the CMake files (and many linkers don't support it), so I'm wondering if something is setting this in your environment, and CMake is picking it up. In the same shell you're building from, what do you see for
./swift --version
Swift version 6.0.1 (swift-6.0.1-RELEASE)
Target: aarch64-unknown-linux-gnu
And:
./swift repl
Welcome to Swift version 6.0.1 (swift-6.0.1-RELEASE).
Type :help for assistance.
I think indeed using the lld was the key here. But before I switched to it, I had gone down a wrong path of using different flags and that copy-dt-needed-entries indeed was the one that allowed the lldb-server to get linked, but now the lib/liblldb.so.17.0.0 at which point I decided to check my assumptions and see if the bootstrap 5.10.1 might be at the root of the problem, at which point no flaggery would solve this. I am cleaning out everything up and doing everything from scratch with only this change and will report. But at least I got it working once, with your superb help, thank you so much!!!
If you get the chance and don't mind confirming something for me, please: could you try to execute something in the repl for this version that was just built (e.g., even just 1 + 1)? Based on my exploration in Swift 6.0.1 for Gentoo on GURU - #9 by itaiferber, I'd expect the repl to crash immediately. I plan on filing a bug report today with detail from a few OSes, but it'll be helpful to get even more confirmation than my own testing.
Was this with stripped or non-stripped? I did stumble on something somewhere in my adventures about repl / stripping, but I can't recall details right now.
I'm seeing this with symbols non-stripped (or, at least, I'm not enabling symbol stripping and I'm not seeing any symbols actually getting stripped); AFAICT, only Darwin platforms support stripping in the CMake setup