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

dpkg-buildflags: Add support for FCFLAGS, OBJCFLAGS and OBJCXXFLAGS

Add default values in Debian and derivatives for these flags.

Distinguish FFLAGS from FCFLAGS by mentioning that the former is for the
Fortran 77 compiler and the latter for the Fortran 9x compiler.

Closes: #744326
Guillem Jover лет назад: 12
Родитель
Сommit
d3611d0d83

+ 2 - 0
debian/changelog

@@ -49,6 +49,8 @@ dpkg (1.17.7) UNRELEASED; urgency=low
     Thanks to Adam Conrad <adconrad@debian.org. Closes: #738691
   * Add OpenRISC or1k support to cputable.
     Thanks to Christian Svensson <christian@cmd.nu>. Closes: #736717
+  * Add support for FCFLAGS, OBJCFLAGS and OBJCXXFLAGS build flags.
+    Closes: #744326
 
   [ Updated dpkg translations ]
   * German (Sven Joachim).

+ 16 - 4
man/dpkg-buildflags.1

@@ -169,11 +169,20 @@ Options for the C preprocessor. Default value: empty.
 .B CXXFLAGS
 Options for the C++ compiler. Same as \fBCFLAGS\fP.
 .TP
+.B OBJCFLAGS
+Options for the Objective C compiler. Same as \fBCFLAGS\fP.
+.TP
+.B OBJCXXFLAGS
+Options for the Objective C++ compiler. Same as \fBCXXFLAGS\fP.
+.TP
 .B GCJFLAGS
 Options for the GNU Java compiler (gcj). A subset of \fBCFLAGS\fP.
 .TP
 .B FFLAGS
-Options for the Fortran compiler. A subset of \fBCFLAGS\fP.
+Options for the Fortran 77 compiler. A subset of \fBCFLAGS\fP.
+.TP
+.B FCFLAGS
+Options for the Fortran 9x compiler. Same as \fBFFLAGS\fP.
 .TP
 .B LDFLAGS
 Options passed to the compiler when linking executables or shared
@@ -211,7 +220,8 @@ enabling only "format" and "fortify" can be achieved with:
 .B format
 This setting (enabled by default) adds
 .B \-Wformat \-Werror=format\-security
-to \fBCFLAGS\fP and \fBCXXFLAGS\fP. This will warn about improper format
+to \fBCFLAGS\fP, \fBCXXFLAGS\fP, \fBOBJCFLAGS\fP and \fBOBJCXXFLAGS\fP.
+This will warn about improper format
 string uses, and will fail when format functions are used in a way
 that represent possible security problems. At present, this warns about
 calls to \fBprintf\fP and \fBscanf\fP functions where the format string is
@@ -241,7 +251,8 @@ glibc 2.16 and later.
 .B stackprotector
 This setting (enabled by default) adds
 .B \-fstack-protector \-\-param=ssp\-buffer\-size=4
-to \fBCFLAGS\fP, \fBCXXFLAGS\fP, \fBGCJFLAGS\fP and \fBFFLAGS\fP.
+to \fBCFLAGS\fP, \fBCXXFLAGS\fP, \fBOBJCFLAGS\fP, \fBOBJCXXFLAGS\fP,
+\fBGCJFLAGS\fP, \fBFFLAGS\fP and \fBFCFLAGS\fP.
 This adds safety checks against stack
 overwrites. This renders many potential code injection attacks into
 aborting situations. In the best case this turns code injection
@@ -273,7 +284,8 @@ above). The option cannot become enabled if \fBrelro\fP is not enabled.
 .TP
 .B pie
 This setting (disabled by default) adds \fB\-fPIE\fP to \fBCFLAGS\fP,
-\fBCXXFLAGS\fP, \fBGCJFLAGS\fP and \fBFFLAGS\fP,
+\fBCXXFLAGS\fP, \fBOBJCFLAGS\fP, \fBOBJCXXFLAGS\fP, \fBGCJFLAGS\fP,
+\fBFFLAGS\fP and \fBFCFLAGS\fP,
 and \fB\-fPIE \-pie\fP to \fBLDFLAGS\fP. Position Independent
 Executable are needed to take advantage of Address Space Layout
 Randomization, supported by some kernel versions. While ASLR can already

+ 9 - 0
scripts/Dpkg/BuildFlags.pm

