Created attachment 649226 [details] build.log The solution is to add in config.toml under the [llvm] section: use-libcxx = true when the compiler is sys-devel/clang[default-libcxx] or -stdlib=libc++ is passed as a compiler flag. Arfrever suggested the following check on IRC: tc-is-clang && { has_version "sys-devel/clang:$(clang-major-version)[default-libcxx]" || is-flagq -stdlib=libc++; }
yes, please go with that suggestion. I don't like it because it introduces a automagic dependency, but amount of users who's going to use it will be less than 5 probably, so that's fine ;-) as for implementation, please pass ( we are not doing it now) use-libcxx = false in [llvm] section by default, in the main `echo` call. and after that call introduce a check and a sed that will modify something like > if need-to-use-libcxx-check; then > sed -i '/^use-libcxx/ s/false/true/' config.toml || die > fi
Created attachment 649312 [details] libcxx rust failing to bootstrap itself I'm having trouble getting rust to compile itself with USE=system-bootstrap after compiling successfully with libcxx. Attached is the build.log showing the failure. It references a failed command, here is the output of the command run: # /usr/bin/cargo build --manifest-path /tmp/portage/dev-lang/rust-1.44.1/work/rustc-1.44.1-src/src/bootstrap/Cargo.toml --verbose --locked --frozen error: failed to get `cc` as a dependency of package `bootstrap v0.0.0 (/tmp/portage/dev-lang/rust-1.44.1/work/rustc-1.44.1-src/src/bootstrap)` Caused by: attempting to make an HTTP request, but --frozen was specified When run without --frozen, the build system contacts crates.io.
*** Bug 747976 has been marked as a duplicate of this bug. ***
I compile rust 1.47.0 with `use-libcxx=true`, system-bootstrap and system-llvm and it can bootstrap itself. I can drop this hack: > cat /usr/lib/libstdc++.so GROUP ( libc++_shared.so libc++abi.so libunwind.so )
Created attachment 780782 [details] 1.61.0 with "use-libcxx = true" in config.toml Any news on this one? I had everything building against libc++ (even without any patches) with rust-1.60.0, but 1.61.0 broke my build and I can't seem to be able to fix it. Adding "use-libcxx = true" to config.toml does not seem to work for me either (see attached build.log). I am at a loss as to how to fix this now...
If rust got broken for your specific usecase inbetween two stable versions, you do have a good chance to get enough evidence together to open an upstream bug. You could for instance start by diffing the released tarballs for the specific lib that fails to compile.
A fresh build.log and emerge --info in addition to the above suggestion would help too.
build.log for 1.61.0 with the addition of "use-libcxx = true" in the part of the ebuild that writes config.toml was already attached to my previous comment. emerge info and a build.log for unmodified 1.61.0-r1 follow. I know next to nothing about Rust, its deployment and how to debug these things, so reporting a proper upstream bug would probably not be the easiest thing for me...
Created attachment 780794 [details] build.log for 1.61.0-r1
Created attachment 780797 [details] emerge --info when trrying to build 1.61.0-r1
(In reply to Manuel Nickschas from comment #8) > build.log for 1.61.0 with the addition of "use-libcxx = true" in the part of > the ebuild that writes config.toml was already attached to my previous > comment. emerge info and a build.log for unmodified 1.61.0-r1 follow. > > I know next to nothing about Rust, its deployment and how to debug these > things, so reporting a proper upstream bug would probably not be the easiest > thing for me... [rustc_llvm 0.0.0] cargo:rustc-link-lib=dylib=LLVM-14libcxx [rustc_llvm 0.0.0] thread 'main' panicked at 'assertion failed: !cxxflags.contains(\"stdlib=libc++\")', compiler/rustc_llvm/build.rs:351:13 [rustc_llvm 0.0.0] stack backtrace: [rustc_llvm 0.0.0] 0: rust_begin_unwind [rustc_llvm 0.0.0] 1: core::panicking::panic_fmt [rustc_llvm 0.0.0] 2: core::panicking::panic [rustc_llvm 0.0.0] 3: build_script_build::main [rustc_llvm 0.0.0] 4: core::ops::function::FnOnce::call_once [rustc_llvm 0.0.0] note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. [rustc_llvm 0.0.0] cargo:rustc-link-search=native=/usr/lib/llvm/14/lib64 [rustc_llvm 0.0.0] cargo:rerun-if-env-changed=LLVM_LINKER_FLAGS [rustc_llvm 0.0.0] cargo:rerun-if-env-changed=LLVM_STATIC_STDCPP [rustc_llvm 0.0.0] cargo:rerun-if-env-changed=LLVM_USE_LIBCXX [0m[0m[1m[31merror[0m[1m:[0m failed to run custom build command for `rustc_llvm v0.0.0 (/var/tmp/portage/dev-lang/rust-1.61.0-r1/work/rustc-1.61.0-src/compiler/rustc_llvm)` Caused by: process didn't exit successfully: `/var/tmp/portage/dev-lang/rust-1.61.0-r1/work/rustc-1.61.0-src/build/x86_64-unknown-linux-gnu/stage0-rustc/release/build/rustc_llvm-179873ca4957ca7c/build-script-build` (exit status: 101) --- stdout cargo:rerun-if-env-changed=RUST_CHECK Very odd. It's dying specifically because it's in your flags. I wonder what we need to pass down.
it happens here: https://github.com/rust-lang/rust/blob/fe5b13d681f25ee6474be29d748c65adcd91f69e/compiler/rustc_llvm/build.rs#L351 > assert!(!cxxflags.contains("stdlib=libc++")); so it runs llvm-config and checks if it cxxflags contain libc++ what does this command print on your system? llvm-config --cxxflags ?
also what happens if you dont't use system-llvm? (you still will need use-libcxx though)
actually I don't thing your use-libcxx part works here's part of config from your build log * config.toml contents: changelog-seen = 2 [llvm] download-ci-llvm = false optimize = true release-debuginfo = false assertions = false ninja = true targets = "BPF;NVPTX;X86" experimental-targets = "" link-shared = true [build] ... so use-libcxx ls clearly missing from [llvm] section.
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3bdbb08f39ee8ad706760eca5138470e88722510 commit 3bdbb08f39ee8ad706760eca5138470e88722510 Author: Georgy Yakovlev <gyakovlev@gentoo.org> AuthorDate: 2022-05-26 21:44:04 +0000 Commit: Georgy Yakovlev <gyakovlev@gentoo.org> CommitDate: 2022-05-26 21:44:43 +0000 dev-lang/rust: attempt to support libcxx in 1.61.0-r1 Bug: https://bugs.gentoo.org/732632 Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org> dev-lang/rust/rust-1.61.0-r1.ebuild | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
ok I comitted minor change, it should detect if you run libcxx can you try it? you should no longer need to edit the ebuild I don't have libcxx setup, but configure properly sets 'use-libcxx = true' if I run > CXX=clang CC=clang CXXFLAGS="-stdlib=libc++" ebuild rust-1.61.0-r1.ebuild clean configure
so libcxx is used if the detexed compiler is clang with USE="+system-libcxx", or if -stdlib=libc++ is detected?
(In reply to tt_1 from comment #17) > so libcxx is used if the detexed compiler is clang with > USE="+system-libcxx", or if -stdlib=libc++ is detected? You read correctly - both are functionally the same, right? What's the issue?
Created attachment 780989 [details] build.log for 1.61.0-r1 with use-libcxx=true Build log in #c5 was with an ebuild to include "use-libcxx=true". Build log in #c9 was without. Sorry for the confusion. I tried again with your change, the flag is set correctly, but the build still fails for the same reason. To me it looks as if some component doesn't get the message that we're building with libcxx, and asserts because we do. FWIW, I don't even have -stdlib=libc++ in my CXXFLAGS, I build clang with USE="+system-libcxx" so it's the default. Something in the Rust build system seems to be figuring that out, and sets the -stdlib flag explicitly for some reason... I'll try with USE=-system-llvm next, but I'm almost sure I already tried that before to no avail. Thanks!
Created attachment 781073 [details] build.log with USE=-system-llvm With USE=-system-llvm, I get a different error: Running `CARGO=/usr/lib/rust/1.60.0/bin/cargo CARGO_CRATE_NAME=rustc_llvm CARGO_MANIFEST_DIR=/var/tmp/portage/dev-lang/rust-1.61.0-r1/work/rustc-1.61.0-src/compiler/rustc_llvm CARGO_PKG_AUTHORS='' CARGO_PKG_DESCRIPTION='' CARGO_PKG_HOMEPAGE ='' CARGO_PKG_LICENSE='' CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=rustc_llvm CARGO_PKG_REPOSITORY='' CARGO_PKG_VERSION=0.0.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=0 CARGO_PKG_VERSION_PATCH=0 CARGO_PKG_VERSION_PRE='' LD_LIBRARY_PATH=' /var/tmp/portage/dev-lang/rust-1.61.0-r1/work/rustc-1.61.0-src/build/x86_64-unknown-linux-gnu/stage0-rustc/release/deps:/usr/lib/rust/1.60.0/lib' OUT_DIR=/var/tmp/portage/dev-lang/rust-1.61.0-r1/work/rustc-1.61.0-src/build/x86_64-unknown-linux-g nu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/rustc_llvm-5d034262ce529127/out /var/tmp/portage/dev-lang/rust-1.61.0-r1/work/rustc-1.61.0-src/build/bootstrap/debug/rustc --crate-name rustc_llvm --edition=2021 compiler/rustc_llvm/src/lib. rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no -C debuginfo=0 -C metadata=2e490da81da22c4b -C extra-filename=-2e490da81da22c4b -- out-dir /var/tmp/portage/dev-lang/rust-1.61.0-r1/work/rustc-1.61.0-src/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -C linker=clang -L dependency=/var/tmp/portage/dev-lang/ru st-1.61.0-r1/work/rustc-1.61.0-src/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps -L dependency=/var/tmp/portage/dev-lang/rust-1.61.0-r1/work/rustc-1.61.0-src/build/x86_64-unknown-linux-gnu/stage0-rustc/release /deps --extern libc=/var/tmp/portage/dev-lang/rust-1.61.0-r1/work/rustc-1.61.0-src/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/liblibc-06fb9222ffad2320.rmeta --cfg=bootstrap -Csymbol-mangling-version=v0 -Zma cro-backtrace -Ztls-model=initial-exec -Zunstable-options '-Wrustc::internal' -Cprefer-dynamic -Z binary-dep-depinfo -L native=/var/tmp/portage/dev-lang/rust-1.61.0-r1/work/rustc-1.61.0-src/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unkn own-linux-gnu/release/build/rustc_llvm-5d034262ce529127/out -L native=/var/tmp/portage/dev-lang/rust-1.61.0-r1/work/rustc-1.61.0-src/build/x86_64-unknown-linux-gnu/llvm/build/lib -L native=/usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0 --cfg 'llvm_comp onent="asmparser"' --cfg 'llvm_component="bitreader"' --cfg 'llvm_component="bitwriter"' --cfg 'llvm_component="bpf"' --cfg 'llvm_component="coverage"' --cfg 'llvm_component="instrumentation"' --cfg 'llvm_component="ipo"' --cfg 'llvm_component=" linker"' --cfg 'llvm_component="lto"' --cfg 'llvm_component="nvptx"' --cfg 'llvm_component="x86"' -l static=llvm-wrapper -l static=LLVMX86TargetMCA -l static=LLVMMCA -l static=LLVMX86Disassembler -l static=LLVMX86AsmParser -l static=LLVMX86CodeG en -l static=LLVMCFGuard -l static=LLVMGlobalISel -l static=LLVMX86Desc -l static=LLVMX86Info -l static=LLVMNVPTXCodeGen -l static=LLVMNVPTXDesc -l static=LLVMNVPTXInfo -l static=LLVMLTO -l static=LLVMPasses -l static=LLVMCoroutines -l static=LL VMObjCARCOpts -l static=LLVMExtensions -l static=LLVMCoverage -l static=LLVMBPFDisassembler -l static=LLVMMCDisassembler -l static=LLVMBPFAsmParser -l static=LLVMBPFCodeGen -l static=LLVMSelectionDAG -l static=LLVMipo -l static=LLVMInstrumentati on -l static=LLVMVectorize -l static=LLVMLinker -l static=LLVMIRReader -l static=LLVMFrontendOpenMP -l static=LLVMBPFDesc -l static=LLVMBPFInfo -l static=LLVMAsmPrinter -l static=LLVMDebugInfoMSF -l static=LLVMCodeGen -l static=LLVMTarget -l sta tic=LLVMScalarOpts -l static=LLVMInstCombine -l static=LLVMAggressiveInstCombine -l static=LLVMTransformUtils -l static=LLVMBitWriter -l static=LLVMAnalysis -l static=LLVMProfileData -l static=LLVMDebugInfoDWARF -l static=LLVMObject -l static=LL VMTextAPI -l static=LLVMMCParser -l static=LLVMMC -l static=LLVMDebugInfoCodeView -l static=LLVMBitReader -l static=LLVMAsmParser -l static=LLVMCore -l static=LLVMRemarks -l static=LLVMBitstreamReader -l static=LLVMBinaryFormat -l static=LLVMSupport -l static=LLVMDemangle -l dylib=rt -l dylib=dl -l dylib=m -l dylib=z -l static=c++` error: could not find native static library `c++`, perhaps an -L flag is missing? FWIW, I have sys-libs/libcxx built with USE=static-libs and /usr/lib64/libc++.a is available. So I guess this is a sandboxed build of the bundled toolchain, and again some part of the build system does not know about libcxx...
what's the output of > llvm-config --cxxflags on your system?
# llvm-config --cxxflags -I/usr/lib/llvm/14/include -std=c++14 -stdlib=libc++ -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS Okay, so that's where the flag comes from apparently...
After some testing and trying to understand the rust's build system I think I found the reason why rust fails to build with libcxx: The config defaults the option `static-libstdcpp` in the `[llvm]` section to true because it isn't set by the ebuild. However this doesn't work because we build with libcxx. This causes the error/panic in the `> assert!(!cxxflags.contains("stdlib=libc++"));` part so the build fails because we have `-stdlib=libc++` in our CXXFLAGS while trying to statically link against libstdc++. The solution is to set `static-libstdcpp = false` if we are building with libcxx. I just ran an emerge with this set in the config.toml to check and it built successfully against libcxx.
I can confirm that Jonas' fix works for me as well! Thanks for pinpointing that.
Thanks for figuring it out, I don’t have the setup and it was weird figuring this out blindly, I’ll add this knob to libcxx condition block.
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1eec1bfb2d551241c3d4e67ecacf2f0c89e76632 commit 1eec1bfb2d551241c3d4e67ecacf2f0c89e76632 Author: Georgy Yakovlev <gyakovlev@gentoo.org> AuthorDate: 2022-05-31 17:42:51 +0000 Commit: Georgy Yakovlev <gyakovlev@gentoo.org> CommitDate: 2022-05-31 17:43:50 +0000 dev-lang/rust: pass static-libstdcpp = false for libcxx build Bug: https://bugs.gentoo.org/732632 Thanks-to: Jonas Rakebrandt <xarblu@protonmail.com> Tested-by: Manuel Nickschas <sputnick@quassel-irc.org> Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org> dev-lang/rust/rust-1.61.0-r1.ebuild | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Fixed ebuild confirmed working, thanks a lot to all involved!
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3fa47c76138a86a5d29d30230c0afc1946d46d5b commit 3fa47c76138a86a5d29d30230c0afc1946d46d5b Author: Sam James <sam@gentoo.org> AuthorDate: 2022-09-16 00:33:02 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2022-09-16 00:35:04 +0000 profiles/features/clang: add LLVM_USE_LIBCXX, CXXSTDLIB Needed to build some Rust crates like sys-apps/uutils. I'd heard some users mention needing to set this but hadn't poked particularly far (was in the context of trying to do Firefox + libc++ on non-LLVM profiles IIRC). Bug: https://bugs.gentoo.org/732632 Bug: https://bugs.gentoo.org/870280 Thanks-to: Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org> Thanks-to: Georgy Yakovlev <gyakovlev@gentoo.org> Signed-off-by: Sam James <sam@gentoo.org> profiles/features/clang/make.defaults | 3 +++ 1 file changed, 3 insertions(+)
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9e38708993c9481291726a1bead4e396799b9dba commit 9e38708993c9481291726a1bead4e396799b9dba Author: Sam James <sam@gentoo.org> AuthorDate: 2022-09-16 00:54:11 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2022-09-16 00:55:14 +0000 profiles/features/clang: add links for libcxx Rust variables Bug: https://bugs.gentoo.org/732632 Bug: https://bugs.gentoo.org/870280 See: 3fa47c76138a86a5d29d30230c0afc1946d46d5b Thanks-to: Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org> Signed-off-by: Sam James <sam@gentoo.org> profiles/features/clang/make.defaults | 3 +++ 1 file changed, 3 insertions(+)
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a903ffe027a436e6b391d3233c94c69aaea0a393 commit a903ffe027a436e6b391d3233c94c69aaea0a393 Author: Georgy Yakovlev <gyakovlev@gentoo.org> AuthorDate: 2022-10-06 21:32:11 +0000 Commit: Georgy Yakovlev <gyakovlev@gentoo.org> CommitDate: 2022-10-06 22:14:42 +0000 dev-lang/rust: change libcxx detection method Bug: https://bugs.gentoo.org/732632 Bug: https://bugs.gentoo.org/875563 Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org> dev-lang/rust/rust-1.64.0-r1.ebuild | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)