Skip to content

rustc-src: enable rustix use-libc feature, revert ported attributes#400

Open
LinuxUserGD wants to merge 2 commits into
thepowersgang:masterfrom
LinuxUserGD:rustc-patch
Open

rustc-src: enable rustix use-libc feature, revert ported attributes#400
LinuxUserGD wants to merge 2 commits into
thepowersgang:masterfrom
LinuxUserGD:rustc-patch

Conversation

@LinuxUserGD

Copy link
Copy Markdown
Contributor

Workarounds for the following bugs:

This patches the rustix dependency in all cargo crates to include the use-libc feature.
The workaround for #365 was mentioned in https://www.github.com/thepowersgang/mrustc/issues/365#issuecomment-3904762958.

The stage0 rustc fails to compile any project with the error "out of TLS keys" on musl.
This happens because the thread-local storage was bumped with the recent additions/ports of attribute parsers in Rust 1.90.0 (see termux/termux-packages#26682, rust-lang/rust#147590).

--- BUILDING rustc-main v0.0.0 [bin rustc_main] (99.4% 2r,0w,0b,317c/319t)
> /usr/lib/rust/mrustc-9999/bin/mrustc /var/tmp/portage/dev-lang/rust-1.90.0-r1/work/rustc-1.90.0-src/compiler/rustc/src/main.rs -o /var/tmp/portage/dev-lang/rust-1.90.0-r1/work/bootstrap/mrustc-stage0/rustc-build/rustc_main -C emit-depfile=/var/tmp/portage/dev-lang/rust-1.90.0-r1/work/bootstrap/mrustc-stage0/rustc-build/rustc_main.d --cfg debug_assertions -O -L /usr/lib/rust/mrustc-9999/lib/rustlib/x86_64-unknown-linux-musl/lib -L /var/tmp/portage/dev-lang/rust-1.90.0-r1/work/bootstrap/mrustc-stage0/rustc-build --cfg feature="llvm" --cfg feature="rustc_driver_impl" --cfg feature="dep:rustc_driver_impl" --crate-name rustc_main --crate-type bin --crate-tag 0_0_0_H44 --edition 2024 --extern rustc_codegen_ssa=/var/tmp/portage/dev-lang/rust-1.90.0-r1/work/bootstrap/mrustc-stage0/rustc-build/librustc_codegen_ssa.rlib --extern rustc_driver=/var/tmp/portage/dev-lang/rust-1.90.0-r1/work/bootstrap/mrustc-stage0/rustc-build/librustc_driver.rlib --extern rustc_driver_impl=/var/tmp/portage/dev-lang/rust-1.90.0-r1/work/bootstrap/mrustc-stage0/rustc-build/librustc_driver_impl.rlib --extern rustc_public=/var/tmp/portage/dev-lang/rust-1.90.0-r1/work/bootstrap/mrustc-stage0/rustc-build/librustc_public-0_1_0_H4.rlib --extern rustc_public_bridge=/var/tmp/portage/dev-lang/rust-1.90.0-r1/work/bootstrap/mrustc-stage0/rustc-build/librustc_public_bridge.rlib > /var/tmp/portage/dev-lang/rust-1.90.0-r1/work/bootstrap/mrustc-stage0/rustc-build/rustc_main_dbg.txt
 (99.4% 2r,0w,0b,317c/319t): rustc-main v0.0.0 (script run), rustc-main v0.0.0 [bin rustc_main]
Completed rustc-main v0.0.0 (script run)
 (99.7% 1r,0w,0b,318c/319t): rustc-main v0.0.0 [bin rustc_main]
Completed rustc-main v0.0.0 [bin rustc_main]
 (100.0% 0r,0w,0b,319c/319t):
rustc 1.90.0-stable-mrustc
 * Building 'sysroot' using bootstrap rustc (mrustc-stage0) ...
 * env MRUSTC_PATH=/var/tmp/portage/dev-lang/rust-1.90.0-r1/work/bootstrap/mrustc-stage0/rustc-build/rustc minicargo -j 24 --vendor-dir /var/tmp/portage/dev-lang/rust-1.90.0-r1/work/rustc-1.90.0-src/vendor --script-overrides /usr/share/mrustc-9999/script-overrides/stable-1.90.0-linux/ --output-dir /var/tmp/portage/dev-lang/rust-1.90.0-r1/work/bootstrap/mrustc-stage0/lib/rustlib/x86_64-unknown-linux-musl/lib /var/tmp/portage/dev-lang/rust-1.90.0-r1/work/rustc-1.90.0-src/library/sysroot
--- BUILDING core v0.0.0 (0.0% 1r,0w,21b,0c/22t)
> /var/tmp/portage/dev-lang/rust-1.90.0-r1/work/bootstrap/mrustc-stage0/rustc-build/rustc /var/tmp/portage/dev-lang/rust-1.90.0-r1/work/rustc-1.90.0-src/library/core/src/lib.rs -o /var/tmp/portage/dev-lang/rust-1.90.0-r1/work/bootstrap/mrustc-stage0/lib/rustlib/x86_64-unknown-linux-musl/lib/libcore.rlib --emit link,dep-info -C debug-assertions -Z force-unstable-if-unmarked -O -L /var/tmp/portage/dev-lang/rust-1.90.0-r1/work/bootstrap/mrustc-stage0/lib/rustlib/x86_64-unknown-linux-musl/lib --crate-name core --crate-type rlib -C metadata=0_0_0 --edition 2024 > /var/tmp/portage/dev-lang/rust-1.90.0-r1/work/bootstrap/mrustc-stage0/lib/rustlib/x86_64-unknown-linux-musl/lib/libcore.rlib_dbg.txt
 (0.0% 1r,0w,21b,0c/22t): core v0.0.0
warning: due to multiple output types requested, the explicitly specified output file name will be adapted for each output type

fatal runtime error: out of TLS keys, aborting
Process was terminated with signal 6
FAILING COMMAND: /var/tmp/portage/dev-lang/rust-1.90.0-r1/work/bootstrap/mrustc-stage0/rustc-build/rustc /var/tmp/portage/dev-lang/rust-1.90.0-r1/work/rustc-1.90.0-src/library/core/src/lib.rs -o /var/tmp/portage/dev-lang/rust-1.90.0-r1/work/bootstrap/mrustc-stage0/lib/rustlib/x86_64-unknown-linux-musl/lib/libcore.rlib --emit link,dep-info -C debug-assertions -Z force-unstable-if-unmarked -O -L /var/tmp/portage/dev-lang/rust-1.90.0-r1/work/bootstrap/mrustc-stage0/lib/rustlib/x86_64-unknown-linux-musl/lib --crate-name core --crate-type rlib -C metadata=0_0_0 --edition 2024
Env:  OUT_DIR=/var/tmp/portage/dev-lang/rust-1.90.0-r1/work/bootstrap/mrustc-stage0/lib/rustlib/x86_64-unknown-linux-musl/lib/build_core CARGO_CRATE_NAME=core CARGO_MANIFEST_DIR=/var/tmp/portage/dev-lang/rust-1.90.0-r1/work/rustc-1.90.0-src/library/core CARGO_PKG_NAME=core CARGO_PKG_VERSION=0.0.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=0 CARGO_PKG_VERSION_PATCH=0
 (4.5% 0r,0w,21b,1c/22t):
BUILD FAILED

Instead of bumping the limit by changing the musl source code, I've reverted the relevant commits (e. g. "Port #[rustc_coherence_is_core] to the new attribute system") from rust's git history.

Fixes #388 (rust 1.90.0 packaging)

@bjorn3

bjorn3 commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

That revert patch is pretty big and will almost certainly cause huge conflicts in the next release. Would patching away the -Ztls-model=initial-exec in src/bootstrap/src/bin/rustc.rs also fix the issue? That flag is just a minor perf optimization.

@LinuxUserGD

Copy link
Copy Markdown
Contributor Author

Would patching away the -Ztls-model=initial-exec in src/bootstrap/src/bin/rustc.rs also fix the issue?

The error also occurs when removing it from bin/rustc.rs.
I also get the same behaviour with the clang flag -ftls-model=initial-exec (or similar) in codegen_c.cpp.

I'm not sure how to solve this issue in mrustc, maybe patching minicargo (https://github.com/thepowersgang/mrustc/blob/master/tools/minicargo/build.cpp) would work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Packaging of rust1.90_bootstrapped

2 participants