On Wed, Feb 24, 2021 at 6:13 PM Yeting Kuo via Gcc-help < gcc-help@xxxxxxxxxxx> wrote: > $ riscv32-unknown-elf-g++ test.o -Wl,--start-group x.o -lc -Wl,--end-group > -v > If you make all of the options linker options instead of compiler options, then the compiler won't re-sort them. E.g. this works riscv32-unknown-elf-g++ test.o -Wl,--start-group -Wl,x.o -Wl,-lc -Wl,--end-group -v However, if you have some special library that requires special treatment, it is probably better to encode that in the specs. If this is for a special target triplet, then you can modify the LINK_SPEC for the target in the gcc sources. Otherwise, you can try using a modified specs file. You can use riscv32-unknown-elf-gcc -dumpspecs > specs to see the default specs file. You can provide an incremental specs file to modify lib or link_command or whatever is appropriate for your target. You can then specify the specs file when linking with -specs=yourspecfile. Or you can modify the default specs file and then copy it into the same dir where cc1 lives if you want it used for all compilers. You can find an example of how to do this incrementally in libgloss. https://sourceware.org/git/?p=newlib-cygwin.git;a=blob;f=libgloss/riscv/nano.specs;h=e12e31384241c58a5a07341a0f7cebc4fac9ed20;hb=HEAD When using riscv-gnu-toolchain and adding -specs=nano.specs we link with -lc_nano instead of -lc. A simpler example might just be appending an extra library to lib. Jim