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

Flang not respecting -module flag #66969

Closed
h-vetinari opened this issue Sep 21, 2023 · 3 comments
Closed

Flang not respecting -module flag #66969

h-vetinari opened this issue Sep 21, 2023 · 3 comments

Comments

@h-vetinari
Copy link
Contributor

While trying to get flang working on a project that uses the meson build system, we ran into:

[133/1628] Compiling Fortran object scipy/special/libamos.a.p/amos_dgamln.f.obj
FAILED: scipy/special/libamos.a.p/amos_dgamln.f.obj 
"flang-new" "-Iscipy\special\libamos.a.p" "-Iscipy\special" "-I..\scipy\special" "-fcolor-diagnostics" "-DNDEBUG" "-D_FILE_OFFSET_BITS=64" "-O3" "-module" "scipy\special\libamos.a.p" -MD -MQ scipy/special/libamos.a.p/amos_dgamln.f.obj -MF "scipy\special\libamos.a.p\amos_dgamln.f.obj.d" -o scipy/special/libamos.a.p/amos_dgamln.f.obj "-c" ../scipy/special/amos/dgamln.f
flang-new: error: unknown argument: '-module'

flang-new: warning: scipy\special\libamos.a.p: 'linker' input unused

This is because -module is apparently so common in Fortran compilers, that it's the baseline assumption for how meson constructs its commandline invocations for most Fortran compilers (it's worth noting that this method gets overridden for several compilers, though notably, meson for classic flang defaults to -module).

It seems this assumption matches parts of flang's documentation (which do indicate -module support)...

## Reading and writing module files
### Options
The compiler will have command-line options to specify where to search
for module files and where to write them. By default it will be the current
directory for both.
For PGI, `-I` specifies directories to search for include files and module
files. `-module` specifics a directory to write module files in as well as to
search for them. gfortran is similar except it uses `-J` instead of `-module`.
The search order for module files is:
1. The `-module` directory (Note: for gfortran the `-J` directory is not searched).
2. The current directory
3. The `-I` directories in the order they appear on the command line

... but not others, which say:

-module-dir<dir>, -J<arg>

This option specifies where to put .mod files for compiled modules. It is also added to the list of directories to be searched by an USE statement. The default is the current directory.

I'm not sure if this was an oversight in the recent option-refactor. It's certainly conceivable to teach meson that (llvm-)flang needs -module-dir instead of -module. However, it's at least surprising (given the documentation divergence), so I thought I'd raise this.

CC @banach-space

@github-actions github-actions bot added the flang Flang issues not falling into any other category label Sep 21, 2023
@EugeneZelenko EugeneZelenko added flang:driver and removed flang Flang issues not falling into any other category labels Sep 21, 2023
@llvmbot
Copy link
Member

llvmbot commented Sep 21, 2023

@llvm/issue-subscribers-flang-driver

While [trying](https://github.com/conda-forge/scipy-feedstock/pull/252) to get flang working on a project that uses the meson build system, we ran into:
[133/1628] Compiling Fortran object scipy/special/libamos.a.p/amos_dgamln.f.obj
FAILED: scipy/special/libamos.a.p/amos_dgamln.f.obj 
"flang-new" "-Iscipy\special\libamos.a.p" "-Iscipy\special" "-I..\scipy\special" "-fcolor-diagnostics" "-DNDEBUG" "-D_FILE_OFFSET_BITS=64" "-O3" "-module" "scipy\special\libamos.a.p" -MD -MQ scipy/special/libamos.a.p/amos_dgamln.f.obj -MF "scipy\special\libamos.a.p\amos_dgamln.f.obj.d" -o scipy/special/libamos.a.p/amos_dgamln.f.obj "-c" ../scipy/special/amos/dgamln.f
flang-new: error: unknown argument: '-module'

flang-new: warning: scipy\special\libamos.a.p: 'linker' input unused

This is because -module is apparently so common in Fortran compilers, that it's the baseline assumption for how meson constructs its commandline invocations for most Fortran compilers (it's worth noting that this method gets overridden for several compilers, though notably, meson for classic flang defaults to -module).

It seems this assumption matches parts of flang's documentation (which do indicate -module support)...

## Reading and writing module files
### Options
The compiler will have command-line options to specify where to search
for module files and where to write them. By default it will be the current
directory for both.
For PGI, `-I` specifies directories to search for include files and module
files. `-module` specifics a directory to write module files in as well as to
search for them. gfortran is similar except it uses `-J` instead of `-module`.
The search order for module files is:
1. The `-module` directory (Note: for gfortran the `-J` directory is not searched).
2. The current directory
3. The `-I` directories in the order they appear on the command line

... but not others, which say:
> -module-dir&lt;dir>, -J&lt;arg>
>
> This option specifies where to put .mod files for compiled modules. It is also added to the list of directories to be searched by an USE statement. The default is the current directory.

I'm not sure if this was an oversight in the recent option-refactor. It's certainly conceivable to teach meson that (llvm-)flang needs -module-dir instead of -module. However, it's at least surprising (given the documentation divergence), so I thought I'd raise this.

CC @banach-space

@banach-space
Copy link
Contributor

Hi @h-vetinari , sorry for the delay. You will find the relevant discussion here: https://lists.llvm.org/pipermail/flang-dev/2020-November/000597.html

flang-new supports -module-dir and -J. Perhaps you could use the latter? That would be compatible with GNU.

@h-vetinari
Copy link
Contributor Author

Ok, thanks for the context and confirming that this is intentional. Closing

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

No branches or pull requests

4 participants