@@ -78,24 +78,33 @@ sub load_vendor_defaults {
 	CPPFLAGS => '',
 	CFLAGS   => $default_flags,
 	CXXFLAGS => $default_flags,
+	OBJCFLAGS   => $default_flags,
+	OBJCXXFLAGS => $default_flags,
 	GCJFLAGS => $default_flags,
 	FFLAGS   => $default_flags,
+	FCFLAGS  => $default_flags,
 	LDFLAGS  => '',
     };
     $self->{origin} = {
 	CPPFLAGS => 'vendor',
 	CFLAGS   => 'vendor',
 	CXXFLAGS => 'vendor',
+	OBJCFLAGS   => 'vendor',
+	OBJCXXFLAGS => 'vendor',
 	GCJFLAGS => 'vendor',
 	FFLAGS   => 'vendor',
+	FCFLAGS  => 'vendor',
 	LDFLAGS  => 'vendor',
     };
     $self->{maintainer} = {
 	CPPFLAGS => 0,
 	CFLAGS   => 0,
 	CXXFLAGS => 0,
+	OBJCFLAGS   => 0,
+	OBJCXXFLAGS => 0,
 	GCJFLAGS => 0,
 	FFLAGS   => 0,
+	FCFLAGS  => 0,
 	LDFLAGS  => 0,
     };
     # The Debian vendor hook will add hardening build flags

+ 8 - 0
scripts/Dpkg/Vendor/Debian.pm

@@ -150,7 +150,10 @@ sub add_hardening_flags {
     # PIE
     if ($use_feature{pie}) {
 	$flags->append('CFLAGS', '-fPIE');
+	$flags->append('OBJCFLAGS', '-fPIE');
+	$flags->append('OBJCXXFLAGS', '-fPIE');
 	$flags->append('FFLAGS', '-fPIE');
+	$flags->append('FCFLAGS', '-fPIE');
 	$flags->append('CXXFLAGS', '-fPIE');
 	$flags->append('GCJFLAGS', '-fPIE');
 	$flags->append('LDFLAGS', '-fPIE -pie');
@@ -159,7 +162,10 @@ sub add_hardening_flags {
     # Stack protector
     if ($use_feature{stackprotector}) {
 	$flags->append('CFLAGS', '-fstack-protector --param=ssp-buffer-size=4');
+	$flags->append('OBJCFLAGS', '-fstack-protector --param=ssp-buffer-size=4');
+	$flags->append('OBJCXXFLAGS', '-fstack-protector --param=ssp-buffer-size=4');
 	$flags->append('FFLAGS', '-fstack-protector --param=ssp-buffer-size=4');
+	$flags->append('FCFLAGS', '-fstack-protector --param=ssp-buffer-size=4');
 	$flags->append('CXXFLAGS', '-fstack-protector --param=ssp-buffer-size=4');
 	$flags->append('GCJFLAGS', '-fstack-protector --param=ssp-buffer-size=4');
     }
@@ -173,6 +179,8 @@ sub add_hardening_flags {
     if ($use_feature{format}) {
 	$flags->append('CFLAGS', '-Wformat -Werror=format-security');
 	$flags->append('CXXFLAGS', '-Wformat -Werror=format-security');
+	$flags->append('OBJCFLAGS', '-Wformat -Werror=format-security');
+	$flags->append('OBJCXXFLAGS', '-Wformat -Werror=format-security');
     }
 
     # Read-only Relocations

+ 2 - 1
scripts/Dpkg/Vendor/Ubuntu.pm

@@ -99,7 +99,8 @@ sub run_hook {
 
 	if (!$build_opts->has('noopt')) {
 	    if (debarch_eq(get_host_arch(), 'ppc64el')) {
-		for my $flag (qw(CFLAGS CXXFLAGS GCJFLAGS FFLAGS)) {
+		for my $flag (qw(CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS GCJFLAGS
+		                 FFLAGS FCFLAGS)) {
 		    $flags->set($flag, '-g -O3', 'vendor');
 		}
 	    }

+ 6 - 2
scripts/mk/buildflags.mk

@@ -3,8 +3,11 @@
 # CFLAGS: flags for the C compiler
 # CPPFLAGS: flags for the C preprocessor
 # CXXFLAGS: flags for the C++ compiler
+# OBJCFLAGS: flags for the Objective C compiler
+# OBJCXXFLAGS: flags for the Objective C++ compiler
 # GCJFLAGS: flags for the GNU Java compiler
-# FFLAGS: flags for the Fortran compiler
+# FFLAGS: flags for the Fortran 77 compiler
+# FCFLAGS: flags for the Fortran 9x compiler
 # LDFLAGS: flags for the linker
 #
 # You can also export them in the environment by setting
@@ -15,7 +18,8 @@
 
 dpkg_late_eval ?= $(or $(value DPKG_CACHE_$(1)),$(eval DPKG_CACHE_$(1) := $(shell $(2)))$(value DPKG_CACHE_$(1)))
 
-DPKG_BUILDFLAGS_LIST = CFLAGS CPPFLAGS CXXFLAGS GCJFLAGS FFLAGS LDFLAGS
+DPKG_BUILDFLAGS_LIST = CFLAGS CPPFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS \
+                       GCJFLAGS FFLAGS FCFLAGS LDFLAGS
 
 define dpkg_buildflags_export_envvar
 ifdef $(1)