Преглед изворни кода

build: Fix the __progname check to avoid the optimizer discarding the symbol

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.
Guillem Jover пре 10 година
родитељ
комит
758ecf7fe1
2 измењених фајлова са 3 додато и 3 уклоњено
  1. 1 0
      debian/changelog
  2. 2 3
      m4/dpkg-funcs.m4

+ 1 - 0
debian/changelog

@@ -4,6 +4,7 @@ dpkg (1.18.11) UNRELEASED; urgency=medium
   * Build system:
   * Build system:
     - Add support for profiling perl modules.
     - Add support for profiling perl modules.
     - Clean up compiler and linker automatic flag usage in configure.
     - Clean up compiler and linker automatic flag usage in configure.
+    - Fix the __progname check to avoid the optimizer discarding the symbol.
 
 
   [ Updated manpages translations ]
   [ Updated manpages translations ]
   * German (Helge Kreutzmann).
   * German (Helge Kreutzmann).

+ 2 - 3
m4/dpkg-funcs.m4

@@ -111,9 +111,8 @@ AC_DEFUN([DPKG_CHECK_PROGNAME],
                  [AC_MSG_RESULT([no])])
                  [AC_MSG_RESULT([no])])
 
 
   AC_MSG_CHECKING([for __progname])
   AC_MSG_CHECKING([for __progname])
-  AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
-                 [[extern char *__progname;
-                   const char *p = __progname;]])],
+  AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern char *__progname;]],
+                 [[printf("%s", __progname);]])],
                  [AC_DEFINE([HAVE___PROGNAME], [1],
                  [AC_DEFINE([HAVE___PROGNAME], [1],
                             [Define to 1 if you have __progname])
                             [Define to 1 if you have __progname])
                   AC_MSG_RESULT([yes])],
                   AC_MSG_RESULT([yes])],