Skip to content

Package.compiler: add support for opt_flags/debug_flags#50126

Merged
alalazo merged 10 commits intospack:developfrom
scheibelp:feature/compiler-adaptor-opt-flags
Apr 24, 2025
Merged

Package.compiler: add support for opt_flags/debug_flags#50126
alalazo merged 10 commits intospack:developfrom
scheibelp:feature/compiler-adaptor-opt-flags

Conversation

@scheibelp
Copy link
Copy Markdown
Member

@scheibelp scheibelp commented Apr 18, 2025

See mfem for an example

opt_flag_found = any(f in self.compiler.opt_flags for f in cxxflags)

this wasn't working, so I added opt_flags to the compiler adaptor. Package.compiler.opt_flags will return the opt_flags for C, C++, or Fortran compiler, the first of whichever is defined (in that order). A test is added for this behavior.

mfem itself is refactored to use spec["cxx"].opt_flags, which is preferred (but the general change above is to support packages in other repos which may not have updated to this form yet).

This also adds a default empty opt_flags/debug_flags to CompilerPackage, so one can ask for Spec["c"].opt_flags regardless of what underlying compiler is in use.

If the package only depends on one language, or uses the same compiler for c/c++, then you can ask for compiler.opt_flags; otherwise you ask for compiler.opt_flags_for_lang(c).

@spackbot-app spackbot-app bot added compilers core PR affects Spack core functionality labels Apr 18, 2025
@spackbot-app spackbot-app bot added build-systems stand-alone-tests Stand-alone (or smoke) tests for installed packages tests General test capability(ies) update-package labels Apr 21, 2025
@scheibelp
Copy link
Copy Markdown
Member Author

Update PR based on discussion (and also updated PR description).

@scheibelp scheibelp requested a review from alalazo April 22, 2025 06:03
Copy link
Copy Markdown
Member

@alalazo alalazo left a comment

Choose a reason for hiding this comment

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

A few minor comments, but essentially LGTM, thanks!

@scheibelp
Copy link
Copy Markdown
Member Author

I followed all requests except for #50126 (comment) (where I explain my reasoning).

I added a docstring to the CompilerAdaptor, and also updated the docs for CompilerPackage.{opt_flags,debug_flags}

@scheibelp scheibelp requested a review from alalazo April 24, 2025 00:18
@alalazo alalazo merged commit a3c430e into spack:develop Apr 24, 2025
36 checks passed
danielsjensen1 added a commit to danielsjensen1/spack that referenced this pull request Apr 26, 2025
* develop: (752 commits)
  mesa: add v23.3.3 and use py-packaging while python>=3.12 (spack#49121)
  gcc: add v15.1.0 (spack#50212)
  draco: add v7.20.0 (spack#49996)
  sgpp: update dependencies and variants (spack#49384)
  input_analysis.py: fix conditional requirements (spack#50194)
  boost: add 1.88.0 (spack#50158)
  mapl: add v2.55.1 (spack#50201)
  mepo: add v2.3.2 (spack#50202)
  py-repligit: add v0.1.1 (spack#50204)
  [package updates] Bump version of cp2k and sirius (spack#50141)
  petsc4py: update ldshared.patch for v3.20.1, and skip for v3.23.1+ (spack#50170)
  namd: add v3.0.1 (spack#50192)
  geomodel: depend on c (spack#49781)
  CompilerAdaptor: add support for opt_flags/debug_flags (spack#50126)
  Add ls alias to spack {compiler, external} (spack#50189)
  covfie: depend on c (spack#50190)
  lua-sol2: add v3.5.0 (spack#49970)
  crtm-fix: fix directory logic (spack#50172)
  py-build: add v1.2.2 (spack#50148)
  py-pillow: fix build (spack#50177)
  ...
teaguesterling pushed a commit to teaguesterling/spack that referenced this pull request May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build-systems compilers core PR affects Spack core functionality stand-alone-tests Stand-alone (or smoke) tests for installed packages tests General test capability(ies) update-package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants