Fix cross-builds from macOS

The macOS linker does not support -zrelro/-znorelro.  Since it is only
used to for build tools that run on the host, and WITH_RELRO or
WITHOUT_RELRO does not matter there, just skip the option.

Reviewed by:	markj
Fixes:		2f3a961487 ("Add RELRO build knob, default to enabled")
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35589
This commit is contained in:
Ed Maste 2022-06-26 13:23:39 -04:00
parent 1e824ee84f
commit 7927452ac4
2 changed files with 4 additions and 0 deletions

View File

@ -79,11 +79,13 @@ TAG_ARGS= -T ${TAGS:[*]:S/ /,/g}
.if ${MK_BIND_NOW} != "no"
LDFLAGS+= -Wl,-znow
.endif
.if ${LINKER_TYPE} != "macos"
.if ${MK_RELRO} == "no"
LDFLAGS+= -Wl,-znorelro
.else
LDFLAGS+= -Wl,-zrelro
.endif
.endif
.if ${MK_RETPOLINE} != "no"
.if ${COMPILER_FEATURES:Mretpoline} && ${LINKER_FEATURES:Mretpoline}
CFLAGS+= -mretpoline

View File

@ -41,11 +41,13 @@ MK_DEBUG_FILES= no
.if ${MK_BIND_NOW} != "no"
LDFLAGS+= -Wl,-znow
.endif
.if ${LINKER_TYPE} != "macos"
.if ${MK_RELRO} == "no"
LDFLAGS+= -Wl,-znorelro
.else
LDFLAGS+= -Wl,-zrelro
.endif
.endif
.if ${MK_PIE} != "no"
# Static PIE is not yet supported/tested.
.if !defined(NO_SHARED) || ${NO_SHARED:tl} == "no"