From: Simon Ruderich Date: Sun, 23 Jul 2017 15:59:16 +0000 (+0200) Subject: Improve Fortran support, also for Open MPI (mpifort) X-Git-Tag: 0.08~10 X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=cda2e04237c0657e09d248b7f33c6ad0dc56612e;p=blhc%2Fblhc.git Improve Fortran support, also for Open MPI (mpifort) --- diff --git a/NEWS b/NEWS index 9806794..f8bbff1 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,7 @@ Version 0.XX - Support Open MPI mpicc/mpicxx compiler wrappers to prevent false positives in non-verbose-build detection, reported by Boud Roukema and Nico Schlömer (Debian Bug #853265). +- Add better support for Fortran (c.f. Debian Bug #853265). Version 0.07 diff --git a/bin/blhc b/bin/blhc index 4a16a36..6afff57 100755 --- a/bin/blhc +++ b/bin/blhc @@ -33,7 +33,7 @@ our $VERSION = '0.07'; my $cc_regex = qr/ (? 1 } ( @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, ); @@ -730,6 +742,8 @@ foreach my $file (@ARGV) { # 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 @@ -827,6 +841,10 @@ foreach my $file (@ARGV) { 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. @@ -1088,10 +1106,11 @@ foreach my $file (@ARGV) { } # 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) { @@ -1248,6 +1267,12 @@ LINE: $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) { diff --git a/t/logs/fortran b/t/logs/fortran new file mode 100644 index 0000000..4a4488b --- /dev/null +++ b/t/logs/fortran @@ -0,0 +1,18 @@ +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 diff --git a/t/tests.t b/t/tests.t index 6e66495..2d02809 100644 --- a/t/tests.t +++ b/t/tests.t @@ -19,7 +19,7 @@ use strict; use warnings; -use Test::More tests => 216; +use Test::More tests => 218; sub is_blhc { @@ -765,6 +765,19 @@ is_blhc 'ada-pbuilder', '', 8, $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,