Skip to content

Comments

#9676 Follow Up - Make it more resilient to subtle differences in gfortran versions#9682

Merged
Myoldmopar merged 1 commit intoNatLabRockies:developfrom
jmarrec:9303_Fortran_UtilitiesLinking
Sep 30, 2022
Merged

#9676 Follow Up - Make it more resilient to subtle differences in gfortran versions#9682
Myoldmopar merged 1 commit intoNatLabRockies:developfrom
jmarrec:9303_Fortran_UtilitiesLinking

Conversation

@jmarrec
Copy link
Contributor

@jmarrec jmarrec commented Sep 29, 2022

Pull request overview

Pull Request Author

Add to this list or remove from it as applicable. This is a simple templated set of guidelines.

  • Title of PR should be user-synopsis style (clearly understandable in a standalone changelog context)
  • Label the PR with at least one of: Defect, Refactoring, NewFeature, Performance, and/or DoNoPublish
  • Pull requests that impact EnergyPlus code must also include unit tests to cover enhancement or defect repair
  • Author should provide a "walkthrough" of relevant code changes using a GitHub code review comment process
  • If any diffs are expected, author must demonstrate they are justified using plots and descriptions
  • If changes fix a defect, the fix should be demonstrated in plots and descriptions
  • If any defect files are updated to a more recent version, upload new versions here or on DevSupport
  • If IDD requires transition, transition source, rules, ExpandObjects, and IDFs must be updated, and add IDDChange label
  • If structural output changes, add to output rules file and add OutputChange label
  • If adding/removing any LaTeX docs or figures, update that document's CMakeLists file dependencies

Reviewer

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • If branch is behind develop, merge develop and build locally to check for side effects of the merge
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified
  • Check that performance is not impacted (CI Linux results include performance check)
  • Run Unit Test(s) locally
  • Check any new function arguments for performance impacts
  • Verify IDF naming conventions and styles, memos and notes and defaults
  • If new idf included, locally check the err file and other outputs

@jmarrec jmarrec added Defect Includes code to repair a defect in EnergyPlus Developer Issue Related to cmake, packaging, installers, or developer tooling (CI, etc) labels Sep 29, 2022
@jmarrec jmarrec requested a review from Myoldmopar September 29, 2022 19:08
@jmarrec jmarrec self-assigned this Sep 29, 2022
Copy link
Member

@Myoldmopar Myoldmopar left a comment

Choose a reason for hiding this comment

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

This looks great!

check_fortran_compiler_flag(-static-libgfortran HAS_STATIC_LIBGFORTRAN)
check_fortran_compiler_flag(-static-libgcc HAS_STATIC_LIBGCC)
check_fortran_compiler_flag(-static-libquadmath HAS_STATIC_LIBQUADMATH)
message(DEBUG "HAS_STATIC_LIBGFORTRAN=${HAS_STATIC_LIBGFORTRAN}, HAS_STATIC_LIBGCC=${HAS_STATIC_LIBGCC}, HAS_STATIC_LIBQUADMATH=${HAS_STATIC_LIBQUADMATH}")
Copy link
Member

Choose a reason for hiding this comment

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

This is a nice robustness improvement.

list(TRANSFORM CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES REPLACE "quadmath" " ${static-libquadmath}")
message(DEBUG "CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES-${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}")
if (NOT HAS_STATIC_LIBGFORTRAN OR NOT HAS_STATIC_LIBGCC)
message(FATAL_ERROR "Please check your compiler. gfortran supports -static-libgcc and -static-libgfortran since at least 2007, but HAS_STATIC_LIBGFORTRAN=${HAS_STATIC_LIBGFORTRAN}, HAS_STATIC_LIBGCC=${HAS_STATIC_LIBGCC}")
Copy link
Member

Choose a reason for hiding this comment

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

I think this is quite reasonable. And kind wording "Please check your compiler..."

message(FATAL_ERROR "Please check your compiler. gfortran supports -static-libgcc and -static-libgfortran since at least 2007, but HAS_STATIC_LIBGFORTRAN=${HAS_STATIC_LIBGFORTRAN}, HAS_STATIC_LIBGCC=${HAS_STATIC_LIBGCC}")
endif()
if (HAS_STATIC_LIBQUADMATH)
target_link_options(fortran_project_options INTERFACE
Copy link
Member

Choose a reason for hiding this comment

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

So clean in this case.

message(DEBUG "CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES=${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}")
# On brew gcc 12.2.0
# => CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES=gfortran;emutls_w;gcc;quadmath;emutls_w;gcc;gcc
# On https://github.com/fxcoudert/gfortran-for-macOS
Copy link
Member

Choose a reason for hiding this comment

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

I think moving forward we'll just always plan on brewing gcc, but this is good to have documented, thanks.

@Myoldmopar
Copy link
Member

This tests fine locally. I'll go ahead and merge this one in. Thanks @jmarrec

@Myoldmopar Myoldmopar merged commit efba7af into NatLabRockies:develop Sep 30, 2022
@jmarrec jmarrec deleted the 9303_Fortran_UtilitiesLinking branch May 2, 2023 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Defect Includes code to repair a defect in EnergyPlus Developer Issue Related to cmake, packaging, installers, or developer tooling (CI, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants