Skip to content

Commit 629c67e

Browse files
Prevent musl riscv32 builds
The upstream musl libc does not support 32bit RISC-V builds. We therefore only allow building the 64bit version (i.e., riscv64-unknown-linux-musl-). Signed-off-by: Florian Hofhammer <florian.hofhammer@fhofhammer.de>
1 parent 6b07a6b commit 629c67e

File tree

6 files changed

+28
-7
lines changed

6 files changed

+28
-7
lines changed

.github/workflows/build.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ jobs:
1616
os: [ubuntu-18.04, ubuntu-20.04]
1717
mode: [newlib, linux, musl]
1818
target: [rv32gc-ilp32d, rv64gc-lp64d]
19+
exclude:
20+
- mode: musl
21+
target: rv32gc-ilp32d
1922
steps:
2023
- uses: actions/checkout@v2
2124

.github/workflows/nightly-release.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ jobs:
5151
os: [ubuntu-18.04, ubuntu-20.04]
5252
mode: [newlib, linux, musl]
5353
target: [rv32gc-ilp32d, rv64gc-lp64d]
54+
exclude:
55+
- mode: musl
56+
target: rv32gc-ilp32d
5457
steps:
5558
- uses: actions/checkout@v2
5659

Makefile.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,13 @@ CONFIGURE_HOST = @configure_host@
102102
all: @default_target@
103103
newlib: stamps/build-gcc-newlib-stage2
104104
linux: stamps/build-gcc-linux-stage2
105+
ifneq (,$(findstring riscv32,$(MUSL_TUPLE)))
106+
.PHONY: musl
107+
musl:
108+
@echo "musl only supports 64bit builds." && exit 1
109+
else
105110
musl: stamps/build-gcc-musl-stage2
111+
endif
106112
ifeq (@enable_gdb@,--enable-gdb)
107113
newlib: stamps/build-gdb-newlib
108114
linux: stamps/build-gdb-linux

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,16 @@ To build either cross-compiler with support for both 32-bit and
9494
And then either `make`, `make linux` or `make musl` for the Newlib, Linux
9595
glibc-based or Linux musl libc-based cross-compiler, respectively.
9696

97-
The multilib compiler will have the prefix riscv64-unknown-elf-,
98-
riscv64-unknown-linux-gnu- or riscv64-unknown-linux-musl-
99-
but will be able to target both 32-bit and 64-bit systems. It will support
100-
the most common `-march`/`-mabi` options, which can be seen by using the
101-
`--print-multi-lib` flag on either cross-compiler.
97+
The multilib compiler will have the prefix riscv64-unknown-elf- or
98+
riscv64-unknown-linux-gnu- but will be able to target both 32-bit and 64-bit
99+
systems.
100+
It will support the most common `-march`/`-mabi` options, which can be seen by
101+
using the `--print-multi-lib` flag on either cross-compiler.
102+
103+
The musl compiler (riscv64-unknown-linux-musl-) will only be able to target
104+
64-bit systems due to limitations in the upstream musl architecture support.
105+
The `--enable-multilib` flag therefore does not actually enable multilib support
106+
for musl libc.
102107

103108
### Troubleshooting Build Problems
104109

configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,7 @@ Optional Features:
13201320
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
13211321
--enable-linux set linux as the default make target
13221322
[--disable-linux]
1323-
--enable-multilib build both RV32 and RV64 runtime libraries
1323+
--enable-multilib build both RV32 and RV64 runtime libraries (only RV64 for musl libc)
13241324
[--disable-multilib]
13251325
--enable-gcc-checking Enable gcc internal checking, it will make gcc very
13261326
slow, only enable it when developing gcc

configure.ac

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ AC_SUBST(WITH_TUNE, --with-tune=$with_tune)
8989

9090
AC_ARG_ENABLE(multilib,
9191
[AS_HELP_STRING([--enable-multilib],
92-
[build both RV32 and RV64 runtime libraries @<:@--disable-multilib@:>@])],
92+
[build both RV32 and RV64 runtime libraries (only RV64 for musl libc) @<:@--disable-multilib@:>@])],
9393
[],
9494
[enable_multilib=no]
9595
)
@@ -118,6 +118,10 @@ AS_IF([test "x$enable_multilib" != xno],
118118
[AC_SUBST(newlib_multilib_names,"rv32i-ilp32 rv32iac-ilp32 rv32im-ilp32 rv32imac-ilp32 rv32imafc-ilp32f rv64imac-lp64 rv64imafdc-lp64d")],
119119
[AC_SUBST(newlib_multilib_names,"$with_arch-$with_abi")])
120120

121+
AS_IF([test "x$enable_multilib" != xno],
122+
[AC_SUBST(musl_multilib_names,"rv64imac-lp64 rv64imafdc-lp64d")],
123+
[AC_SUBST(musl_multilib_names,"$with_arch-$with_abi")])
124+
121125
AC_ARG_ENABLE(gcc-checking,
122126
[AS_HELP_STRING([--enable-gcc-checking],
123127
[Enable gcc internal checking, it will make gcc very slow, only enable it when developing gcc @<:@--disable-gcc-checking@:>@])],

0 commit comments

Comments
 (0)