This fixes a problem reported for the RISC-V Haiku OS port, where putting STARTFILE_PREFIX_SPEC in riscv.h breaks their port because they put libraries in different directories than the UNIX convention. The current definition is definitely needed for Linux. It should not be needed for rtems or embedded elf which use cross compilers. It may or may not be needed for FreeBSD, I can't easily tell, but it is harmless, and can be removed later if they don't want it. So I'm moving the definition from riscv.h into the freebsd.h and linux.h files.
Tested with cross builds and make checks for riscv32-elf and riscv64-linux. There were no regressions. Also tested by checking the --print-search-dirs output for elf, linux, and freebsd cross compiler builds. Committed. Jim gcc/ PR target/89955 * config/riscv/riscv.h (STARTFILE_PREFIX_SPEC): Deleted. * config/riscv/freebsd.h (STARTFILE_PREFIX_SPEC): Added. * config/riscv/linux.h (STARTFILE_PREFIX_SPEC): Added. --- gcc/config/riscv/freebsd.h | 6 ++++++ gcc/config/riscv/linux.h | 6 ++++++ gcc/config/riscv/riscv.h | 6 ------ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/gcc/config/riscv/freebsd.h b/gcc/config/riscv/freebsd.h index 13d04ccbb47..bc516628285 100644 --- a/gcc/config/riscv/freebsd.h +++ b/gcc/config/riscv/freebsd.h @@ -52,3 +52,9 @@ along with GCC; see the file COPYING3. If not see %{rdynamic:-export-dynamic} \ -dynamic-linker " FBSD_DYNAMIC_LINKER "} \ %{static:-static}}" + +#define STARTFILE_PREFIX_SPEC \ + "/lib" XLEN_SPEC "/" ABI_SPEC "/ " \ + "/usr/lib" XLEN_SPEC "/" ABI_SPEC "/ " \ + "/lib/ " \ + "/usr/lib/ " diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h index 58dd18b89f3..07ce80a847c 100644 --- a/gcc/config/riscv/linux.h +++ b/gcc/config/riscv/linux.h @@ -68,3 +68,9 @@ along with GCC; see the file COPYING3. If not see %{static:-static}}" #define TARGET_ASM_FILE_END file_end_indicate_exec_stack + +#define STARTFILE_PREFIX_SPEC \ + "/lib" XLEN_SPEC "/" ABI_SPEC "/ " \ + "/usr/lib" XLEN_SPEC "/" ABI_SPEC "/ " \ + "/lib/ " \ + "/usr/lib/ " diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h index 4edd2a60194..8856cee599e 100644 --- a/gcc/config/riscv/riscv.h +++ b/gcc/config/riscv/riscv.h @@ -893,12 +893,6 @@ extern unsigned riscv_stack_boundary; "%{mabi=lp64f:lp64f}" \ "%{mabi=lp64d:lp64d}" \ -#define STARTFILE_PREFIX_SPEC \ - "/lib" XLEN_SPEC "/" ABI_SPEC "/ " \ - "/usr/lib" XLEN_SPEC "/" ABI_SPEC "/ " \ - "/lib/ " \ - "/usr/lib/ " - /* ISA constants needed for code generation. */ #define OPCODE_LW 0x2003 #define OPCODE_LD 0x3003 -- 2.17.1