Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Mon, 13 Oct 2014 14:46:35 UTC Commit: 086fe3d11106edbc2261b8a8f634d2653a1ecf80 https://github.com/geany/geany-plugins/commit/086fe3d11106edbc2261b8a8f634d2...
Log Message: ----------- autotools: Don't allow undefined symbols in plugins when possible
Tell the linker not to allow undefined symbols in built plugins it possible.
This avoids use of non-plugin API functions from plugins as using those would lead to undefined symbols. This works even as we don't link to a "libgeany" or the like because Geany plugin API is hidden behind macros indirection.
Modified Paths: -------------- build/ldflags.m4 build/vars.build.mk configure.ac
Modified: build/ldflags.m4 40 lines changed, 40 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,40 @@ +dnl GP_CHECK_LDFLAG(FLAG, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) +dnl Checks whether the linker understands FLAG +AC_DEFUN([GP_CHECK_LDFLAG], +[ + gp_check_ldflag_LDFLAGS="$LDFLAGS" + LDFLAGS="$1" + AC_MSG_CHECKING([whether the linker understands $LDFLAGS]) + AC_LANG_PUSH(C) + AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) {return 0;}])], + [AC_MSG_RESULT([yes]) + $2], + [AC_MSG_RESULT([no]) + $3]) + AC_LANG_POP(C) + LDFLAGS="$gp_check_ldflag_LDFLAGS" +]) + +dnl GP_CHECK_LDFLAGS +dnl Checks for default Geany-Plugins LDFLAGS and defines GP_LDFLAGS +AC_DEFUN([GP_CHECK_LDFLAGS], +[ + AC_ARG_ENABLE([extra-ld-flags], + AS_HELP_STRING([--disable-extra-ld-flags], + [Disable extra linker flags]), + [enable_extra_ld_flags=$enableval], + [enable_extra_ld_flags=yes]) + + GP_LDFLAGS= + AS_IF([test "x$enable_extra_ld_flags" != xno], + [ + enable_extra_ld_flags=yes + for flag in -Wl,-z,defs # do not allow undefined symbols in object files + do + GP_CHECK_LDFLAG([$flag], [GP_LDFLAGS="${GP_LDFLAGS} $flag"]) + done + ]) + AC_SUBST([GP_LDFLAGS]) + GP_STATUS_BUILD_FEATURE_ADD([Extra linker options], + [$enable_extra_c_warnings]) +])
Modified: build/vars.build.mk 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -9,7 +9,7 @@ AM_CFLAGS = \ $(GEANY_CFLAGS) \ $(GP_CFLAGS)
-AM_LDFLAGS = -module -avoid-version +AM_LDFLAGS = -module -avoid-version $(GP_LDFLAGS)
COMMONLIBS = \ $(GEANY_LIBS) \
Modified: configure.ac 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -23,6 +23,7 @@ GP_CHECK_UNITTESTS(0.9.4) GP_CHECK_GTK_VERSION GP_CHECK_CPPCHECK GP_CHECK_CFLAGS +GP_CHECK_LDFLAGS
dnl plugin checks GP_CHECK_ADDONS
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).