Open kassane opened 8 months ago
So IIUC, you are hitting build issues with libc++
, for the compiler/bundled tools itself. #3711 concerns user programs being able to use core.stdcpp.*
for libc++, with a prebuilt druntime expecting libstdc++ on Linux; this doesn't affect the compiler build itself (the compiler itself isn't using core.stdcpp
).
I've never tried libc++ on Linux; but if both LLVM and the compiler are built against it, I'd expect it to work. As you're getting linker errors for C++-only tools like ldmd2, it looks like there's a mismatch between LLVM and the C++ parts of LDC. What's your exact CMake command-line?
Btw, why libc++? The official LDC binaries link libstdc++ fully statically: https://github.com/ldc-developers/ldc/blob/6ede9a4fdfd04724fc28a60e6460993d8344136f/.github/workflows/main.yml#L33
And libstdc++ is apparently an option with musl, as Alpine's ldc package uses it (https://pkgs.alpinelinux.org/package/edge/community/x86_64/ldc).
What's your exact CMake command-line?
cmake "$ROOTDIR/ldc" \
-DLLVM_ROOT_DIR="$ROOTDIR/out/llvm-cross-$TARGET-$MCPU" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CROSSCOMPILING=True \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_INSTALL_PREFIX="$ROOTDIR/out/$TARGET-$MCPU" \
-DCMAKE_PREFIX_PATH="$ROOTDIR/out/$TARGET-$MCPU" \
-DCMAKE_SYSTEM_NAME="$TARGET_OS_CMAKE" \
-DLLVM_IS_SHARED=OFF \
-DD_COMPILER_FLAGS="-gcc=clang -Xcc=-static -Xcc=-stdlib=libc++ -linker=lld"
cmake --build . --target install --parallel 5
I have had problems building using ldc for musl-abi target (mainly cross-compiling) since issue #4520. However, I use this libc for embedded devices and software portability.
Usually I get into the bad habit of linking libstdc++
with glibc
. I do not know what the limitations of this libc are when cross compiling. Because there are custom llvm builds that don't use libstdc++
to cross compile (similar to the zig toolchain).
The biggest deadlock for me is this error in switching C++ABI. Also, the dependency on llvm-config
makes it difficult to redirect custom llvm root (libs & include only).
The biggest deadlock for me is this bug in switching C++ABI
What bug? AFAICT, you don't pass any -stdlib=libc++
when compiling the LDC C++ parts. From the various logs that you've added, I only see relevant failures when linking C++ executables (ldmd2 and vendored LLVM tools - no D involved anywhere), so if you thought -DD_COMPILER_FLAGS="-gcc=clang -Xcc=-stdlib=libc++
would somehow be enough to switch compiler and tools to libc++, then that's definitely not the case. You'll most likely need to set CMAKE_CXX_FLAGS
or so, as you would for any other C++ project.
What bug?
No, error build only!
AFAICT, you don't pass any
-stdlib=libc++
when compiling the LDC C++ parts.
Yeah! There's not much choice from what I've seen. Hopefully I can at least build it with musl static.
so if you thought
-DD_COMPILER_FLAGS="-gcc=clang -Xcc=-stdlib=libc++"
This flag was needed because the D Compiler failed to follow the default linker. This may be -DLDC_LINK_MANUALLY
related.
You'll most likely need to set
CMAKE_CXX_FLAGS
or so, as you would for any other C++ project.
Ok.
Environment Build Test
OS: Alpine latest (docker) Tools: ldc 1.33 + llvm/clang/libc++ 17 (alpine-pkgs) Compiler: ldc-master (1.37.0) building Arch: x86_64
During a few tests to build the musl-toolchain, I got errors when trying to (static) build it with another C++ ABI (non-gnu)
libc++
. However, when building on Linux systems, only the C++ ABI (GNU)libstdc++
works correctly.I believe the issue is not related to the Musl target, but just the C++ ABI conflict. Briefly, I have attempted build a portable ldc-toolchain for use in a legacy distro without interference from glibc version.
I also have questions about the
-DLLVM_IS_SHARED=OFF
flag and about the parameters passed by llvm-config. Can you make LLVM-rootdir completely independent of llvm-config ( fulfilling all necessary LLVM dependencies)?Some errors
```bash [ 10%] Built target ldc-prune-cache ld.lld: error: undefined symbol: llvm::sampleprof::SampleProfileReader::create(std::__1::basic_stringFull log: ldc2_build_clanglibcxx.log ldc2_build_ziglibcxx.log
Reference