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

Startup objects disappearing when running testsuite #120784

Closed
Nikokrock opened this issue Feb 8, 2024 · 3 comments · Fixed by #120831
Closed

Startup objects disappearing when running testsuite #120784

Nikokrock opened this issue Feb 8, 2024 · 3 comments · Fixed by #120831
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

@Nikokrock
Copy link
Contributor

Hi,

I was running the following command for the x86_64-pc-windows-gnu platform after bootstrapping completely the compiler:

 python x.py test \
--verbose \
--no-fail-fast \
--keep-stage=0 \
--keep-stage=1 \
--keep-stage=2 \
--stage=2 \
library/alloc \
library/core \
library/std \
library/test

I had some strange link issues (output simplified):

 = note: "gcc.exe" "-fno-use-linker-plugin"  "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-m64" "-Wl,--high-entropy-va" "rsbegin.o" "C:\\tmp\\rustcUs9Xka\\symbols.o" [...] "-Wl,-Bdynamic" "-lkernel32" "-lkernel32" "-ladvapi32" "-luserenv" "-lkernel32" "-lws2_32" "-lbcrypt" "-lntdll" "-lgcc_s" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "-Wl,--nxcompat" "-L" "<BUILD_DIR>\\build\\x86_64-pc-windows-gnu\\stage2\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-o" "<BUILD_DIR>\\build\\x86_64-pc-windows-gnu\\stage2-rustc\\x86_64-pc-windows-gnu\\release\\deps\\rustc_lexer-6fc796dffd134063.exe" "-Wl,--gc-sections" "-no-pie" "-Wl,-O1" "-nodefaultlibs" "rsend.o"
  = note: <GCC_DIR>/bin/../lib/gcc/x86_64-w64-mingw32/13.2.1/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find rsbegin.o: No such file or directory
          <GCC_DIR>/bin/../lib/gcc/x86_64-w64-mingw32/13.2.1/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find rsend.o: No such file or directory
          collect2.exe: error: ld returned 1 exit status

After some investigation it seems that when calling Assemble step we reach the Std step and the following code:

        if builder.config.keep_stage.contains(&compiler.stage)
            || builder.config.keep_stage_std.contains(&compiler.stage)
        {
            builder.info("WARNING: Using a potentially old libstd. This may not behave well.");

            self.copy_extra_objects(builder, &compiler, target);

            builder.ensure(StdLink::from_std(self, compiler));
            return;
        }

        builder.update_submodule(&Path::new("library").join("stdarch"));

        // Profiler information requires LLVM's compiler-rt
        if builder.config.profiler {
            builder.update_submodule(&Path::new("src/llvm-project"));
        }

        let mut target_deps = builder.ensure(StartupObjects { compiler, target });

Due to my options, we enter the if block and thus builder.ensure(StartupObjects { compiler, target }); which is in charge of compiling and installing in the sysroot dir is not called. rsbegin.o and rsend.o are not copied and thus not found.

As a consequence the linker command looks like "rsend.o" instead of "<ABSOLUTE_PATH>"/rsend.o (likewise for rsbegin.o)

I am new to Rust, but I think that the right patch would be to add.

builder.ensure(StartupObjects { compiler, target });

in the first if block. It worked for me, but not sure this is the right thing to do.

Thanks

@Nikokrock Nikokrock added the C-bug Category: This is a bug. label Feb 8, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 8, 2024
@onur-ozkan onur-ozkan added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 8, 2024
@onur-ozkan
Copy link
Member

Thank you for reporting this. The proposed fix seems quite correct to me. Would you like to submit a PR?

@Nikokrock
Copy link
Contributor Author

Ok. Need to finish the reading of the contributing document first :-)

@onur-ozkan
Copy link
Member

onur-ozkan commented Feb 8, 2024

For such small changes, you can simply open the PR with a resonable title and commit message. Nothing more needed :)

Nikokrock added a commit to Nikokrock/rust that referenced this issue Feb 9, 2024
When launching tests with --keep-stage option, startup objects
such as rsbegin.o an rsend.o may disappear from the corresponding
stageN compiler.

Fix issue rust-lang#120784
@onur-ozkan onur-ozkan linked a pull request Feb 9, 2024 that will close this issue
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 9, 2024
…objects, r=onur-ozkan

Startup objects disappearing from sysroot

When launching tests with --keep-stage option, startup objects such as rsbegin.o an rsend.o may disappear from the corresponding stageN compiler.

Fix issue rust-lang#120784
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 9, 2024
…objects, r=onur-ozkan

Startup objects disappearing from sysroot

When launching tests with --keep-stage option, startup objects such as rsbegin.o an rsend.o may disappear from the corresponding stageN compiler.

Fix issue rust-lang#120784
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 9, 2024
Rollup merge of rust-lang#120831 - Nikokrock:pr/disappearing_startup_objects, r=onur-ozkan

Startup objects disappearing from sysroot

When launching tests with --keep-stage option, startup objects such as rsbegin.o an rsend.o may disappear from the corresponding stageN compiler.

Fix issue rust-lang#120784
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.

3 participants