]> git.ipfire.org Git - thirdparty/libbsd.git/commitdiff
Fix the __progname check to avoid the optimizer discarding the symbol
authorGuillem Jover <guillem@hadrons.org>
Sun, 28 Aug 2016 15:13:20 +0000 (17:13 +0200)
committerGuillem Jover <guillem@hadrons.org>
Mon, 5 Jun 2017 03:52:07 +0000 (05:52 +0200)
Because we were assigning to another unused variable, when building the
check with optimizations enabled, which is the default when using gcc
as the compiler, the variable was being discarded. Instead pass it to
printf() so that it cannot do so.

configure.ac

index 5a432d4b05ffe1fb3a53477aa4bd2788c6823588..5cbc2fad9a411ff567b9dae8936f3322f9522968 100644 (file)
@@ -131,9 +131,8 @@ AC_LINK_IFELSE(
 
 AC_MSG_CHECKING([for __progname])
 AC_LINK_IFELSE(
-       [AC_LANG_PROGRAM([[]],
-                        [[extern char *__progname;
-                          const char *p = __progname;]])],
+       [AC_LANG_PROGRAM([[extern char *__progname;]],
+                        [[printf("%s", __progname);]])],
        [AC_DEFINE([HAVE___PROGNAME], [1], [Define to 1 if you have __progname])
         AC_MSG_RESULT([yes])],
        [AC_MSG_RESULT([no])])