@@ -31,8 +31,11 @@ std::string trim_line(std::string s);
3131std::string normalize_driver_output (std::string_view s);
3232
3333std::vector<std::filesystem::path>
34- discover_compiler_runtime_dirs (const std::filesystem::path& compilerBin,
35- std::string_view runtimeBinding = {});
34+ discover_compiler_runtime_dirs (const std::filesystem::path& compilerBin);
35+
36+ std::vector<std::filesystem::path>
37+ discover_compiler_invocation_runtime_dirs (const std::filesystem::path& compilerBin,
38+ std::string_view runtimeBinding);
3639
3740std::vector<std::filesystem::path>
3841discover_link_runtime_dirs (const std::filesystem::path& compilerBin,
@@ -190,8 +193,7 @@ std::string normalize_driver_output(std::string_view s) {
190193}
191194
192195std::vector<std::filesystem::path>
193- discover_compiler_runtime_dirs (const std::filesystem::path& compilerBin,
194- std::string_view runtimeBinding) {
196+ discover_compiler_runtime_dirs (const std::filesystem::path& compilerBin) {
195197 std::vector<std::filesystem::path> dirs;
196198 auto root = compilerBin.parent_path ().parent_path ();
197199
@@ -212,6 +214,14 @@ discover_compiler_runtime_dirs(const std::filesystem::path& compilerBin,
212214 append_existing_unique (dirs, *rt / " lib" );
213215 }
214216
217+ return dirs;
218+ }
219+
220+ std::vector<std::filesystem::path>
221+ discover_compiler_invocation_runtime_dirs (const std::filesystem::path& compilerBin,
222+ std::string_view runtimeBinding) {
223+ auto dirs = discover_compiler_runtime_dirs (compilerBin);
224+
215225 // A managed compiler's DT_RUNPATH reaches its bound private libc for its
216226 // own direct dependencies only. A host /etc/ld.so.preload library can
217227 // require libdl.so.2 itself, where that non-transitive RUNPATH cannot help.
@@ -251,7 +261,8 @@ discover_link_runtime_dirs(const std::filesystem::path& compilerBin,
251261}
252262
253263std::string compiler_env_prefix (const Toolchain& tc) {
254- return env_prefix_for_dirs (tc.compilerRuntimeDirs );
264+ return env_prefix_for_dirs (tc.compilerInvocationRuntimeDirs .empty ()
265+ ? tc.compilerRuntimeDirs : tc.compilerInvocationRuntimeDirs );
255266}
256267
257268std::expected<std::filesystem::path, DetectError>
0 commit comments