-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-contributor-roadblockArea: Makes things more difficult for new or seasoned contributors to RustArea: Makes things more difficult for new or seasoned contributors to RustC-bugCategory: This is a bug.Category: This is a bug.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.O-muslTarget: The musl libcTarget: The musl libcT-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Description
I cloned the Rust repo with the intention of building rustc for cross-compilation to the riscv64gc-unknown-linux-musl
target. I did the following:
$x.py setup
- selected the "codegen" option- Edited the
config.toml
file to append:
[target.riscv64gc-unknown-linux-musl]
ar = "riscv64-unknown-linux-musl-ar"
linker = "riscv64-unknown-linux-musl-gcc"
cc = "riscv64-unknown-linux-musl-gcc"
cxx = "riscv64-unknown-linux-musl-g++"
musl-root = "/home/tjc/riscv64-linux-musl-cross/riscv64-linux-musl"
./x.py build --target x86_64-unknown-linux-gnu --target riscv64gc-unknown-linux-musl
This failed; the end of the output is as follows:
Building stage1 library artifacts (x86_64-unknown-linux-gnu)
[snip]
Finished release [optimized] target(s) in 43.27s
Building crtbegin.o and crtend.o
running: "riscv64-unknown-linux-musl-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-march=rv64gc" "-mabi=lp64d" "-mcmodel=medany" "-std=c11" "-DCRT_HAS_INITFINI_ARRAY" "-DEH_USE_FRAME_REGISTRY" "-o" "/home/tjc/rust2/build/riscv64gc-unknown-linux-musl/native/crt/crtbegin.o" "-c" "/home/tjc/rust2/src/llvm-project/compiler-rt/lib/crt/crtbegin.c"
cargo:warning=cc1: fatal error: /home/tjc/rust2/src/llvm-project/compiler-rt/lib/crt/crtbegin.c: No such file or directory
cargo:warning=compilation terminated.
exit status: 1
error occurred: Command "riscv64-unknown-linux-musl-gcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-march=rv64gc" "-mabi=lp64d" "-mcmodel=medany" "-std=c11" "-DCRT_HAS_INITFINI_ARRAY" "-DEH_USE_FRAME_REGISTRY" "-o" "/home/tjc/rust2/build/riscv64gc-unknown-linux-musl/native/crt/crtbegin.o" "-c" "/home/tjc/rust2/src/llvm-project/compiler-rt/lib/crt/crtbegin.c" with args "riscv64-unknown-linux-musl-gcc" did not execute successfully (status code exit status: 1).
Build completed unsuccessfully in 0:02:32
After I executed git submodule update --init
and retried the build command, the LLVM submodule was checked out and the build was able to make progress. It seems like this should be done automatically. I'm not sure if the issue is specific to this target or if it's happening with other cross-compilation targets.
Metadata
Metadata
Assignees
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-contributor-roadblockArea: Makes things more difficult for new or seasoned contributors to RustArea: Makes things more difficult for new or seasoned contributors to RustC-bugCategory: This is a bug.Category: This is a bug.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.O-muslTarget: The musl libcTarget: The musl libcT-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
jyn514 commentedon Apr 6, 2023
Hmm. This is some interaction between
download-ci-llvm=true
and cross-compiling, but I'm not sure exactly what — it should be a no-op unless you're building for the host.As a workaround you can set
download-ci-llvm=false
and that should handle the submodule automatically.jyn514 commentedon Apr 6, 2023
(Note that
download-ci-llvm=true
is implied byprofile = codegen
.)jyn514 commentedon Apr 6, 2023
Ok, it looks like we only try to build crtbegin.o for musl targets:
rust/src/bootstrap/compile.rs
Lines 238 to 270 in 8d321f7
So I think we would have checked out the submodule if we were doing a full LLVM build, but because we're only building the CRT it got missed when download-ci-llvm was implemented. I think the simplest fix is to call
builder.update_submodule
at the start ofCrtBeginEnd::run
, like we do for thellvm::Llvm
step:rust/src/bootstrap/llvm.rs
Lines 1077 to 1097 in f98a271
jyn514 commentedon Apr 6, 2023
llvm::Libunwind
looks like it also has the same bug:rust/src/bootstrap/llvm.rs
Lines 1143 to 1167 in f98a271
as well as
dist::Src
:rust/src/bootstrap/dist.rs
Lines 896 to 915 in f98a271
KittyBorgX commentedon Apr 8, 2023
@rustbot claim
KittyBorgX commentedon Apr 8, 2023
Does fixing
llvm::Libunwind
dist::Src
also come under the scope of this issue? I'd be happy to fix that as well.jyn514 commentedon Apr 8, 2023
@KittyBorgX sure thing, feel free to fix all three at once :)
KittyBorgX commentedon Apr 8, 2023
@jyn514 Do I pause work on this till #110074 gets resolved? Since it's implementing the workaround you mentioned as a solution
jyn514 commentedon Apr 8, 2023
@KittyBorgX no, this fix still makes sense - not everyone is using the
codegen
profile without changes.Rollup merge of rust-lang#110265 - KittyBorgX:master, r=ozkanonur