[PATCH v2] ld: Rename a file on Windows fails if target already exists
Jan Beulich
jbeulich@suse.com
Mon Jul 21 06:05:00 GMT 2025
On 19.07.2025 09:34, Torbjörn SVENSSON wrote:
> Changes since v1:
>
> - Apparently, the include of errno was never committed before.
> I've rebuilt and rechecked that this works on Windows again.
>
>
> Without this patch, the GCC testsuite gives errors like:
>
> Testing gcc.dg/lto/20091027-1, -O0 -flto -flto-partition=1to1 -fno-use-linker-plugin
> doing compile
> Executing on host: arm-none-eabi-gcc.exe -mthumb -march=armv6s-m -mcpu=cortex-m0 -mfloat-abi=soft -fdiagnostics-plain-output -O0 -flto -flto-partition=1to1 -fno-use-linker-plugin -c -o c_lto_20091027-1_0.o /build/src/gcc/gcc/testsuite/gcc.dg/lto/20091027-1_0.c (timeout = 800)
> spawn -ignore SIGHUP arm-none-eabi-gcc.exe -mthumb -march=armv6s-m -mcpu=cortex-m0 -mfloat-abi=soft -fdiagnostics-plain-output -O0 -flto -flto-partition=1to1 -fno-use-linker-plugin -c -o c_lto_20091027-1_0.o /build/src/gcc/gcc/testsuite/gcc.dg/lto/20091027-1_0.c
> pid is 52421 -52421
> pid is -1
> output is status 0
> PASS: gcc.dg/lto/20091027-1 c_lto_20091027-1_0.o assemble, -O0 -flto -flto-partition=1to1 -fno-use-linker-plugin
> doing compile
> Executing on host: arm-none-eabi-gcc.exe -mthumb -march=armv6s-m -mcpu=cortex-m0 -mfloat-abi=soft -fdiagnostics-plain-output -O0 -flto -flto-partition=1to1 -fno-use-linker-plugin -c -o c_lto_20091027-1_1.o /build/src/gcc/gcc/testsuite/gcc.dg/lto/20091027-1_1.c (timeout = 800)
> spawn -ignore SIGHUP arm-none-eabi-gcc.exe -mthumb -march=armv6s-m -mcpu=cortex-m0 -mfloat-abi=soft -fdiagnostics-plain-output -O0 -flto -flto-partition=1to1 -fno-use-linker-plugin -c -o c_lto_20091027-1_1.o /build/src/gcc/gcc/testsuite/gcc.dg/lto/20091027-1_1.c
> pid is 52444 -52444
> pid is -1
> output is status 0
> PASS: gcc.dg/lto/20091027-1 c_lto_20091027-1_1.o assemble, -O0 -flto -flto-partition=1to1 -fno-use-linker-plugin
> doing compile
> Executing on host: arm-none-eabi-gcc.exe c_lto_20091027-1_0.o c_lto_20091027-1_1.o -mthumb -march=armv6s-m -mcpu=cortex-m0 -mfloat-abi=soft -dumpbase "" -fdiagnostics-plain-output -O0 -flto -flto-partition=1to1 -fno-use-linker-plugin -r -nostdlib -flinker-output=nolto-rel -Wl,--start-group -lc -lm -Wl,--end-group --specs=nosys.specs -o gcc-dg-lto-20091027-1-21.exe (timeout = 800)
> spawn -ignore SIGHUP arm-none-eabi-gcc.exe c_lto_20091027-1_0.o c_lto_20091027-1_1.o -mthumb -march=armv6s-m -mcpu=cortex-m0 -mfloat-abi=soft -dumpbase -fdiagnostics-plain-output -O0 -flto -flto-partition=1to1 -fno-use-linker-plugin -r -nostdlib -flinker-output=nolto-rel -Wl,--start-group -lc -lm -Wl,--end-group --specs=nosys.specs -o gcc-dg-lto-20091027-1-21.exe
> pid is 52471 -52471
> T:../lib/gcc/arm-none-eabi/14.3.1/../../../../arm-none-eabi/bin/ld.exe: failed to rename output with object-only section
> collect2.exe: error: ld returned 1 exit status
> pid is -1
> close result is 52471 exp6 0 1
> output is T:../lib/gcc/arm-none-eabi/14.3.1/../../../../arm-none-eabi/bin/ld.exe: failed to rename output with object-only section
> collect2.exe: error: ld returned 1 exit status
> status 1
> compiler exited with status 1
> FAIL: gcc.dg/lto/20091027-1 c_lto_20091027-1_0.o-c_lto_20091027-1_1.o link, -O0 -flto -flto-partition=1to1 -fno-use-linker-plugin
>
>
> With this patch, the test is a PASS.
>
> Ok for trunk?
Yes.
> @Nick: Is this something that should be considered for 2.45 branch? Regression started with 2.44 release.
Cc-ing Nick for him to answer this.
Jan
More information about the Binutils
mailing list