When building a cross-compiler ld for RISC-V Linux systems, you can specify
target=riscv64*-linux* to create a linker that supports both 32-bit
(-march=rv32*) and 64-bit (-march=rv64*) architectures. The specified -march
value populates the EMULATION_NAME variable, which determines the default
linker script selection. For proper riscv64 target support, the build process
must prepare both elf32lriscv* and elf64lriscv* linker scripts. These should
align with the standard RISC-V Linux sysroot directory structure.
Signed-off-by: Mark Goncharov <mark.goncharov@syntacore.com>
# On Linux, first look for 32 bit ILP32D target libraries in /lib/ilp32d as per
# the glibc ABI.
case "$target" in
- riscv32*-linux*)
+ riscv*-linux*)
case "$EMULATION_NAME" in
*32*)
LIBPATH_SUFFIX="32/ilp32d 32" ;;
# On Linux, first look for 32 bit ILP32 target libraries in /lib/ilp32 as per
# the glibc ABI.
case "$target" in
- riscv32*-linux*)
+ riscv*-linux*)
case "$EMULATION_NAME" in
*32*)
LIBPATH_SUFFIX="32/ilp32 32" ;;
# On Linux, first look for 32 bit ILP32F target libraries in /lib/ilp32f as per
# the glibc ABI.
case "$target" in
- riscv32*-linux*)
+ riscv*-linux*)
case "$EMULATION_NAME" in
*32*)
LIBPATH_SUFFIX="32/ilp32f 32" ;;
# On Linux, first look for 64 bit LP64D target libraries in /lib64/lp64d as per
# the glibc ABI, and then /lib64 for backward compatility.
case "$target" in
- riscv64*-linux*)
+ riscv*-linux*)
case "$EMULATION_NAME" in
*64*)
LIBPATH_SUFFIX="64/lp64d 64";;
# On Linux, first look for 64 bit LP64 target libraries in /lib64/lp64 as per
# the glibc ABI, and then /lib64 for backward compatility.
case "$target" in
- riscv64*-linux*)
+ riscv*-linux*)
case "$EMULATION_NAME" in
*64*)
LIBPATH_SUFFIX="64/lp64 64";;
# On Linux, first look for 64 bit LP64F target libraries in /lib64/lp64f as per
# the glibc ABI, and then /lib64 for backward compatility.
case "$target" in
- riscv64*-linux*)
+ riscv*-linux*)
case "$EMULATION_NAME" in
*64*)
LIBPATH_SUFFIX="64/lp64f 64";;