Skip to content

cernlib: fix -fPIC flag for internal lapack, patch for modern gfortran - #5748

Open
nicolamori wants to merge 3 commits into
spack:developfrom
nicolamori:fix_lapack_pic_flag
Open

cernlib: fix -fPIC flag for internal lapack, patch for modern gfortran#5748
nicolamori wants to merge 3 commits into
spack:developfrom
nicolamori:fix_lapack_pic_flag

Conversation

@nicolamori

Copy link
Copy Markdown
Contributor

Set the POSITION_INDEPENDENT_CODE flag to ON unconditionally for shared lib build and depending on CERNLIB_POSITION_INDEPENDENT_CODE for static lib build. This patch inverts the previous behavior and aligns the lapack build settings to those of the other sub-packages.

I found this bug while compiling in an Almalinux 9 container with some external packages (perl, openssl, et al.). From CMakeLists inspection and comparison with other sub-packages (e.g. packlib) it looks like an erroneous switch of the settings for static and shared libraries,

Set the POSITION_INDEPENDENT_CODE flag to ON unconditionally for shared
lib build and depending on CERNLIB_POSITION_INDEPENDENT_CODE for static
lib build. This patch inverts the previous behavior and aligns the
lapack build settings to those of the other sub-packages.
@spackbot-triage spackbot-triage Bot added patch Modifications to packages' sets of defined patches update-package Modifications to packages in the repository labels Jul 25, 2026
@spackbot-triage
spackbot-triage Bot requested a review from andriish July 25, 2026 12:41
@bernhardkaindl
bernhardkaindl requested a review from Copilot July 27, 2026 14:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts how CERNLIB’s internal LAPACK targets set POSITION_INDEPENDENT_CODE so that shared libraries are always built with PIC and static libraries follow the CERNLIB_POSITION_INDEPENDENT_CODE setting, aligning LAPACK with the behavior of other CERNLIB subpackages.

Changes:

  • Add a new Spack patch hook for CERNLIB @2023: to correct LAPACK PIC handling.
  • Introduce fix_lapack_pic_flag.patch to invert the PIC settings between static and shared LAPACK targets.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
repos/spack_repo/builtin/packages/cernlib/package.py Adds application of a new patch for CERNLIB @2023: to fix LAPACK PIC behavior.
repos/spack_repo/builtin/packages/cernlib/fix_lapack_pic_flag.patch Modifies LAPACK’s CMakeLists.txt to set PIC unconditionally for shared targets and conditionally for static targets.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread repos/spack_repo/builtin/packages/cernlib/fix_lapack_pic_flag.patch Outdated
Following the recommendations of the Copilot overview.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@bernhardkaindl

Copy link
Copy Markdown
Contributor

@andriish as you're the maintiner of this package, would you like to review this patch for cernlib 2023 and newer to patch lapack/CMakeLists.txt?

The previous patch for GCC 16 is needed for any modern gfortran version,
since the etime_ symbol seems to have been removed a long time ago given
that it is not present in GCC 11. So patch unconditionally.
@nicolamori nicolamori changed the title cernlib: fix -fPIC flag for internal lapack. cernlib: fix -fPIC flag for internal lapack, patch for modern gfortran Jul 27, 2026
@nicolamori

Copy link
Copy Markdown
Contributor Author

I stumbled upon and fixed another issue. The GCC16 patch introduced in PR 5675 turned out to be necessary also for GCC 11, so now it is applied unconditionally since it is probably needed for any modern GFortran version. I decided to add it to this PR to not open yet another one being this still open.

Sorry for this continuous flow of patches but every time I think I fixed everything something new pops out.

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

Labels

patch Modifications to packages' sets of defined patches update-package Modifications to packages in the repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants