<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;" dir="ltr">
<p>Ping<br>
</p>
<ul style="font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
<li>jimw@sifive.com</li><li>amodra@gmail.com<br>
<br>
</li></ul>
<p></p>
<div style="color: rgb(0, 0, 0);">
<div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Mark Goncharov<br>
<b>Sent:</b> 01 July 2025 08:57<br>
<b>To:</b> binutils@sourceware.org<br>
<b>Cc:</b> Mark Goncharov<br>
<b>Subject:</b> [PATCH] ldscript: riscv: Fix libpath_suffix selection</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">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.<br>
The specified -march value populates the EMULATION_NAME variable, which determines the default linker script selection.<br>
For proper riscv64 target support, the build process must prepare both elf32lriscv* and elf64lriscv* linker scripts.<br>
These should align with the standard RISC-V Linux sysroot directory structure.<br>
<br>
Signed-off-by: Mark Goncharov <mark.goncharov@syntacore.com><br>
---<br>
ld/emulparams/elf32lriscv.sh | 2 +-<br>
ld/emulparams/elf32lriscv_ilp32.sh | 2 +-<br>
ld/emulparams/elf32lriscv_ilp32f.sh | 2 +-<br>
ld/emulparams/elf64lriscv.sh | 2 +-<br>
ld/emulparams/elf64lriscv_lp64.sh | 2 +-<br>
ld/emulparams/elf64lriscv_lp64f.sh | 2 +-<br>
6 files changed, 6 insertions(+), 6 deletions(-)<br>
<br>
diff --git a/ld/emulparams/elf32lriscv.sh b/ld/emulparams/elf32lriscv.sh<br>
index da0d7cf54f4..42460131e6e 100644<br>
--- a/ld/emulparams/elf32lriscv.sh<br>
+++ b/ld/emulparams/elf32lriscv.sh<br>
@@ -6,7 +6,7 @@ OUTPUT_FORMAT="elf32-littleriscv"<br>
# On Linux, first look for 32 bit ILP32D target libraries in /lib/ilp32d as per<br>
# the glibc ABI.<br>
case "$target" in<br>
- riscv32*-linux*)<br>
+ riscv*-linux*)<br>
case "$EMULATION_NAME" in<br>
*32*)<br>
LIBPATH_SUFFIX="32/ilp32d 32" ;;<br>
diff --git a/ld/emulparams/elf32lriscv_ilp32.sh b/ld/emulparams/elf32lriscv_ilp32.sh<br>
index 4935937ef6a..c773985f093 100644<br>
--- a/ld/emulparams/elf32lriscv_ilp32.sh<br>
+++ b/ld/emulparams/elf32lriscv_ilp32.sh<br>
@@ -5,7 +5,7 @@ OUTPUT_FORMAT="elf32-littleriscv"<br>
# On Linux, first look for 32 bit ILP32 target libraries in /lib/ilp32 as per<br>
# the glibc ABI.<br>
case "$target" in<br>
- riscv32*-linux*)<br>
+ riscv*-linux*)<br>
case "$EMULATION_NAME" in<br>
*32*)<br>
LIBPATH_SUFFIX="32/ilp32 32" ;;<br>
diff --git a/ld/emulparams/elf32lriscv_ilp32f.sh b/ld/emulparams/elf32lriscv_ilp32f.sh<br>
index c684bf85ee5..a2f0c2a6c38 100644<br>
--- a/ld/emulparams/elf32lriscv_ilp32f.sh<br>
+++ b/ld/emulparams/elf32lriscv_ilp32f.sh<br>
@@ -5,7 +5,7 @@ OUTPUT_FORMAT="elf32-littleriscv"<br>
# On Linux, first look for 32 bit ILP32F target libraries in /lib/ilp32f as per<br>
# the glibc ABI.<br>
case "$target" in<br>
- riscv32*-linux*)<br>
+ riscv*-linux*)<br>
case "$EMULATION_NAME" in<br>
*32*)<br>
LIBPATH_SUFFIX="32/ilp32f 32" ;;<br>
diff --git a/ld/emulparams/elf64lriscv.sh b/ld/emulparams/elf64lriscv.sh<br>
index e07a0648735..7958052d3b7 100644<br>
--- a/ld/emulparams/elf64lriscv.sh<br>
+++ b/ld/emulparams/elf64lriscv.sh<br>
@@ -6,7 +6,7 @@ OUTPUT_FORMAT="elf64-littleriscv"<br>
# On Linux, first look for 64 bit LP64D target libraries in /lib64/lp64d as per<br>
# the glibc ABI, and then /lib64 for backward compatility.<br>
case "$target" in<br>
- riscv64*-linux*)<br>
+ riscv*-linux*)<br>
case "$EMULATION_NAME" in<br>
*64*)<br>
LIBPATH_SUFFIX="64/lp64d 64";;<br>
diff --git a/ld/emulparams/elf64lriscv_lp64.sh b/ld/emulparams/elf64lriscv_lp64.sh<br>
index b1bb252c1ee..7c7feca2e3e 100644<br>
--- a/ld/emulparams/elf64lriscv_lp64.sh<br>
+++ b/ld/emulparams/elf64lriscv_lp64.sh<br>
@@ -5,7 +5,7 @@ OUTPUT_FORMAT="elf64-littleriscv"<br>
# On Linux, first look for 64 bit LP64 target libraries in /lib64/lp64 as per<br>
# the glibc ABI, and then /lib64 for backward compatility.<br>
case "$target" in<br>
- riscv64*-linux*)<br>
+ riscv*-linux*)<br>
case "$EMULATION_NAME" in<br>
*64*)<br>
LIBPATH_SUFFIX="64/lp64 64";;<br>
diff --git a/ld/emulparams/elf64lriscv_lp64f.sh b/ld/emulparams/elf64lriscv_lp64f.sh<br>
index 005f191c5bf..e036c2f0f2c 100644<br>
--- a/ld/emulparams/elf64lriscv_lp64f.sh<br>
+++ b/ld/emulparams/elf64lriscv_lp64f.sh<br>
@@ -5,7 +5,7 @@ OUTPUT_FORMAT="elf64-littleriscv"<br>
# On Linux, first look for 64 bit LP64F target libraries in /lib64/lp64f as per<br>
# the glibc ABI, and then /lib64 for backward compatility.<br>
case "$target" in<br>
- riscv64*-linux*)<br>
+ riscv*-linux*)<br>
case "$EMULATION_NAME" in<br>
*64*)<br>
LIBPATH_SUFFIX="64/lp64f 64";;<br>
-- <br>
2.43.0<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>