Skip to content

Commit

Permalink
build: use -Wl,--gc-sections when appropriate
Browse files Browse the repository at this point in the history
Problem: libflux-optparse.so has unresolved jansson symbols on focal.

A recent macos portability change dropped the linker option to
garbage collect unused sections, resulting in unresolved json_*
symbols in libflux-optparse.so from libmissing.la on focal.

The change, introduced in #6476, was supposed
to set a make variable $ld_gc_sections when that option is available,
but the change was incomplete and the variable was never set.

Add the missing configure logic.

Confirmed:
- json_ symbols are no longer unresolved in libflux-optparse.so on focal
- macos still builds, and json_ symbols do not appear there

Fixes #6496
  • Loading branch information
garlick committed Dec 10, 2024
1 parent 7cd6705 commit ff1a93f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,20 @@ AC_PATH_PROGS(SSH, [rsh ssh], [/usr/bin/rsh])
AC_DEFINE_UNQUOTED([PATH_SSH], "$SSH",
[Define remote shell program to be used by the ssh:// connector])

# macos linker doesn't support --gc-sections
saved_LDFLAGS="$LDFLAGS"
LDFLAGS="-Wl,--gc-sections $LDFLAGS"
AC_MSG_CHECKING([whether ld supports --gc-sections])
AC_LINK_IFELSE([AC_LANG_PROGRAM([])], [
AC_MSG_RESULT([yes])
ld_gc_sections="-Wl,--gc-sections"
AS_VAR_SET(ld_gc_sections, $ld_gc_sections)
AC_SUBST(ld_gc_sections)
],[
AC_MSG_RESULT([no])
])
LDFLAGS=$saved_LDFLAGS

LT_INIT
AC_PROG_AWK

Expand Down

0 comments on commit ff1a93f

Please sign in to comment.