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

Fix CMake Compiler Flag Summary: ID Regex Matching #4272

Open
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

nmnobre
Copy link
Contributor

@nmnobre nmnobre commented Dec 18, 2024

Fixes #2978.

Summary

To understand what I'm trying to fix here, first note:

target_compile_options( Flags_CXX
INTERFACE
$<${_cxx_gnu_dbg}:-O0 -ggdb -Wall -Wno-sign-compare -Wno-unused-but-set-variable -Werror=return-type>
# $<$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,5.0>:-Wnull-dereference>
$<${_cxx_gnu_rwdbg}:-Werror=return-type>
$<${_cxx_gnu_rel}:-Werror=return-type>
$<${_cxx_intel_dbg}:-O0 -traceback -Wcheck>
$<${_cxx_intel_rwdbg}:-ip -qopt-report=5 -qopt-report-phase=vec>
$<${_cxx_intel_rel}:-ip -qopt-report=5 -qopt-report-phase=vec>
$<${_cxx_pgi_dbg}:-O0 -Mbounds>
$<${_cxx_pgi_rwdbg}:-gopt -fast>
$<${_cxx_pgi_rel}:-gopt -fast>
$<${_cxx_cray_dbg}:-O0>
$<${_cxx_cray_rwdbg}:>
$<${_cxx_cray_rel}:>
$<${_cxx_clang_dbg}:-O0 -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable>
$<${_cxx_clang_rwdbg}:>
$<${_cxx_clang_rel}:>
$<${_cxx_appleclang_dbg}:-O0 -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable>
$<${_cxx_appleclang_rwdbg}:>
$<${_cxx_appleclang_rel}:>
$<${_cxx_intelllvm_dbg}:-O0 -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable>
$<${_cxx_intelllvm_rwdbg}:-gline-tables-only -fdebug-info-for-profiling> # recommended by Intel VTune
$<${_cxx_intelllvm_rel}:>
)

Then, with Intel's classic compilers, configure AMReX with -DCMAKE_BUILD_TYPE=Debug and note the C++ flags listed under "AMReX configuration summary", before and after the changes suggested here. The gist is Intel as a compiler id was matching IntelLLVM (and Clang was also matching AppleClang though the flags in that case are the same, so it's harder to tell).
EDIT: this actually only affects what's printed in the summary, the flags that are actually used are already correct!

The proposed changes:

  • fix a bug or incorrect behavior in AMReX
  • add new capabilities to AMReX
  • changes answers in the test suite to more than roundoff level
  • are likely to significantly affect the results of downstream AMReX users
  • include documentation in the code and/or rst files, if appropriate

@nmnobre nmnobre mentioned this pull request Dec 18, 2024
@ax3l ax3l added the install label Jan 6, 2025
@ax3l ax3l requested review from ax3l and WeiqunZhang January 6, 2025 18:58
@ax3l ax3l added the bug label Jan 6, 2025
@@ -279,7 +279,7 @@ function ( eval_genex _list _lang _comp )
string(REGEX REPLACE "\\$<PLATFORM_ID:[A-Za-z]*>" "0" _in "${_in}")

# Genex in the form $<*_COMPILER_ID:compiler_ids>
string(REGEX REPLACE "\\$<${_lang}_COMPILER_ID:[^>]*${_comp}[^>]*>" "1" _in "${_in}")
string(REGEX REPLACE "\\$<${_lang}_COMPILER_ID[^>]*[:,]${_comp}[>,]" "1" _in "${_in}")
Copy link
Member

Choose a reason for hiding this comment

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

Can you help me understand what the change in regex does for each part?

  • Does [:,] now match a literal : or ,?
  • Does [>,] now match a literal > or ,?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • Does [:,] now match a literal : or ,?
  • Does [>,] now match a literal > or ,?

Yes to both, the idea is that we will now exactly (without prefixes or suffixes) match ${_comp} because it must be surrounded by commas (if it's in the middle of the list) or immediately follow the colon at the beginning of the list or immediately precede the chevron at the end of the list.

Copy link
Member

Choose a reason for hiding this comment

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

It would also match $<CXX_COMPILER_ID,someid>, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, but that's illegal CMake syntax and will cause CMake to complain with "Expression did not evaluate to a known generator expression" or "Expression syntax not recognized."

@ax3l ax3l changed the title Fix compiler ids regex matching Fix CMake Compiler Flag Summary: ID Regex Matching Jan 6, 2025
Copy link
Member

@ax3l ax3l left a comment

Choose a reason for hiding this comment

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

LGTM, more robust 👍

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

Successfully merging this pull request may close these issues.

CMake build system
3 participants