public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: Satish Balay <balay.anl@fastmail.org>
To: bug-gcc@gnu.org
Subject: gfortran-14.1.1: issue with -Jpath search order
Date: Tue, 4 Jun 2024 20:35:05 -0500 (CDT)	[thread overview]
Message-ID: <a144ae89-c238-1afd-c247-acc4cbf128c1@fastmail.org> (raw)

A test case:

>>>>>>>>>
$ ls
incdir/  moddir/  srcdir/
$ ls incdir/
$ ls moddir/
$ ls srcdir/
modtest.F90
$ cat srcdir/modtest.F90 
module modtest
integer a
end module
program main
use modtest
end
$ gfortran --version
GNU Fortran (GCC) 14.1.1 20240522 (Red Hat 14.1.1-4)
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ strace --follow-forks -o trace.log gfortran -Jmoddir -Iincdir srcdir/modtest.F90
$ 
<<<<

From trace.log:

>>>>
231249 openat(AT_FDCWD, "moddir/modtest.mod", O_RDONLY) = -1 ENOENT (No such file or directory)
231249 unlink("moddir/modtest.mod")     = -1 ENOENT (No such file or directory)
231249 rename("moddir/modtest.mod0", "moddir/modtest.mod") = 0
231249 openat(AT_FDCWD, "modtest.mod", O_RDONLY) = -1 ENOENT (No such file or directory)
231249 openat(AT_FDCWD, "srcdir/modtest.mod", O_RDONLY) = -1 ENOENT (No such file or directory)
231249 openat(AT_FDCWD, "incdir/modtest.mod", O_RDONLY) = -1 ENOENT (No such file or directory)
231249 openat(AT_FDCWD, "moddir/modtest.mod", O_RDONLY) = 5
<<<<

i.e after moddir/modtest.mod is created - its searched for in the following order:

- pwd
- src-file-dir
- -Ipath
- -Jpath

With this search order - a buggy/old/incorrect modtest.mod in pwd or src-file-dir gets picked up - resulting in broken builds.

Checking ifx from OneAPI - i see:

>>>>
$ ifx --version
ifx (IFORT) 2023.0.0 20221201
Copyright (C) 1985-2022 Intel Corporation. All rights reserved.

$ ifx --help |& grep -A2 \\-module
-module path
           specify path where mod files should be placed and first location to
           look for mod files
<<<<
Here with ifx - I don't get into the issue with picking up buggy/old/incorrect modtest.mod. With a slightly tweaked test:

>>>>>>>>
$ cat srcdir/modtest.F90
module modtest
integer a
end module
program main
use modtestwrong
end
$ strace --follow-forks -o trace.log ifx -module moddir -Iincdir srcdir/modtest.F90
srcdir/modtest.F90(5): error #7002: Error in opening the compiled module file.  Check INCLUDE paths.   [MODTESTWRONG]
use modtestwrong
----^
compilation aborted for srcdir/modtest.F90 (code 1)
$ 
<<<

trace.log has:

>>>
1573952 openat(AT_FDCWD, "moddir/modtestwrong.mod", O_RDONLY) = -1 ENOENT (No such file or directory)
1573952 openat(AT_FDCWD, "modtestwrong.mod", O_RDONLY) = -1 ENOENT (No such file or directory)
1573952 openat(AT_FDCWD, "srcdir/modtestwrong.mod", O_RDONLY) = -1 ENOENT (No such file or directory)
1573952 openat(AT_FDCWD, "./modtestwrong.mod", O_RDONLY) = -1 ENOENT (No such file or directory)
1573952 openat(AT_FDCWD, "incdir/modtestwrong.mod", O_RDONLY) = -1 ENOENT (No such file or directory)
...
<<<<
[i.e; -Jpath is searched first, then pwd, src-file-dir, ./, -Ipath, ...]

So is this a bug in gfortran?

thanks,
Satish


                 reply	other threads:[~2024-06-05  1:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a144ae89-c238-1afd-c247-acc4cbf128c1@fastmail.org \
    --to=balay.anl@fastmail.org \
    --cc=bug-gcc@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).