|
97 | 97 | ] |
98 | 98 | # modes to handle CPP header search paths |
99 | 99 | # see: https://gcc.gnu.org/onlinedocs/cpp/Environment-Variables.html |
| 100 | +# supported on Linux by: GCC, GFortran, oneAPI C/C++ Compilers, oneAPI Fortran Compiler |
100 | 101 | SEARCH_PATH_CPP_HEADERS_FLAGS = "CPPFLAGS" |
101 | 102 | SEARCH_PATH_CPP_HEADERS_CPATH = "CPATH" |
102 | 103 | SEARCH_PATH_CPP_HEADERS_INCLUDE = "INCLUDE_PATHS" |
|
107 | 108 | } |
108 | 109 | DEFAULT_SEARCH_PATH_CPP_HEADERS = SEARCH_PATH_CPP_HEADERS_FLAGS |
109 | 110 |
|
| 111 | +# modes to handle linker search paths |
| 112 | +# see: https://gcc.gnu.org/onlinedocs/cpp/Environment-Variables.html |
| 113 | +# supported on Linux by: GCC, GFortran, oneAPI C/C++ Compilers, oneAPI Fortran Compiler |
| 114 | +SEARCH_PATH_LINKER_FLAGS = "LDFLAGS" |
| 115 | +SEARCH_PATH_LINKER_LIBPATH = "LIBRARY_PATH" |
| 116 | +SEARCH_PATH_LINKER = { |
| 117 | + SEARCH_PATH_LINKER_FLAGS: ["LDFLAGS"], |
| 118 | + SEARCH_PATH_LINKER_LIBPATH: ["LIBRARY_PATH"], |
| 119 | +} |
| 120 | +DEFAULT_SEARCH_PATH_LINKER = SEARCH_PATH_LINKER_FLAGS |
110 | 121 |
|
111 | 122 | def is_system_toolchain(tc_name): |
112 | 123 | """Return whether toolchain with specified name is a system toolchain or not.""" |
@@ -1122,9 +1133,26 @@ def _add_dependency_linker_paths(self, dep_root, extra_dirs=None): |
1122 | 1133 | lib_dirs = ["lib64", "lib"] |
1123 | 1134 | lib_dirs = unique_ordered_extend(lib_dirs, extra_dirs) |
1124 | 1135 |
|
1125 | | - env_var = "LDFLAGS" |
1126 | | - self.log.debug("Adding lib paths to toolchain variable '%s': %s", env_var, dep_root) |
1127 | | - self.variables.append_subdirs(env_var, dep_root, subdirs=lib_dirs) |
| 1136 | + # mode of operation is defined by search-path-linker option |
| 1137 | + # toolchain option has precedence over build option |
| 1138 | + linker_mode = DEFAULT_SEARCH_PATH_LINKER |
| 1139 | + build_opt = build_option("search_path_linker") |
| 1140 | + if self.options.get("search-path-linker") is not None: |
| 1141 | + linker_mode = self.options.option("search-path-linker") |
| 1142 | + self.log.debug("search-path-linker set by toolchain option: %s", linker_mode) |
| 1143 | + elif build_opt is not None: |
| 1144 | + linker_mode = build_opt |
| 1145 | + self.log.debug("search-path-linker set by build option: %s", linker_mode) |
| 1146 | + |
| 1147 | + if linker_mode not in SEARCH_PATH_LINKER: |
| 1148 | + raise EasyBuildError( |
| 1149 | + "Unknown value selected for option search-path-linker: %s. Choose one of: %s", |
| 1150 | + linker_mode, ", ".join(SEARCH_PATH_LINKER) |
| 1151 | + ) |
| 1152 | + |
| 1153 | + for env_var in SEARCH_PATH_LINKER[linker_mode]: |
| 1154 | + self.log.debug("Adding lib paths to toolchain variable '%s': %s", env_var, dep_root) |
| 1155 | + self.variables.append_subdirs(env_var, dep_root, subdirs=lib_dirs) |
1128 | 1156 |
|
1129 | 1157 | def _setenv_variables(self, donotset=None, verbose=True): |
1130 | 1158 | """Actually set the environment variables""" |
|
0 commit comments