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

Parse intrinsic and non_intrinsic used modules #920

Merged
merged 12 commits into from
Jun 14, 2023

Conversation

perazz
Copy link
Contributor

@perazz perazz commented Jun 1, 2023

Addressing #917. @dacarnazzola

  • Parse intrinsic, non_intrinsic keywords in use statement
  • if intrinsic, check that it's a valid intrinsic module name (except in a continuation line)
  • add tests and example package that overrides iso_fortran_env.

@minhqdao @arteevraina @henilp105 @urbanjost would you mind reviewing?

@barracuda156 this is potentially relevant for #850.

@perazz
Copy link
Contributor Author

perazz commented Jun 1, 2023

Apparently stdlib has use statements with nothing until a continuation line:

<ERROR> *cmd_build* Model error: Parse error: module is declared intrinsic but it is not 
build/dependencies/stdlib/src/stdlib_logger.f90:45
   | use, intrinsic ::           &
STOP 1

Continuation lines are not supported by fpm yet for the use statement, will try to find a workaround for this.

SOLUTION: let's defer that check to the compiler, if there is a continuation line. Parsing continuation lines in fpm would be a far bigger effort beyond the scope of this PR, due to all possible source formats.

@perazz perazz marked this pull request as draft June 1, 2023 11:15
@perazz perazz marked this pull request as ready for review June 1, 2023 11:46
@perazz perazz requested a review from urbanjost June 1, 2023 13:29
@barracuda156
Copy link
Contributor

@perazz I can test this, but a bit later (like, in a few hours, hopefully). Machine which has the needed setup is busy atm.

Copy link
Member

@henilp105 henilp105 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @perazz , Looks good to me.

@barracuda156
Copy link
Contributor

@perazz Sorry, will try this out today. Been very busy recently.

@barracuda156
Copy link
Contributor

@perazz Does not seem to help. I have activated a build of gcc12 without ieee_arithmetic, and fpm does not build with your patches:

--->  Applying patches to fpm
--->  Applying patch-install.diff
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_fpm/fpm/work/fpm-0.9.0" && /usr/bin/patch -p0 < '/opt/PPCSnowLeopardPorts/devel/fpm/files/patch-install.diff'
patching file install.sh
--->  Applying 0001-parse-non_intrinsic-and-intrinsic-use-d-modules.patch
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_fpm/fpm/work/fpm-0.9.0" && /usr/bin/patch -p0 < '/opt/PPCSnowLeopardPorts/devel/fpm/files/0001-parse-non_intrinsic-and-intrinsic-use-d-modules.patch'
patching file src/fpm_source_parsing.f90
--->  Applying 0002-tests-for-non_intrinsic-parsing.patch
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_fpm/fpm/work/fpm-0.9.0" && /usr/bin/patch -p0 < '/opt/PPCSnowLeopardPorts/devel/fpm/files/0002-tests-for-non_intrinsic-parsing.patch'
patching file test/fpm_test/test_source_parsing.f90
--->  Applying 0003-cleanup.patch
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_fpm/fpm/work/fpm-0.9.0" && /usr/bin/patch -p0 < '/opt/PPCSnowLeopardPorts/devel/fpm/files/0003-cleanup.patch'
patching file src/fpm_source_parsing.f90
--->  Applying 0004-add-example-package.patch
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_fpm/fpm/work/fpm-0.9.0" && /usr/bin/patch -p0 < '/opt/PPCSnowLeopardPorts/devel/fpm/files/0004-add-example-package.patch'
patching file example_packages/nonintrinsic/.gitignore
patching file example_packages/nonintrinsic/app/main.f90
patching file example_packages/nonintrinsic/fpm.toml
patching file example_packages/nonintrinsic/src/iso_fortran_env.f90
--->  Applying 0005-add-to-CI.patch
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_fpm/fpm/work/fpm-0.9.0" && /usr/bin/patch -p0 < '/opt/PPCSnowLeopardPorts/devel/fpm/files/0005-add-to-CI.patch'
patching file ci/run_tests.sh
--->  Applying 0006-fix-use-identification.patch
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_fpm/fpm/work/fpm-0.9.0" && /usr/bin/patch -p0 < '/opt/PPCSnowLeopardPorts/devel/fpm/files/0006-fix-use-identification.patch'
patching file src/fpm_source_parsing.f90
--->  Applying 0007-Update-fpm_source_parsing.f90.patch
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_fpm/fpm/work/fpm-0.9.0" && /usr/bin/patch -p0 < '/opt/PPCSnowLeopardPorts/devel/fpm/files/0007-Update-fpm_source_parsing.f90.patch'
patching file src/fpm_source_parsing.f90
--->  Applying 0008-fix-intrinsic-module-parsing-in-the-next-line.patch
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_fpm/fpm/work/fpm-0.9.0" && /usr/bin/patch -p0 < '/opt/PPCSnowLeopardPorts/devel/fpm/files/0008-fix-intrinsic-module-parsing-in-the-next-line.patch'
patching file src/fpm_source_parsing.f90
--->  Applying 0009-cleanup.patch
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_fpm/fpm/work/fpm-0.9.0" && /usr/bin/patch -p0 < '/opt/PPCSnowLeopardPorts/devel/fpm/files/0009-cleanup.patch'
patching file src/fpm_source_parsing.f90
--->  Patching install.sh: s,@FC@,/opt/local/bin/gfortran-mp-12,
--->  Patching install.sh: s,@PREFIX@,/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_fpm/fpm/work/fpm-0.9.0/opt/local,
--->  Configuring fpm
--->  Building fpm
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_fpm/fpm/work/fpm-0.9.0" && FPM_CFLAGS="-Os -arch ppc" FPM_LDFLAGS="-L/opt/local/lib -Wl,-headerpad_max_install_names -arch ppc" /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_fpm/fpm/work/fpm-0.9.0/install.sh 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 25966    0 25966    0     0  45849      0 --:--:-- --:--:-- --:--:-- 45876
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 1338k  100 1338k    0     0   870k      0  0:00:01  0:00:01 --:--:-- 11.4M
fpm.F90:12882:21:

12882 |    use, intrinsic :: ieee_arithmetic, only : ieee_value, &
      |                     1
Fatal Error: Cannot find an intrinsic module named 'ieee_arithmetic' at (1)
compilation terminated.

Once built (using gcc12 with ieee_arithmetic), case of issue #850 remains broken. So no change, unless I did something wrong (I used your patches upon 0.9.0).

@perazz
Copy link
Contributor Author

perazz commented Jun 10, 2023

Too bad @barracuda156. It really does seem like issue #850 is not easy to solve,see for example:
https://github.com/freebsd/freebsd-ports/blob/9471f544b9ed3d990a955b1dbd17cb1b7fdcb749/science/dftbplus/Makefile#L13

as the request for ieee_arithmetic is not in the fpm codebase but in one of its dependencies.

@barracuda156
Copy link
Contributor

@perazz Well, let’s see, maybe I get ieee_arithmetic into GCC upstream soon. Need to fix some tests.

@perazz
Copy link
Contributor Author

perazz commented Jun 11, 2023

That would be great @barracuda156. Meanwhile I think I can merge this PR soon, if there are no further comments.

@perazz
Copy link
Contributor Author

perazz commented Jun 14, 2023

Thank you all, I think this is ready to be merged.

@perazz perazz merged commit c020044 into fortran-lang:main Jun 14, 2023
@perazz perazz deleted the nonintrinsic_parse branch June 14, 2023 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants