Add support for the following f18 options:
-fintrinsic-modules-path
Also the following changes:
- Create a new test case
- Adding dummy module files in the test directory
Depends on : D98522
Paths
| Differential D97080
[flang][driver] Add -fintrinsic-modules-path option ClosedPublic Authored by arnamoy10 on Feb 19 2021, 12:47 PM.
Details Summary Add support for the following f18 options: -fintrinsic-modules-path Also the following changes:
Depends on : D98522
Diff Detail
Unit TestsFailed Event TimelineComment Actions Hi @arnamoy10 , thanks for the patch! Both ieee_arithmetic.mod and iso_fortran_env.mod look like copies of similar files from <build-dir>/tools/flang/include/flang. Could you either re-use those or add something custom?
This revision now requires changes to proceed.Feb 22 2021, 9:43 AM Comment Actions Addressing comments, by separating the search directories from fintrinsic-modules-path in a separate variables. Also added dummy modules for the test case, as using %llvmshlibdir did not work out. Also, not sure what to set as the default directory, as gfortran uses a specific installation location. Comment Actions
We probably should use a location relative to the flang-new binary, i.e. <flang-new-path>/../tools/flang/include/flang/. Question: What are the semantics for this flag in gfortran? Is the path specified with -fintrinsics-module-path _prepended_ or _appended_ to the default search path? Comment Actions
I believe that it is _prepended_. Take this dummy module: module ieee_arithmetic type::ieee_round_type integer(1),private::mode=0_2 end type end Compile it with e.g. flang-new: flang-new -fc1 -fsyntax-only dummy-module.f90 Next, take this Fortran file: program test use ieee_arithmetic implicit none real(kind=4) :: x1 if (.not. ieee_support_nan(x1)) STOP 20 end program test And try compiling it with gfortran: mv ieee_arithmetic.mod tools/flang/ gfortran -fintrinsic-modules-path tools/flang/ test.f90 test.f90:2:6: use ieee_arithmetic 1 Fatal Error: File ‘ieee_arithmetic.mod’ opened at (1) is not a GNU Fortran module file compilation terminated. So gfortran did look in tools/flang first, i.e. the path specified with -fintrinsic-modules-path. Comment Actions Thank you so much for this experiment @awarzynski . I will modify the code accordingly. Comment Actions
Comment Actions Thank you for updating this @arnamoy10 !
Comment Actions Modifying the algo of default search path extraction for supporting Windows platforms.
Comment Actions I tried reproducing the CI failures reported at the top (in particular intrinsic_module_path.f90), but haven't had much luck. @arnamoy10 - how about you? Could you clang-format this patch when uploading the next diff? Thank you!
arnamoy10 added a parent revision: D98522: [flang] Build intrinsic .mod files in include/flang.Mar 15 2021, 7:02 AM Comment Actions Clang-formatting and addressing reviewers' comments: Moved the default directory append to setFortranOpts() arnamoy10 removed a parent revision: D98522: [flang] Build intrinsic .mod files in include/flang.Mar 16 2021, 12:08 PM
Comment Actions Using llvm::sys::path::remove_filename as per suggestion.
Comment Actions Addressing reviewers' comments
Comment Actions LGTM, thank you for working on this! In the summary you refer to -fdebug-module-writer. Could you please update before merging this?
This revision is now accepted and ready to land.Mar 20 2021, 7:38 AM This revision was landed with ongoing or failed builds.Mar 23 2021, 9:30 AM Closed by commit rGcd4abc5242c0: [flang][driver] Add -fintrinsic-modules-path option (authored by arnamoy10). · Explain Why This revision was automatically updated to reflect the committed changes. awarzynski mentioned this in D93401: [flang][driver] Add support for `-D`, `-U`.Jan 27 2022, 8:50 AM
Revision Contents
Diff 325067 clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
flang/include/flang/Frontend/PreprocessorOptions.h
flang/lib/Frontend/CompilerInvocation.cpp
flang/test/Flang-Driver/Inputs/ieee_arithmetic.mod
flang/test/Flang-Driver/Inputs/iso_fortran_env.mod
flang/test/Flang-Driver/driver-help-hidden.f90
flang/test/Flang-Driver/driver-help.f90
flang/test/Flang-Driver/intrinsic_module_path.f90
|
Why not copy this from gfortran?