I'm trying to build LLVM bitcode files from standard lib but can't figure out the right combination of params for build-script.
I've tried --embed-bitcode-section=1 but getting the following errors:
Without LTO: ld: loaded libLTO doesn't support -bitcode_hide_symbols: LLVM version 5.0.0 for architecture arm64
With thin LTO or with full LTO: ld: could not process llvm bitcode object file, because swift-source/build/thinlto/llvm-iphoneos-arm64/./lib/libLTO.dylib could not be loaded file 'lib/SwiftDemangle/CMakeFiles/swiftDemangle.dir/SwiftDemangle.cpp.o' for architecture arm64
The full commands and build logs are here if they can help.
As for the 'what are you trying to achieve' question, I'm trying to get some simple swift scripts (no SDK calls, Obj-C or C) compiled to LLVM bitcode without external references. I figure if I can llvm-link the bitcode output of swiftc with bitcode of stdlib and foundation I'll be off to a good start.
Appreciate any tips on building myself, or a way to extract from distributed toolchains if that's possible.
For anyone reading this, I spoke with @yonihemi and told him the problem he was running into was that he was trying to cross compile. @yonihemi were you able to get it to work?
Thanks @Michael_Gottesman for looking into it. Unfortunately, still getting error (now same for no lto, thin or full lto): ld: loaded libLTO doesn't support -bitcode_hide_symbols: LLVM version 5.0.0 for architecture arm64.
Basing off of build-toolchain and the buildbot_osx_package preset, these are the args I'm using:
./utils/build-script --ios --release-debuginfo --compiler-vendor=apple --lldb-no-debugserver --verbose-build --build-ninja --build-swift-static-stdlib --build-swift-static-sdk-overlay --build-subdir=bcstdlib --ios --no-swift-stdlib-assertions --swift-enable-ast-verifier=0 --embed-bitcode-section=1 and then with:
--swift-tools-enable-lto=thin --llvm-enable-lto=thin or
@yonihemi on another note, please be aware that you do not need to use lto for your purposes. You are interested in getting bitcode for the stdlib/runtime. The compiler itself AFAIKT you are ok with being object files? Those LTO options you are mentioning only touch the tools outputs (e.g. swiftc), not the library outputs (e.g. libswiftCore.dylib).
I noticed that we do not have a build-preset that shows how to use use that embed bitcode section flag. Lets figure out how to get this to work and then create a preset to document this for other people!
So I looked into this a little bit. I think the code here has atrophied a little bit. I am going to spruce it up. The build system should be able to do this.