Re-add ALLOW_MIPS_SHARED_TEXTREL, sprinkle it around

Diff partially stolen from CheriBSD; these bits need -Wl,-z,notext in order
to build in an LLVM world. They are needed for all flavors/sizes of MIPS.
This will eventually get fixed in LLVM, but it's unclear when.

Reported by:	arichardson, emaste
Differential Revision:	https://reviews.freebsd.org/D21696
This commit is contained in:
Kyle Evans 2019-10-06 04:19:49 +00:00
parent 29a5f63951
commit 036d2e814b
6 changed files with 22 additions and 0 deletions

View File

@ -5,6 +5,8 @@ SHLIB= h_csu
SHLIB_NAME= libh_csu.so
SHLIB_MAJOR= 1
ALLOW_MIPS_SHARED_TEXTREL=
WITHOUT_STATIC=
WITHOUT_PROFILE=
WITHOUT_PIC=

View File

@ -11,6 +11,8 @@ CXXINCLUDEDIR= ${INCLUDEDIR}/c++/v${SHLIB_MAJOR}
STATIC_CXXFLAGS+= -mlong-calls
.endif
ALLOW_MIPS_SHARED_TEXTREL=
.PATH: ${SRCDIR}
LIB= c++

View File

@ -5,6 +5,7 @@ SRCDIR= ${SRCTOP}/contrib/libcxxrt
SHLIB_MAJOR= 1
SHLIBDIR?= /lib
ALLOW_MIPS_SHARED_TEXTREL=
.PATH: ${SRCDIR}

View File

@ -6,6 +6,8 @@ UNWINDSRCDIR= ${SRCTOP}/contrib/libunwind/src
STATIC_CFLAGS+=${PICFLAG} -fvisibility=hidden -DVISIBILITY_HIDDEN
ALLOW_MIPS_SHARED_TEXTREL=
.PATH: ${COMPILERRTDIR}/lib/builtins
.PATH: ${UNWINDSRCDIR}
SRCS_EXC+= gcc_personality_v0.c

View File

@ -5,6 +5,8 @@ LIB= pmc
SRCS= libpmc.c pmclog.c libpmc_pmu_util.c libpmc_json.cc
INCS= pmc.h pmclog.h pmcformat.h
ALLOW_MIPS_SHARED_TEXTREL=
.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386"
.if ${MACHINE_ARCH} == "aarch64"

View File

@ -287,6 +287,10 @@ CLEANFILES+= ${SOBJS}
.if defined(SHLIB_NAME)
_LIBS+= ${SHLIB_NAME}
.if ${CFLAGS:M-fexceptions} || defined(SHLIB_CXX) || defined(LIB_CXX)
ALLOW_MIPS_SHARED_TEXTREL=
.endif
SOLINKOPTS+= -shared -Wl,-x
.if defined(LD_FATAL_WARNINGS) && ${LD_FATAL_WARNINGS} == "no"
SOLINKOPTS+= -Wl,--no-fatal-warnings
@ -295,6 +299,15 @@ SOLINKOPTS+= -Wl,--fatal-warnings
.endif
SOLINKOPTS+= -Wl,--warn-shared-textrel
.if defined(ALLOW_MIPS_SHARED_TEXTREL) && ${MACHINE_CPUARCH:Mmips}
# Check if we should be defining ALLOW_SHARED_TEXTREL... basically, C++
# or -fexceptions in CFLAGS on MIPS. This works around clang/lld attempting
# to generate text relocations in read-only .eh_frame. A future version of
# clang/lld should instead transform them into relative references at link
# time, and then we can stop doing this.
SOLINKOPTS+= -Wl,-z,notext
.endif
.if target(beforelinking)
beforelinking: ${SOBJS}
${SHLIB_NAME_FULL}: beforelinking