my $cc_regex = qr/
(?<!\s-) # ignore options, e.g. "-c++" [sic!] (used by swig)
(?<!\.) # ignore file names, e.g. "test.gcc"
- (?:cc|gcc|g\+\+|c\+\+|mpicc|mpicxx)
+ (?:cc|gcc|g\+\+|c\+\+|gfortran|mpicc|mpicxx|mpifort)
(?:-[\d.]+)? # version suffix, e.g. "gcc-4.6"
/x;
# Full regex which matches the complete compiler name. Used in a few places to
# Objective-C++
qw( mm M ),
);
+my @source_preprocess_compile_fortran = (
+ # Fortran
+ qw( F FOR fpp FPP FTN F90 F95 F03 F08 ),
+);
my @source_preprocess_compile = (
# C
qw( c ),
# (Objective-)C++
@source_preprocess_compile_cpp,
# Fortran
- qw( F FOR fpp FPP FTN F90 F95 F03 F08 ),
+ @source_preprocess_compile_fortran,
);
my @source_preprocess_no_compile = (
# Assembly
# Ada body
qw( adb ),
);
+my @source_no_preprocess_compile_fortran = (
+ # Fortran
+ qw( f for ftn f90 f95 f03 f08 ),
+);
my @source_no_preprocess_compile = (
# C
qw( i ),
# Objective-C
qw( mi ),
# Fortran
- qw( f for ftn f90 f95 f03 f08 ),
+ @source_no_preprocess_compile_fortran,
# Ada
@source_no_preprocess_compile_ada,
);
@source_no_preprocess_compile_ada,
@source_no_preprocess_no_compile_ada,
);
+my %extensions_fortran = map { $_ => 1 } (
+ @source_no_preprocess_compile_fortran,
+ @source_preprocess_compile_fortran,
+);
my %extensions_object = map { $_ => 1 } (
@object,
);
# different CFLAGS. But only perform ada checks if an ada compiler is used
# for performance reasons.
my $ada = 0;
+ # Fortran also requires different CFLAGS.
+ my $fortran = 0;
# Number of parallel jobs to prevent false positives when detecting
# non-verbose builds. As not all jobs declare the number of parallel jobs
if ($line =~ /\bgnat\b/) {
$ada = 1;
}
+ # Fortran compiler.
+ if ($line =~ /\bgfortran\b/) {
+ $fortran = 1;
+ }
}
# This flags is not always available, but if it is use it.
}
# Ada doesn't support format hardening flags, see #680117 for more
- # information. Filter them out if ada is used.
+ # information. Same for fortran. Filter them out if either language is
+ # used.
my @cflags_backup;
my @cflags_noformat;
- if ($ada and $harden_format) {
+ if (($ada or $fortran) and $harden_format) {
@cflags_noformat = grep {
my $ok = 1;
foreach my $flag (@def_cflags_format) {
$preprocess = 0; # Ada uses no CPPFLAGS
@cflags_backup = @cflags;
@cflags = @cflags_noformat;
+ # Same for fortran.
+ } elsif ($fortran
+ and extension_found(\%extensions_fortran, @extensions)) {
+ $restore_cflags = 1;
+ @cflags_backup = @cflags;
+ @cflags = @cflags_noformat;
}
if ($option_buildd) {
--- /dev/null
+Filtered Build-Depends: ..., gfortran, ...
+
+dpkg-buildpackage: source package fortran package
+
+gfortran -g -w -O2 -Wtabs -ffixed-line-length-132 -Wl,-z,relro -o balls balls.f
+gfortran -g -w -O2 -Wtabs -ffixed-line-length-132 -c -o quadric.o quadric.f
+gfortran -g -w -O2 -Wtabs -ffixed-line-length-132 -c -o suv.o suv.f
+gfortran -g -w -O2 -Wtabs -ffixed-line-length-132 \
+rastep.f quadric.o suv.o -Wl,-z,relro \
+-o rastep
+gfortran -g -w -O2 -Wtabs -ffixed-line-length-132 -c -o render.o render.f
+gfortran -g -w -O2 -Wtabs -ffixed-line-length-132 -fstack-protector-strong -o balls-without-ldflags balls.f
+
+mpifort -cpp -DDOUB -g -O2 -fdebug-prefix-map=/«PKGBUILDDIR»=. -c -o transform.o transform.f90
+
+# correct
+gfortran -g -w -O2 -Wtabs -ffixed-line-length-132 -Wl,-z,relro -fstack-protector-strong -o balls balls.f
+mpifort -cpp -DDOUB -g -O2 -fdebug-prefix-map=/«PKGBUILDDIR»=. -fstack-protector-strong -c -o paste.o paste.f90
use strict;
use warnings;
-use Test::More tests => 216;
+use Test::More tests => 218;
sub is_blhc {
$ada;
+# fortran
+
+is_blhc 'fortran', '', 8,
+ 'CFLAGS missing (-fstack-protector-strong): gfortran -g -w -O2 -Wtabs -ffixed-line-length-132 -Wl,-z,relro -o balls balls.f
+CFLAGS missing (-fstack-protector-strong): gfortran -g -w -O2 -Wtabs -ffixed-line-length-132 -c -o quadric.o quadric.f
+CFLAGS missing (-fstack-protector-strong): gfortran -g -w -O2 -Wtabs -ffixed-line-length-132 -c -o suv.o suv.f
+CFLAGS missing (-fstack-protector-strong): gfortran -g -w -O2 -Wtabs -ffixed-line-length-132 \ rastep.f quadric.o suv.o -Wl,-z,relro \ -o rastep
+CFLAGS missing (-fstack-protector-strong): gfortran -g -w -O2 -Wtabs -ffixed-line-length-132 -c -o render.o render.f
+LDFLAGS missing (-Wl,-z,relro): gfortran -g -w -O2 -Wtabs -ffixed-line-length-132 -fstack-protector-strong -o balls-without-ldflags balls.f
+CFLAGS missing (-fstack-protector-strong): mpifort -cpp -DDOUB -g -O2 -fdebug-prefix-map=/«PKGBUILDDIR»=. -c -o transform.o transform.f90
+';
+
+
# libtool
is_blhc 'libtool', '--bindnow', 12,