0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-01 17:48:56 +02:00

configure: Preliminaries for swappable ld.gold and ld.lld.

This commit is contained in:
Jason Volk 2022-06-13 18:27:38 -07:00
parent 471dc16275
commit 858fb6c33a
2 changed files with 37 additions and 14 deletions

View file

@ -21,6 +21,8 @@ AC_PATH_PROG(RM, rm)
AC_PATH_PROG(CP, cp) AC_PATH_PROG(CP, cp)
AC_PATH_PROG(MV, mv) AC_PATH_PROG(MV, mv)
AC_PATH_PROG(LN, ln) AC_PATH_PROG(LN, ln)
AC_PATH_PROG(LDGOLD, ld.gold)
AC_PATH_PROG(LDLLD, ld.lld)
AC_PATH_PROG(LD, ld.gold) AC_PATH_PROG(LD, ld.gold)
AC_PATH_PROG(XXD, xxd) AC_PATH_PROG(XXD, xxd)
AC_PATH_PROG(TOUCH, touch) AC_PATH_PROG(TOUCH, touch)
@ -973,20 +975,39 @@ RB_VAR_PREPEND([CPPFLAGS], ["$CWARNS"])
dnl mirror the base CFLAGS and CXXFLAGS up to this point dnl mirror the base CFLAGS and CXXFLAGS up to this point
CFLAGS="$CXXFLAGS" CFLAGS="$CXXFLAGS"
dnl ***************************************************************************
dnl dnl
dnl Gold linker dnl Linker flags
dnl dnl
dnl Sorry there is no way to disable gold right now. You can try the AM_COND_IF([CLANG],
dnl binutils-gold package if your binutils package doesn't ship with it [
dnl by default these days. Not sure if this is a problem with musl; please AM_CONDITIONAL([LLD], [test "" != ""])
dnl report any issues so we can weigh the need to change course here. dnl AM_CONDITIONAL([LLD], [test "$LDLLD" != ""])
dnl AM_CONDITIONAL([GOLD], [test "$LDGOLD" != ""])
ld_gold="yes" ], [
AM_CONDITIONAL([LLD], [test "" != ""])
AM_CONDITIONAL([GOLD], [test "$LDGOLD" != ""])
])
AM_CONDITIONAL([LD_GOLD], [[[[ $ld_gold = "yes" ]]]]) AM_COND_IF_NAND([LLD], [GOLD],
[
AC_MSG_ERROR([Sorry, ld.gold required at this time.])
])
AM_COND_IF([LD_GOLD], AM_COND_IF([LLD],
[
AC_SUBST(LD, "$LDLLD")
])
AM_COND_IF([LLD],
[
RB_VAR_PREPEND([LDFLAGS], ["-fuse-ld=lld"])
RB_VAR_PREPEND([LDFLAGS], ["-Wc,-fuse-ld=lld"])
])
AM_COND_IF([GOLD],
[ [
AM_COND_IF([GCC], AM_COND_IF([GCC],
[ [
@ -1008,8 +1029,6 @@ dnl RB_VAR_PREPEND([LDFLAGS], ["-Wl,--icf=all"])
RB_VAR_PREPEND([LDFLAGS], ["-Wl,-z,noexecstack"]) RB_VAR_PREPEND([LDFLAGS], ["-Wl,-z,noexecstack"])
RB_VAR_PREPEND([LDFLAGS], ["-Wl,-z,combreloc"]) RB_VAR_PREPEND([LDFLAGS], ["-Wl,-z,combreloc"])
RB_VAR_PREPEND([LDFLAGS], ["-Wl,-z,text-unlikely-segment"]) RB_VAR_PREPEND([LDFLAGS], ["-Wl,-z,text-unlikely-segment"])
], [
AC_MSG_ERROR([Sorry, disabling the gold linker is not supported at this time.])
]) ])
dnl Note compact mode options available in both GOLD and LLD dnl Note compact mode options available in both GOLD and LLD
@ -1019,6 +1038,7 @@ AM_COND_IF([COMPACT],
RB_VAR_PREPEND([LDFLAGS], ["-Wl,--gc-sections"]) RB_VAR_PREPEND([LDFLAGS], ["-Wl,--gc-sections"])
]) ])
dnl *************************************************************************** dnl ***************************************************************************
dnl dnl
dnl Philology checks dnl Philology checks

View file

@ -25,10 +25,7 @@ AM_LDFLAGS = \
-version-info 3:2:0 \ -version-info 3:2:0 \
-Wl,--no-undefined-version \ -Wl,--no-undefined-version \
-Wl,--icf=all \ -Wl,--icf=all \
-Wl,--no-text-reorder \
-Wl,--sort-section=name \ -Wl,--sort-section=name \
-Wl,--sort-common=descending \
-Wl,--weak-unresolved-symbols \
-Wl,--unresolved-symbols=ignore-in-shared-libs \ -Wl,--unresolved-symbols=ignore-in-shared-libs \
-Wl,--wrap=pthread_create \ -Wl,--wrap=pthread_create \
-Wl,--wrap=pthread_join \ -Wl,--wrap=pthread_join \
@ -79,6 +76,12 @@ AM_LDFLAGS += -Wl,-fprofile-generate
endif endif
endif endif
if GOLD
AM_LDFLAGS += -Wl,--no-text-reorder
AM_LDFLAGS += -Wl,--weak-unresolved-symbols
AM_LDFLAGS += -Wl,--sort-common=descending
endif
if MINGW if MINGW
AM_LDFLAGS += -Wl,--enable-runtime-pseudo-reloc AM_LDFLAGS += -Wl,--enable-runtime-pseudo-reloc
AM_LDFLAGS += -export-symbols-regex '*' AM_LDFLAGS += -export-symbols-regex '*'