summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaximilian Brune <maximilian.brune@9elements.com>2024-01-18 18:15:17 +0600
committerLean Sheng Tan <sheng.tan@9elements.com>2024-02-18 07:53:09 +0000
commit732134932b7b01262fbcb3e08328ec09af1f90e8 (patch)
treee4fd864f81ac6662b88b4de0938022ab0faa214b
parent8bbc07ef232c329d811ae920953a9858c5b1821e (diff)
util/crossgcc/buildgcc: Compile RISC-V GCC with medany
currently the HiFive Unmatched mainboard produces the following error: ``` util/crossgcc/xgcc/lib/gcc/riscv64-elf/13.2.0/rv64imafdc/lp64d/libgcc.a (_clzsi2.o): in function `__clzdi2': util/crossgcc/gcc-13.2.0/libgcc/libgcc2.c:690:(.text+0x1e): relocation truncated to fit: R_RISCV_HI20 against symbol `__clz_tab' defined in .rodata section in util/crossgcc/xgcc/lib/gcc/riscv64-elf/13.2.0/ rv64imafdc/lp64d/libgcc.a(_clz.o) ``` This is due to the fact that the libgcc.a library is compiled with the medlow code model but the mainboards are compiled with the medany code model. Changing the code model of the GCC libraries to the medany code model fixes the issue. Signed-off-by: Maximilian Brune <maximilian.brune@9elements.com> Change-Id: If5f07ce034686dd7fec160ea76838507c0ba7fa0 Reviewed-on: https://review.coreboot.org/c/coreboot/+/80139 Reviewed-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-by: ron minnich <rminnich@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
-rwxr-xr-xutil/crossgcc/buildgcc7
1 files changed, 6 insertions, 1 deletions
diff --git a/util/crossgcc/buildgcc b/util/crossgcc/buildgcc
index 29193769f5..26b4b05b15 100755
--- a/util/crossgcc/buildgcc
+++ b/util/crossgcc/buildgcc
@@ -774,6 +774,11 @@ build_cross_GCC() {
[ -n "$CXX" ] && $CXX --version | grep clang >/dev/null 2>&1 && \
CLANGCXXFLAGS="-fbracket-depth=1024"
+ # standard code model is medlow but all mainboards are compiled with medany code model
+ if [ "${TARGETARCH}" = "riscv64-elf" ]; then
+ CFLAGS_FOR_TARGET_EXTRA="-mcmodel=medany"
+ fi
+
# GCC does not honor HOSTCFLAGS at all. CFLAGS are used for
# both target and host object files.
# There's a work-around called CFLAGS_FOR_BUILD and CFLAGS_FOR_TARGET
@@ -783,7 +788,7 @@ build_cross_GCC() {
# using C++.
# shellcheck disable=SC2086
CC="$(hostcc target)" CXX="$(hostcxx target)" \
- CFLAGS_FOR_TARGET="-O2 -Dinhibit_libc" \
+ CFLAGS_FOR_TARGET="${CFLAGS_FOR_TARGET_EXTRA} -O2 -Dinhibit_libc" \
CFLAGS="$HOSTCFLAGS $CLANGFLAGS" \
CFLAGS_FOR_BUILD="$HOSTCFLAGS $CLANGFLAGS" \
CXXFLAGS="$HOSTCFLAGS $CLANGCXXFLAGS" \