Add a new "riscv-relaxations" linker feature.

When the linker doesn't have this feature, add -mno-relax to CFLAGS
on RISC-V.

Define the feature for ld.bfd, but not lld.  If lld gains relaxation
support in a newer version, we can enable it for those versions of lld
in bsd.linker.mk.

Reviewed by:	mhorne
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D22659
This commit is contained in:
John Baldwin 2019-12-05 19:37:30 +00:00
parent 1bef4955bc
commit 0869dceb9d
3 changed files with 11 additions and 0 deletions

View File

@ -375,6 +375,10 @@ 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

View File

@ -86,6 +86,9 @@ ${X_}LINKER_FEATURES=
${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

View File

@ -144,6 +144,10 @@ CFLAGS+= -march=rv64imafdc -mabi=lp64
CFLAGS.clang+= -mcmodel=medium
CFLAGS.gcc+= -mcmodel=medany
INLINE_LIMIT?= 8000
.if ${LINKER_FEATURES:Mriscv-relaxations} == ""
CFLAGS+= -mno-relax
.endif
.endif
#