Skip to content

Ensure transitive dependencies for headers and libraries are always available#5143

Open
ocaisa wants to merge 9 commits intoeasybuilders:developfrom
ocaisa:search_paths_headers
Open

Ensure transitive dependencies for headers and libraries are always available#5143
ocaisa wants to merge 9 commits intoeasybuilders:developfrom
ocaisa:search_paths_headers

Conversation

@ocaisa
Copy link
Copy Markdown
Member

@ocaisa ocaisa commented Mar 9, 2026

This addresses #5124 but is quite a major change even if just a bugfix. I believe that this was probably the original intention when introducing the related options.

Requires additional tests (and probably debating) so leaving as a draft PR for now.

Comment thread easybuild/tools/toolchain/toolchain.py Outdated
# and only use the configured option
# (our RPATH wrappers rely on LIBRARY_PATH so we need an exception for that)
if env_var != 'LIBRARY_PATH':
self.variables.append(env_var, '')
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.

This may seem quite aggressive, but it does seem to work in the cases I tried.

@ocaisa
Copy link
Copy Markdown
Member Author

ocaisa commented Mar 10, 2026

I think this is good enough for a review, it passes existing CI and also fixes #5143

@ocaisa ocaisa marked this pull request as ready for review March 10, 2026 11:46
if env_var != 'LIBRARY_PATH':
self.variables.setdefault(env_var, append_empty=True)
for var in SEARCH_PATH[search_path_var][self.search_path[search_path_var]]:
self.variables.append_subdirs(var, '', subdirs=paths_list)
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.

This looks odd, but the methods available here are limited. My subdirs are full paths relative to ''

@akesandgren
Copy link
Copy Markdown
Contributor

Can't we just clear the relevant env variables at start of eb and then just load modules and "all will be fine"?

@ocaisa
Copy link
Copy Markdown
Member Author

ocaisa commented Mar 11, 2026

Sure, but that is not what we say we support with the option --search-path-cpp-headers. @lexming can correct me, but I thought the intention there was to exclusively use the indicated approach

@lexming
Copy link
Copy Markdown
Contributor

lexming commented Mar 12, 2026

When I worked on --search-path-cpp-headers I didn't change the behaviour of EB at build time in that regard. That option only introduces the possibility to set how those paths are injected in the build environment.

The default behaviour of EB (which has not changed in ages AFAIK):

  • manually inject search paths in direct dependencies with compiler/linker flags, so include folders are always passed with -I flags independently of what modules set
  • the build environment is not reset, any environment variables like CPATH and LIBRARY_PATH will be present in the build environment

Now, I have not yet looked in detail the code in this PR, but it is indeed probably the case that setting --search-path-cpp-headers to an environment variable (instead of flags) is resetting that variable instead of prepending to it.

@boegel
Copy link
Copy Markdown
Member

boegel commented Mar 26, 2026

We should be careful with changing the logic here imho, since I expect it's likely that we would overlook some situations here and introduce regressions.

This effort was triggered by us hitting this bug in EESSI, because we were configuring EasyBuild with $EASYBUILD_MODULE_SEARCH_PATH_HEADERS and $EASYBUILD_SEARCH_PATH_CPP_HEADERS set to include_paths, so $C_INCLUDE_PATH & co are used both in module file and by EasyBuild itself when setting up the build environment.

We revised that:

That effectively defuses the situation in EESSI, which makes me think we should take our time here...

@boegel boegel modified the milestones: next release (5.3.0), 5.x Apr 7, 2026
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.

4 participants