Skip to content

Startup objects disappearing when running testsuite #120784

Closed
@Nikokrock

Description

@Nikokrock

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions