H.J. Lu wrote:
gfortran: fatal error: cannot read spec file 'libgomp.spec': No such file or directory ... FAIL: gfortran.dg/gomp/declare-variant-mod-1.f90 -O (test for excess errors)
The problem is that dg-additional-sources does not work with '-o' with dg-compile ("-c") as more than one file is involved.
But while 'dg-do link' solves the '-c -o' issue, a testcase that is supposed to compile successfully (no dg-error) will actually invoke the linker, which has issues with -fopenmp (implies the attempt to link libgomp).
(This issue does not manifest for in-tree testing when the system provides what is needed.)
Committed as r15-8085-g2d5c1e5149809f. Thanks for the report! Tobias
commit 2d5c1e5149809f978ea2c07517de13fdbb925de6 Author: Tobias Burnus <tbur...@baylibre.com> Date: Mon Mar 17 10:12:44 2025 +0100 Move gfortran.dg/gomp/declare-variant-mod-1*.f90 to libgomp.fortran/ [PR115271] The test is a supposed to be a compile-only test but as dg-additional-sources does not work with dg-compile (due to compiling with '-o'), dg-link had to be used; as the code actually compiles (no diagnostic error), the linker is actually invoked, which fails unless the system compiler by chance provides the required files. Solution: move the test to libgomp. PR fortran/115271 gcc/testsuite/ChangeLog: * gfortran.dg/gomp/declare-variant-mod-1-use.f90: Move to libgomp/testsuite/libgomp.fortran/. * gfortran.dg/gomp/declare-variant-mod-1.f90: Likewise. libgomp/ChangeLog: * testsuite/libgomp.fortran/declare-variant-mod-1-use.f90: Moved from gcc/testsuite/gfortran.dg/gomp/. * testsuite/libgomp.fortran/declare-variant-mod-1.f90: Likewise. --- .../testsuite/libgomp.fortran}/declare-variant-mod-1-use.f90 | 0 .../gomp => libgomp/testsuite/libgomp.fortran}/declare-variant-mod-1.f90 | 0 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/gcc/testsuite/gfortran.dg/gomp/declare-variant-mod-1-use.f90 b/libgomp/testsuite/libgomp.fortran/declare-variant-mod-1-use.f90 similarity index 100% rename from gcc/testsuite/gfortran.dg/gomp/declare-variant-mod-1-use.f90 rename to libgomp/testsuite/libgomp.fortran/declare-variant-mod-1-use.f90 diff --git a/gcc/testsuite/gfortran.dg/gomp/declare-variant-mod-1.f90 b/libgomp/testsuite/libgomp.fortran/declare-variant-mod-1.f90 similarity index 100% rename from gcc/testsuite/gfortran.dg/gomp/declare-variant-mod-1.f90 rename to libgomp/testsuite/libgomp.fortran/declare-variant-mod-1.f90