diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk index 70ba98bb361b..499eeeee9a0e 100644 --- a/share/mk/bsd.lib.mk +++ b/share/mk/bsd.lib.mk @@ -92,6 +92,12 @@ CXXFLAGS+= ${DEBUG_FILES_CFLAGS} CTFFLAGS+= -g .endif +# clang currently defaults to dynamic TLS for mips64 object files without -fPIC +.if ${MACHINE_ARCH:Mmips64*} && ${COMPILER_TYPE} == "clang" +STATIC_CFLAGS+= -ftls-model=initial-exec +STATIC_CXXFLAGS+= -ftls-model=initial-exec +.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 d2631452bedc..f0368ec5d2b8 100644 --- a/share/mk/bsd.prog.mk +++ b/share/mk/bsd.prog.mk @@ -82,6 +82,11 @@ TAG_ARGS= -T ${TAGS:[*]:S/ /,/g} LDFLAGS+= -static .endif +# clang currently defaults to dynamic TLS for mips64 binaries +.if ${MACHINE_ARCH:Mmips64*} && ${COMPILER_TYPE} == "clang" +CFLAGS+= -ftls-model=initial-exec +.endif + .if ${MK_DEBUG_FILES} != "no" PROG_FULL=${PROG}.full # Use ${DEBUGDIR} for base system debug files, else .debug subdirectory