Просмотр исходного кода

build: Clean up compiler and linker automatic flag usage

Detect if the flags work at configure time, instead of enabling them
unconditionally. Amend the description so that the above is clear. And
rename the options so that downstreams realize about the change.
Guillem Jover лет назад: 10
Родитель
Сommit
4f8bca211c
5 измененных файлов с 35 добавлено и 27 удалено
  1. 2 2
      README
  2. 2 2
      configure.ac
  3. 1 0
      debian/changelog
  4. 14 13
      m4/dpkg-compiler.m4
  5. 16 10
      m4/dpkg-linker.m4

+ 2 - 2
README

@@ -118,5 +118,5 @@ programs:
 And the following to disable modifications to the build flags:
 And the following to disable modifications to the build flags:
 
 
   --disable-compiler-warnings
   --disable-compiler-warnings
-  --disable-compiler-optimisations
-  --disable-linker-optimisations
+  --disable-compiler-optimizations
+  --disable-linker-optimizations

+ 2 - 2
configure.ac

@@ -132,8 +132,8 @@ DPKG_MMAP
 # Checks for the build machinery.
 # Checks for the build machinery.
 AC_DEFINE(LIBDPKG_VOLATILE_API, 1, [Acknowledge the volatility of the API.])
 AC_DEFINE(LIBDPKG_VOLATILE_API, 1, [Acknowledge the volatility of the API.])
 DPKG_COMPILER_WARNINGS
 DPKG_COMPILER_WARNINGS
-DPKG_COMPILER_OPTIMISATIONS
-DPKG_LINKER_OPTIMISATIONS
+DPKG_COMPILER_OPTIMIZATIONS
+DPKG_LINKER_OPTIMIZATIONS
 DPKG_ARCHITECTURE
 DPKG_ARCHITECTURE
 AC_DEFINE([PACKAGE_RELEASE], [PACKAGE_VERSION " (" ARCHITECTURE ")"],
 AC_DEFINE([PACKAGE_RELEASE], [PACKAGE_VERSION " (" ARCHITECTURE ")"],
           [Define the project release information, version and architecture])
           [Define the project release information, version and architecture])

+ 1 - 0
debian/changelog

@@ -3,6 +3,7 @@ dpkg (1.18.11) UNRELEASED; urgency=medium
   [ Guillem Jover ]
   [ Guillem Jover ]
   * 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.
 
 
   [ Updated manpages translations ]
   [ Updated manpages translations ]
   * German (Helge Kreutzmann).
   * German (Helge Kreutzmann).

+ 14 - 13
m4/dpkg-compiler.m4

@@ -1,5 +1,5 @@
 # Copyright © 2004 Scott James Remnant <scott@netsplit.com>
 # Copyright © 2004 Scott James Remnant <scott@netsplit.com>
-# Copyright © 2006,2009-2011,2013-2015 Guillem Jover <guillem@debian.org>
+# Copyright © 2006, 2009-2011, 2013-2016 Guillem Jover <guillem@debian.org>
 
 
 # DPKG_CHECK_COMPILER_FLAG
 # DPKG_CHECK_COMPILER_FLAG
 # ------------------------
 # ------------------------
@@ -84,7 +84,7 @@ AC_DEFUN([DPKG_CHECK_COMPILER_WARNINGS], [
 AC_DEFUN([DPKG_COMPILER_WARNINGS], [
 AC_DEFUN([DPKG_COMPILER_WARNINGS], [
   AC_ARG_ENABLE([compiler-warnings],
   AC_ARG_ENABLE([compiler-warnings],
     AS_HELP_STRING([--disable-compiler-warnings],
     AS_HELP_STRING([--disable-compiler-warnings],
-                   [Disable additional compiler warnings]),
+                   [Disable (detected) additional compiler warnings]),
     [],
     [],
     [enable_compiler_warnings=yes]
     [enable_compiler_warnings=yes]
   )
   )
@@ -100,17 +100,18 @@ AC_DEFUN([DPKG_COMPILER_WARNINGS], [
   fi
   fi
 ])
 ])
 
 
-# DPKG_COMPILER_OPTIMISATIONS
-# --------------------------
-# Add configure option to disable optimisations.
-AC_DEFUN([DPKG_COMPILER_OPTIMISATIONS],
-[AC_ARG_ENABLE(compiler-optimisations,
-	AS_HELP_STRING([--disable-compiler-optimisations],
-		       [Disable compiler optimisations]),
-	[],
-	[enable_compiler_optimisations=yes])
-
-  AS_IF([test "x$enable_compiler_optimisations" = "xno"], [
+# DPKG_COMPILER_OPTIMIZATIONS
+# ---------------------------
+# Add configure option to disable optimizations.
+AC_DEFUN([DPKG_COMPILER_OPTIMIZATIONS], [
+  AC_ARG_ENABLE(compiler-optimizations,
+    AS_HELP_STRING([--disable-compiler-optimizations],
+                   [Disable (detected) compiler optimizations]),
+    [],
+    [enable_compiler_optimizations=yes]
+  )
+
+  AS_IF([test "x$enable_compiler_optimizations" = "xno"], [
     CFLAGS=$(echo "$CFLAGS" | sed -e "s/ -O[[1-9]]*\b/ -O0/g")
     CFLAGS=$(echo "$CFLAGS" | sed -e "s/ -O[[1-9]]*\b/ -O0/g")
   ])
   ])
 ])
 ])

+ 16 - 10
m4/dpkg-linker.m4

@@ -1,20 +1,26 @@
 # Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
 # Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
-# Copyright © 2010, 2014 Guillem Jover <guillem@debian.org>
+# Copyright © 2010, 2014, 2016 Guillem Jover <guillem@debian.org>
 
 
-# DPKG_LINKER_OPTIMISATIONS
-# --------------------------
-# Add configure option to disable linker optimisations.
-AC_DEFUN([DPKG_LINKER_OPTIMISATIONS],
-[AC_ARG_ENABLE(linker-optimisations,
-	AS_HELP_STRING([--disable-linker-optimisations],
-		       [Disable linker optimisations]),
+# DPKG_LINKER_OPTIMIZATIONS
+# -------------------------
+# Add configure option to disable linker optimizations.
+AC_DEFUN([DPKG_LINKER_OPTIMIZATIONS],
+[
+  AC_ARG_ENABLE([linker-optimizations],
+    AS_HELP_STRING([--disable-linker-optimizations],
+                   [Disable (detected) linker optimizations]),
     [],
     [],
-    [enable_linker_optimisations=yes])
+    [enable_linker_optimizations=yes]
+  )
 
 
-  AS_IF([test "x$enable_linker_optimisations" = "xno"], [
+  AS_IF([test "x$enable_linker_optimizations" = "xno"], [
     LDFLAGS=$(echo "$LDFLAGS" | sed -e "s/ -Wl,-O[[0-9]]*\b//g")
     LDFLAGS=$(echo "$LDFLAGS" | sed -e "s/ -Wl,-O[[0-9]]*\b//g")
   ], [
   ], [
+    save_LDFLAGS=$LDFLAGS
     LDFLAGS="$LDFLAGS -Wl,-O1"
     LDFLAGS="$LDFLAGS -Wl,-O1"
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
+                   [],
+                   [LDFLAGS="$save_LDFLAGS"])
   ])
   ])
 ])
 ])