Skip to content

Build environment: add external pkgconfig dirs even when they are system paths#49378

Open
scheibelp wants to merge 2 commits intospack:developfrom
scheibelp:features/externals-and-pkgconfig
Open

Build environment: add external pkgconfig dirs even when they are system paths#49378
scheibelp wants to merge 2 commits intospack:developfrom
scheibelp:features/externals-and-pkgconfig

Conversation

@scheibelp
Copy link
Copy Markdown
Member

Fixes #48293

Spack-built pkgconfig won't search system paths for .pc files, so if there is an external in a system path, spack wasn't adding its associated pkgconfig dir to PKG_CONFIG_PATH.

When an external is a system path, this PR makes it so that spack will add its associated pkgconfig dir if the associated .pc file is found there. If there are no externals in system paths then Spack will not add them to PKG_CONFIG_PATH; even if there are externals in system paths, if their associated .pc files are not found, then Spack will not add those system paths to PKG_CONFIG_PATH.

Packages can define pkg_config_name to help spack find the right .pc file. It defaults to the (lower-cased) name of the package, e.g. zlib.pc for the zlib package.

@spackbot-app spackbot-app bot added build-environment core PR affects Spack core functionality tests General test capability(ies) labels Mar 8, 2025
pcdir = os.path.join(dep.prefix, d, "pkgconfig")
if os.path.isdir(pcdir):
env.prepend_path("PKG_CONFIG_PATH", pcdir)
if not is_system_path(dep.prefix):
Copy link
Copy Markdown
Member

@haampie haampie Mar 8, 2025

Choose a reason for hiding this comment

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

Branch on external / not external; is_system_path is incorrect for spack users on cernvm-fs

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

If a package is external but not in a system path, I want to take this branch, so I could use some more detail to refine this: what happens on cernvm-fs?

Copy link
Copy Markdown
Member

@haampie haampie Mar 17, 2025

Choose a reason for hiding this comment

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

It's not rooted at /. You should let go of the concept of static "system" paths, it does not exist. The only thing that exists is default search paths of certain applications.

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

Labels

build-environment core PR affects Spack core functionality tests General test capability(ies)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Does a spack-built pkg-config work with external packages?

2 participants