]> granicus.if.org Git - python/commitdiff
add -Werror=declaration-after-statement only to stdlib extension modules (closes...
authorBenjamin Peterson <benjamin@python.org>
Sun, 10 Aug 2014 03:01:49 +0000 (20:01 -0700)
committerBenjamin Peterson <benjamin@python.org>
Sun, 10 Aug 2014 03:01:49 +0000 (20:01 -0700)
Patch from Stefan Krah.

Makefile.pre.in
Misc/NEWS
configure
configure.ac
setup.py

index f36c11d6528ddf72b4a5aded27cb7ce25aaa2330..3b4e21edaea336ed6e3566f4e75c028595b964bc 100644 (file)
@@ -71,12 +71,17 @@ OPT=                @OPT@
 BASECFLAGS=    @BASECFLAGS@
 BASECPPFLAGS=  @BASECPPFLAGS@
 CONFIGURE_CFLAGS=      @CFLAGS@
+# CFLAGS_NODIST is used for building the interpreter and stdlib C extensions.
+# Use it when a compiler flag should _not_ be part of the distutils CFLAGS
+# once Python is installed (Issue #21121).
+CONFIGURE_CFLAGS_NODIST=@CFLAGS_NODIST@
 CONFIGURE_CPPFLAGS=    @CPPFLAGS@
 CONFIGURE_LDFLAGS=     @LDFLAGS@
 # Avoid assigning CFLAGS, LDFLAGS, etc. so users can use them on the
 # command line to append to these values without stomping the pre-set
 # values.
 PY_CFLAGS=     $(BASECFLAGS) $(OPT) $(CONFIGURE_CFLAGS) $(CFLAGS) $(EXTRA_CFLAGS)
+PY_CFLAGS_NODIST=$(CONFIGURE_CFLAGS_NODIST) $(CFLAGS_NODIST)
 # Both CPPFLAGS and LDFLAGS need to contain the shell's value for setup.py to
 # be able to build extension modules using the directories specified in the
 # environment variables
@@ -91,7 +96,7 @@ ARFLAGS=      @ARFLAGS@
 # Extra C flags added for building the interpreter object files.
 CFLAGSFORSHARED=@CFLAGSFORSHARED@
 # C flags used for building the interpreter object files
-PY_CORE_CFLAGS=        $(PY_CFLAGS) $(PY_CPPFLAGS) $(CFLAGSFORSHARED) -DPy_BUILD_CORE
+PY_CORE_CFLAGS=        $(PY_CFLAGS) $(PY_CFLAGS_NODIST) $(PY_CPPFLAGS) $(CFLAGSFORSHARED) -DPy_BUILD_CORE
 
 
 # Machine-dependent subdirectories
index c0bc433ff80f3cf8ce2233057cf33fb4e036dbf7..a1d55c035816f0de179c344e11b902c3e804c645 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -27,6 +27,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #21121: Don't force 3rd party C extensions to be built with
+  -Werror=declaration-after-statement.
+
 - Issue #21975: Fixed crash when using uninitialized sqlite3.Row (in particular
   when unpickling pickled sqlite3.Row).  sqlite3.Row is now initialized in the
   __new__() method.
index 87e6f3e30e6d13cceb6b420309d5c08e7b4308f7..73792038507c8112fd26decfb554f4ef71ecffe1 100755 (executable)
--- a/configure
+++ b/configure
@@ -662,6 +662,7 @@ SHLIB_SUFFIX
 LIBTOOL_CRUFT
 OTHER_LIBTOOL_OPT
 UNIVERSAL_ARCH_FLAGS
+CFLAGS_NODIST
 BASECFLAGS
 OPT
 ABIFLAGS
@@ -6292,6 +6293,7 @@ fi
 
 
 
+
 # The -arch flags for universal builds on OSX
 UNIVERSAL_ARCH_FLAGS=
 
@@ -6452,7 +6454,7 @@ $as_echo "$ac_cv_declaration_after_statement_warning" >&6; }
 
     if test $ac_cv_declaration_after_statement_warning = yes
     then
-      BASECFLAGS="$BASECFLAGS -Werror=declaration-after-statement"
+      CFLAGS_NODIST="$CFLAGS_NODIST -Werror=declaration-after-statement"
     fi
 
     # if using gcc on alpha, use -mieee to get (near) full IEEE 754
index 124c4450c45de7082676b45ab414f5905959a557..418e16ffa5d517364a2782fbae712e34200b5cac 100644 (file)
@@ -1138,6 +1138,7 @@ then
 fi
 
 AC_SUBST(BASECFLAGS)
+AC_SUBST(CFLAGS_NODIST)
 
 # The -arch flags for universal builds on OSX
 UNIVERSAL_ARCH_FLAGS=
@@ -1222,7 +1223,7 @@ yes)
 
     if test $ac_cv_declaration_after_statement_warning = yes
     then
-      BASECFLAGS="$BASECFLAGS -Werror=declaration-after-statement"
+      CFLAGS_NODIST="$CFLAGS_NODIST -Werror=declaration-after-statement"
     fi
 
     # if using gcc on alpha, use -mieee to get (near) full IEEE 754
index c909261cbd19e85ecd57f1c70d622cf3ad78abe6..5d4f44465a8a344bbec8fba6f99fb5453e63a849 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -19,6 +19,12 @@ from distutils.spawn import find_executable
 
 cross_compiling = "_PYTHON_HOST_PLATFORM" in os.environ
 
+# Add special CFLAGS reserved for building the interpreter and the stdlib
+# modules (Issue #21121).
+cflags = sysconfig.get_config_var('CFLAGS')
+py_cflags_nodist = sysconfig.get_config_var('PY_CFLAGS_NODIST')
+sysconfig.get_config_vars()['CFLAGS'] = cflags + ' ' + py_cflags_nodist
+
 def get_platform():
     # cross build
     if "_PYTHON_HOST_PLATFORM" in os.environ: