[PATCH v2 1/1] libgomp: Fix gfortran detection when program is found via PATH
Peter0x44 via Sourceware Forge <[email protected]> Sat, 04 Jul 2026 13:45:25 +0000
| Newsgroups | gmane.comp.gcc.patches,gmane.comp.gcc.fortran |
|---|---|
| Message-ID | <bmm.hk2y8pxbwk.gcc.gcc-TEST.Peter0x44.172.2.1@forge-stage.sourceware.org> |
From: Peter Damianov <[email protected]> The gfortran detection logic in libgomp's configure uses "test -x" to check whether the $GFORTRAN program is executable. However, "test -x" only succeeds for absolute or relative paths that name an existing file; it fails for bare program names (e.g. "x86_64-w64-mingw32-gfortran") that are found via $PATH lookup. This causes FC to be incorrectly set to "no" in cross-compilation environments where $GFORTRAN is a bare command name rather than a full path. As a result, the Fortran OpenMP module (omp_lib.mod) is never installed, and programs that "use omp_lib" fail with: Fatal Error: Cannot open module file 'omp_lib.mod' for reading The fix adds a "command -v" fallback for testing whether a command is available on $PATH. The bug was introduced in r0-98199-g2122aa973ed (2010-01-26), so the Fortran OpenMP module has been missing from cross-compiled installs for 16 years. libgomp/ChangeLog: * configure.ac: Also accept $GFORTRAN when it can be found via PATH lookup using "command -v", not only when "test -x" succeeds on the bare name. * configure: Regenerate. --- libgomp/configure | 2 +- libgomp/configure.ac | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libgomp/configure b/libgomp/configure index 2f395a883f2a..7fc926aed82a 100755 --- a/libgomp/configure +++ b/libgomp/configure @@ -12270,7 +12270,7 @@ case `echo $GFORTRAN` in FC=no ;; *) set dummy $GFORTRAN; ac_word=$2 - if test -x "$ac_word"; then + if test -x "$ac_word" || command -v "$ac_word" >/dev/null 2>&1; then FC="$GFORTRAN" else FC=no diff --git a/libgomp/configure.ac b/libgomp/configure.ac index 057debe92141..5bb5ee0b7d3a 100644 --- a/libgomp/configure.ac +++ b/libgomp/configure.ac @@ -164,7 +164,7 @@ case `echo $GFORTRAN` in FC=no ;; *) set dummy $GFORTRAN; ac_word=$2 - if test -x "$ac_word"; then + if test -x "$ac_word" || command -v "$ac_word" >/dev/null 2>&1; then FC="$GFORTRAN" else FC=no -- 2.54.0