Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bootstrap: copy_self_contained_objects can't find crtbegin.o when cc=clang #84033

Closed
12101111 opened this issue Apr 9, 2021 · 0 comments · Fixed by #85395
Closed

bootstrap: copy_self_contained_objects can't find crtbegin.o when cc=clang #84033

12101111 opened this issue Apr 9, 2021 · 0 comments · Fixed by #85395
Labels
C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@12101111
Copy link
Contributor

12101111 commented Apr 9, 2021

c7091f5 add "crtbegin.o", "crtbeginS.o", "crtend.o", "crtendS.o" to self-contained object files, but it don't works for me.

Add some code to print the command line:

--- a/src/bootstrap/compile.rs
+++ b/src/bootstrap/compile.rs
@@ -905,6 +905,9 @@ pub fn compiler_file(
     let mut cmd = Command::new(compiler);
     cmd.args(builder.cflags(target, GitRepo::Rustc));
     cmd.arg(format!("-print-file-name={}", file));
+    builder.info(&format!(
+        "!!!!cmd: {:?}",cmd
+    ));
     let out = output(&mut cmd);
     PathBuf::from(out.trim())
 }
Copy "/usr/src/x86_64-linux-musl/sysroot/lib/crt1.o" to "/home/han/rust/build/x86_64-unknown-linux-musl/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crt1.o"
Copy "/usr/src/x86_64-linux-musl/sysroot/lib/Scrt1.o" to "/home/han/rust/build/x86_64-unknown-linux-musl/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/Scrt1.o"
Copy "/usr/src/x86_64-linux-musl/sysroot/lib/rcrt1.o" to "/home/han/rust/build/x86_64-unknown-linux-musl/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/rcrt1.o"
Copy "/usr/src/x86_64-linux-musl/sysroot/lib/crti.o" to "/home/han/rust/build/x86_64-unknown-linux-musl/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crti.o"
Copy "/usr/src/x86_64-linux-musl/sysroot/lib/crtn.o" to "/home/han/rust/build/x86_64-unknown-linux-musl/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crtn.o"
!!!!cmd: "clang" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=x86_64-unknown-linux-musl" "-print-file-name=crtbegin.o"
Copy "crtbegin.o" to "/home/han/rust/build/x86_64-unknown-linux-musl/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crtbegin.o"
thread 'main' panicked at 'src.symlink_metadata() failed with No such file or directory (os error 2)', src/bootstrap/lib.rs:1196:24
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

It seems the --target=x86_64-unknown-linux-musl argument cause clang omit the path of those files.

> clang -ffunction-sections -fdata-sections -fPIC --target=x86_64-unknown-linux-musl -print-file-name=crtbegin.o
crtbegin.o
> clang -ffunction-sections -fdata-sections -fPIC -print-file-name=crtbegin.o
/usr/lib/gcc/x86_64-gentoo-linux-musl/10.3.0/crtbegin.o
> gcc -ffunction-sections -fdata-sections -fPIC --target=x86_64-unknown-linux-musl -print-file-name=crtbegin.o
gcc: error: unrecognized command-line option '--target=x86_64-unknown-linux-musl'
/usr/lib/gcc/x86_64-gentoo-linux-musl/10.3.0/crtbegin.o
> gcc -ffunction-sections -fdata-sections -fPIC -print-file-name=crtbegin.o
/usr/lib/gcc/x86_64-gentoo-linux-musl/10.3.0/crtbegin.o

Meta

rustc --version --verbose:

rustc 1.52.0-beta.3 (215738137 2021-04-06)
binary: rustc
commit-hash: 215738137bcbef2c3637a5bd290ef612cffe6ba5
commit-date: 2021-04-06
host: x86_64-unknown-linux-musl
release: 1.52.0-beta.3
LLVM version: 12.0.0
@12101111 12101111 added the C-bug Category: This is a bug. label Apr 9, 2021
@jyn514 jyn514 added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Apr 9, 2021
@bors bors closed this as completed in 7baa7af May 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants