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

Address issues with IBM XL builds #621

Merged
merged 3 commits into from
Sep 21, 2021
Merged

Conversation

quellyn
Copy link
Contributor

@quellyn quellyn commented Sep 15, 2021

Description
This PR addresses #606, by adding correct detection for the IBM XL Fortran (xlf) recursive option (-qrecur).

Note that the current logic will test ALL possible recursive flags against a target compiler; in the case of xlf this unexpectedly "succeeds" when the Intel-specific flag -recursive is passed in. Actually it doesn't really succeed, but xlf does not correctly report failure, so cmake CheckFortranCompilerFlag ends up tacking -recursive onto CMAKE_Fortran_FLAGS. The resulting attempt to compile with this bogus flag fails.

You can see the errant compiler behavior with a simple example "Hello World" program:

$ xlf_r -recursive -o hello-dumb hello.f90
** helloworld   === End of Compilation 1 ===
1501-510  Compilation successful for file hello.f90.
ld: cannot find -lgcc_s
ld: cannot find -lgcc_s

$ ls
hello.f90  hello.o

$ file hello.o
hello.o: ELF 64-bit LSB relocatable, 64-bit PowerPC or cisco 7500, version 1 (SYSV), not stripped

The xlf compiler produces an intermediate object code that will not link.

P.S. I've sent this patch to the Spack project. They've accepted it but of course it would be best to implement the fixes upstream.

Checklist

  • The documentation has been updated.
  • If the PR solves a specific issue, it is set to be closed on merge.

Be more explicit about selecting recursive fortran flags, as not
every compiler will correctly reject an incorrect option (e.g., XL).
@codecov
Copy link

codecov bot commented Sep 16, 2021

Codecov Report

Merging #621 (26a81d1) into master (85ef8de) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #621   +/-   ##
=======================================
  Coverage    0.00%    0.00%           
=======================================
  Files        1894     1894           
  Lines      184021   184021           
=======================================
  Misses     184021   184021           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 85ef8de...26a81d1. Read the comment docs.

@quellyn
Copy link
Contributor Author

quellyn commented Sep 17, 2021

I should mention @martin-frbg, who helped me debug this issue.

check_fortran_compiler_flag("-recursive" _recursiveFlag)
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL XL)
check_fortran_compiler_flag("-qrecur" _qrecurFlag)
endif()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it is a good idea to have a non-empty else() for other compiler IDs. I would considers using either:

else()
  check_fortran_compiler_flag("-recursive" _recursiveFlag)
  check_fortran_compiler_flag("-frecursive" _frecursiveFlag)
  check_fortran_compiler_flag("-Mrecursive" _MrecursiveFlag)
  check_fortran_compiler_flag("-qrecur" _qrecurFlag)
endif()

or:

else()
  message( WARNING "Fortran local arrays should be allocated on the stack."
    " Please assure your compiler guarantees that."
    " See https://github.com/Reference-LAPACK/lapack/pull/188 and references therein." )
endif()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good! I like the second choice better; the shotgunning approach didn't work so well with XL ...

Copy link
Collaborator

@weslleyspereira weslleyspereira left a comment

Choose a reason for hiding this comment

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

Thanks!

@langou langou merged commit fe5af11 into Reference-LAPACK:master Sep 21, 2021
mpbelhorn added a commit to mpbelhorn/olcf-spack-environments that referenced this pull request Feb 24, 2022
Unpins netlib-lapack@3.8.0 for builds using the XL toolchain now that
the patch for XL that has been merged into the upstream netlib-lapack
source (Reference-LAPACK/lapack#621) works
successfully.
@julielangou julielangou added this to the LAPACK 3.10.1 milestone Nov 12, 2022
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.

None yet

4 participants