Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test suite fails when using GCC 10 #7017

Closed
DimStar77 opened this issue Apr 22, 2020 · 7 comments · Fixed by #7136
Closed

Test suite fails when using GCC 10 #7017

DimStar77 opened this issue Apr 22, 2020 · 7 comments · Fixed by #7136
Milestone

Comments

@DimStar77
Copy link
Contributor

Describe the bug
GCC10 is nearing release and various distros are sarting preparation work. Meson's test suite has been identified as a component that is failing when using gcc19

[  873s] Running compile:
[  873s] Working directory:  /home/abuild/rpmbuild/BUILD/meson-0.54.0/b 536484cc32/meson-private/tmpsv_1caih
[  873s] Command line:  gfortran /home/abuild/rpmbuild/BUILD/meson-0.54.0/b 536484cc32/meson-private/tmpsv_1caih/testfile.f90 -pipe -cpp -E -P -D_FILE_OFFSET_BITS=64 -cpp -P -O0 
[  873s] 
[  873s] Code:
[  873s]  
[  873s]         #ifdef __has_include
[  873s]          #if !__has_include("omp.h")
[  873s]           #error "Header 'omp.h' could not be found"
[  873s]          #endif
[  873s]         #else
[  873s]          #include <omp.h>
[  873s]         #endif
[  873s] Compiler stdout:
[  873s]  
[  873s] 
[  873s] 
[  873s]         #ifdef 0
[  873s]          #if !0("omp.h")
[  873s]           #error "Header 'omp.h' could not be found"
[  873s]          #endif
[  873s]         #else
[  873s]          #include <omp.h>
[  873s]         #endif
[  873s] 
[  873s] Compiler stderr:
[  873s]  /home/abuild/rpmbuild/BUILD/meson-0.54.0/b 536484cc32/meson-private/tmpsv_1caih/testfile.f90:2:0:
[  873s] 
[  873s]     2 |         #ifdef __has_include
[  873s]       | 
[  873s] Error: "__has_include" used outside of preprocessing directive
[  873s] /home/abuild/rpmbuild/BUILD/meson-0.54.0/b 536484cc32/meson-private/tmpsv_1caih/testfile.f90:2:0: Error: missing '(' before "__has_include" operand
[  873s] /home/abuild/rpmbuild/BUILD/meson-0.54.0/b 536484cc32/meson-private/tmpsv_1caih/testfile.f90:2:0: Error: operator "__has_include" requires a header-name
[  873s] /home/abuild/rpmbuild/BUILD/meson-0.54.0/b 536484cc32/meson-private/tmpsv_1caih/testfile.f90:3:0:
[  873s] 
[  873s]     3 |          #if !__has_include("omp.h")
[  873s]       | 
[  873s] Error: "__has_include" used outside of preprocessing directive
[  873s] /home/abuild/rpmbuild/BUILD/meson-0.54.0/b 536484cc32/meson-private/tmpsv_1caih/testfile.f90:3:0: Error: missing '(' before "__has_include" operand
[  873s] /home/abuild/rpmbuild/BUILD/meson-0.54.0/b 536484cc32/meson-private/tmpsv_1caih/testfile.f90:3:0: Error: operator "__has_include" requires a header-name
[  873s] 

Expected behavior
A passing test suite - irrespective of the use of gcc100

system parameters

  • Tested on openSUSE Tumbleweed Staging (i.e. 'packages to integrate into future openSUSE Tumbleweed snapshots); the only change is the switch from gcc9.3.1 to gcc 10

Always latest build log available at: https://build.opensuse.org/build/openSUSE:Factory:Staging:N/standard/x86_64/meson:test/_log

@lazka
Copy link
Contributor

lazka commented May 12, 2020

The MSYS2 jobs in CI show this error now since the update to GCC 10.

@lazka
Copy link
Contributor

lazka commented May 12, 2020

since it affects fortran @scivision do you have any idea what's wrong here?

@scivision
Copy link
Member

scivision commented May 13, 2020

The code put in testfile.f90 isn't a full test if OpenMP is truly linkable. GCC 10 and in particular Gfortran 10 got a lot stricter about invalid code, and this appears ripe for updating anyway.

Old Meson code

doesn't work with gfortran -E -P -cpp for GCC 10

#ifdef __has_include
#if !__has_include("omp.h")
#error "Header \'omp.h\' could not be found"
#endif
#else 
#include <omp.h>
#endif

Fortran-specific stanza for detecting if OpenMP is available and linkable

In general I strongly prefer tests like this, because in general users may have multiple compilers and OpenMP libraries installed, which are not necessarily ABI compatible. This brief test gives higher confidence that an ABI-compatible set is found.

use omp_lib  ! tests that OpenMP is included
implicit none
!$ integer :: N  ! OpenMP reads lines starting like this
N = omp_get_num_threads() ! tests that OpenMP is linked

this shorter test is not as complete, but is still more thorough than the original Meson code:

use omp_lib

@scivision
Copy link
Member

scivision commented May 13, 2020

If this is suitable, one would slightly modify the Meson code to swap in this stanza in if the language is Fortran. I can do this if others agree.

@lazka
Copy link
Contributor

lazka commented May 13, 2020

From what I see this is just the output of the generic has_header, maybe called from

if self.clib_compiler.has_header(name, '', self.env, dependencies=[self], disable_cache=True)[0]:
so not easy to replace.

@nirbheek nirbheek added this to the 0.54.2 milestone May 14, 2020
@nirbheek
Copy link
Member

The main bug to solve is that compiler.has_header() does not work if compiler is gfortran >= 10.

nirbheek added a commit that referenced this issue May 14, 2020
__has_include is not accepted as a pre-processor directive in Fortran
code since GCC 10.

Closes #7017
@nirbheek
Copy link
Member

#7136 fixes it.

nirbheek added a commit that referenced this issue May 14, 2020
__has_include is not accepted as a pre-processor directive in Fortran
code since GCC 10.

Closes #7017
nirbheek added a commit that referenced this issue May 14, 2020
__has_include is not accepted as a pre-processor directive in Fortran
code since GCC 10.

Closes #7017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants