Open finagolfin opened 2 months ago
We are in the process of significantly rewriting our modulemap in libc++: https://github.com/llvm/llvm-project/pull/107638
This will yield significant compilation time speedups when using modules. IMO what we should do here (as far as trunk libc++ is concerned) is to keep moving towards that change and make sure that it doesn't break interop (in fact ideally it would fix the issues you're seeing). If we need to backport a partial fix to an already-released version of libc++, that's another story and I would tackle that separately.
Do you see problems when using libc++ as it shipped with LLVM 19? Perhaps the NDK doesn't ship such a recent version yet?
Do you see problems when using libc++ as it shipped with LLVM 19?
I have not tried it, but I see no differences in LLVM 19 using the voidify.h
header, so I think it would still have this problem.
Perhaps the NDK doesn't ship such a recent version yet?
It doesn't.
I saw your rewrite pull above soon after I opened this issue: I hope it fixes this.
However, you all don't see this issue now when building the Swift toolchain with libc++ on other platforms? I don't see why this would only affect libc++ on Android.
However, you all don't see this issue when building the Swift toolchain with libc++ on other platforms? I don't see why this would only affect libc++ on Android.
I will let Swift / interop folks answer this since I do not build the Swift toolchain myself.
I just dumped some libc++ module maps from recent Xcode versions on the github CI, and it appears that this libc++ reorg commit was first shipped with Xcode 15.3 six months ago. Checking the macOS CI for which Xcode it uses to build this Optimizer.o
file, it shows these flags used, /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -c -o /Users/ec2-user/jenkins/workspace/swift-PR-macos/branch-main/build/buildbot_incremental/swift-macosx-x86_64/SwiftCompilerSources/Optimizer.o -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk
, which implies Xcode 15.1 or 15.2, neither of which use Ian's reorganized libc++ module map.
This suggests this has not hit macOS yet only because the CI is using an older libc++ module map, but once the CI updates to Xcode 15.3 or later, building the Swift compiler and C++ interop is going to break on macOS too.
@shahmishal, just letting you know, perhaps you've already seen this problem.
In the meantime, aren't there other environments using Swift with libc++ also that fail in this way?
Can confirm also hitting this exact issue on FreeBSD 14.1, which ships clang/libc++ 18.1.5
ld.lld: error: undefined hidden symbol: void* std::__1::__voidify[abi:se180100]<swift::SILLocation>(swift::SILLocation&)
>>> referenced by SIL.o
>>> SIL.o:(swift::SILBuilder::createAllocStack(swift::SILLocation, swift::SILType, std::__1::optional<swift::SILDebugVariable>, swift::HasDynamicLifetime_t, swift::IsLexical_t, swift::IsFromVarDecl_t, swift::UsesMoveableValueDebugInfo_t, bool)) in archive lib/libswiftCompilerModules.a
>>> referenced by SIL.o
>>> SIL.o:(swift::DebugValueInst::getVarInfo(bool) const) in archive lib/libswiftCompilerModules.a
>>> referenced by SIL.o
>>> SIL.o:(swift::DebugValueInst::getVarInfo(bool) const) in archive lib/libswiftCompilerModules.a
>>> referenced 2 more times
ld.lld: error: undefined hidden symbol: void* std::__1::__voidify[abi:se180100]<swift::SILDebugVariable>(swift::SILDebugVariable&)
>>> referenced by SIL.o
>>> SIL.o:(void std::__1::__optional_storage_base<swift::SILDebugVariable, false>::__construct_from[abi:se180100]<std::__1::__optional_copy_base<swift::SILDebugVariable, false> const&>(std::__1::__optional_copy_base<swift::SILDebugVariable, false> const&)) in archive lib/libswiftCompilerModules.a
>>> referenced by SIL.o
>>> SIL.o:(void std::__1::__optional_storage_base<swift::SILDebugVariable, false>::__assign_from[abi:se180100]<std::__1::__optional_copy_assign_base<swift::SILDebugVariable, false> const&>(std::__1::__optional_copy_assign_base<swift::SILDebugVariable, false> const&)) in archive lib/libswiftCompilerModules.a
ld.lld: error: undefined hidden symbol: void* std::__1::__voidify[abi:se180100]<swift::FixedOperandList<1u>>(swift::FixedOperandList<1u>&)
>>> referenced by SIL.o
>>> SIL.o:(swift::FixedOperandList<1u>* std::__1::__construct_at[abi:se180100]<swift::FixedOperandList<1u>, swift::EnumInst*, swift::SILValue&, swift::FixedOperandList<1u>*>(swift::FixedOperandList<1u>*, swift::EnumInst*&&, swift::SILValue&)) in archive lib/libswiftCompilerModules.a
ld.lld: error: undefined hidden symbol: void* std::__1::__voidify[abi:se180100]<swift::SILType>(swift::SILType&)
>>> referenced by SIL.o
>>> SIL.o:(swift::DebugValueInst::getVarInfo(bool) const) in archive lib/libswiftCompilerModules.a
>>> referenced by SIL.o
>>> SIL.o:(swift::AllocStackInst::getVarInfo(bool) const) in archive lib/libswiftCompilerModules.a
>>> referenced by SIL.o
>>> SIL.o:(swift::AllocStackInst::getVarInfo(bool) const) in archive lib/libswiftCompilerModules.a
I'm also able to work around this issue by applying the same patch to libc++ modulemap (at /usr/include/c++/module.modulemap
)
Description
I just tried building the Swift 6.1 trunk Sep.4 source snapshot natively on Android 13 AArch64 with the new Android NDK 27 sysroot and it failed with this linker error:
Modifying the libc++ module map like this got it to build again:
This worked fine when building the Aug. 6 trunk source snapshot with the NDK 26b sysroot last month, so I looked into it and that NDK did not ship with @ian-twilightcoder's reorganization of the libc++ module map from last summer, llvm/llvm-project@571178a21. NDK 27 ships with a lightly-patched version of that upstream libc++ module map, but I don't see anything when comparing their changes to the version in swiftlang/llvm-project that would cause this error.
I also see 11 newly failing C++ Interop tests from the Swift compiler validation suite, which all worked fine last month with NDK 26b:
Since the upstream libc++ reorg shipped with the LLVM 17 release last fall and there don't appear to be any fixes merged for this issue since, I assume this doesn't affect clang/C++, only Swift->C++ Interop, so I filed the issue here.
Reproduction
See commands pasted above
Expected behavior
No linker errors
Environment
Android 13 AArch64 in the Termux app
Additional information
I'll see what other module map changes get those 11 failing C++ Interop tests to build again. In the meantime, aren't there other environments using Swift with libc++ also that fail in this way?
@egorzhdan or @ldionne, in addition to Ian, let me know what you think.