From 25ff968a90b53365a3526d2a0d1f32974afd9c31 Mon Sep 17 00:00:00 2001 From: jhb Date: Wed, 8 Jan 2020 17:49:34 +0000 Subject: [PATCH] Add -mno-relax to CFLAGS in bsd.prog/lib.mk instead of bsd.cpu.mk. bsd.cpu.mk is included by bsd.init.mk before bsd.linker.mk, so it was always setting the flag since LINKER_FEATURES wasn't defined. Reported by: mhorne Reviewed by: imp, mhorne Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D23076 --- share/mk/bsd.cpu.mk | 4 ---- share/mk/bsd.lib.mk | 4 ++++ share/mk/bsd.prog.mk | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/share/mk/bsd.cpu.mk b/share/mk/bsd.cpu.mk index 31eb9e3510de..dd57ef071341 100644 --- a/share/mk/bsd.cpu.mk +++ b/share/mk/bsd.cpu.mk @@ -375,10 +375,6 @@ CFLAGS += -march=rv64imac -mabi=lp64 .else CFLAGS += -march=rv64imafdc -mabi=lp64d .endif - -.if ${LINKER_FEATURES:U:Mriscv-relaxations} == "" -CFLAGS += -mno-relax -.endif .endif # NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk index 67788697229c..4464f44a1c10 100644 --- a/share/mk/bsd.lib.mk +++ b/share/mk/bsd.lib.mk @@ -98,6 +98,10 @@ STATIC_CFLAGS+= -ftls-model=initial-exec STATIC_CXXFLAGS+= -ftls-model=initial-exec .endif +.if ${MACHINE_CPUARCH} == "riscv" && ${LINKER_FEATURES:Mriscv-relaxations} == "" +CFLAGS += -mno-relax +.endif + .include # prefer .s to a .c, add .po, remove stuff not used in the BSD libraries diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk index f0368ec5d2b8..7854a1b01820 100644 --- a/share/mk/bsd.prog.mk +++ b/share/mk/bsd.prog.mk @@ -57,6 +57,10 @@ LDFLAGS+= -Wl,-zretpolineplt .endif .endif +.if ${MACHINE_CPUARCH} == "riscv" && ${LINKER_FEATURES:Mriscv-relaxations} == "" +CFLAGS += -mno-relax +.endif + .if defined(CRUNCH_CFLAGS) CFLAGS+=${CRUNCH_CFLAGS} .else