Index: head/share/mk/bsd.cpu.mk =================================================================== --- head/share/mk/bsd.cpu.mk +++ head/share/mk/bsd.cpu.mk @@ -375,6 +375,10 @@ .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 Index: head/share/mk/bsd.linker.mk =================================================================== --- head/share/mk/bsd.linker.mk +++ head/share/mk/bsd.linker.mk @@ -86,6 +86,9 @@ ${X_}LINKER_FEATURES+= build-id ${X_}LINKER_FEATURES+= ifunc .endif +.if ${${X_}LINKER_TYPE} == "bfd" && ${${X_}LINKER_VERSION} > 21750 +${X_}LINKER_FEATURES+= riscv-relaxations +.endif .if ${${X_}LINKER_TYPE} == "lld" && ${${X_}LINKER_VERSION} >= 60000 ${X_}LINKER_FEATURES+= retpoline .endif Index: head/sys/conf/kern.mk =================================================================== --- head/sys/conf/kern.mk +++ head/sys/conf/kern.mk @@ -144,6 +144,10 @@ CFLAGS.clang+= -mcmodel=medium CFLAGS.gcc+= -mcmodel=medany INLINE_LIMIT?= 8000 + +.if ${LINKER_FEATURES:Mriscv-relaxations} == "" +CFLAGS+= -mno-relax +.endif .endif #