at master 1.4 kB view raw
1diff --git a/libbuild2/cc/common.cxx b/libbuild2/cc/common.cxx 2index f848003c..0f14f9a5 100644 3--- a/libbuild2/cc/common.cxx 4+++ b/libbuild2/cc/common.cxx 5@@ -966,6 +966,17 @@ namespace build2 6 void 7 msvc_extract_library_search_dirs (const strings&, dir_paths&); // msvc.cxx 8 9+ static strings split (const string& s, const char delim) { 10+ stringstream ss (s); 11+ string item; 12+ strings result; 13+ 14+ while (getline (ss, item, delim)) { 15+ result.push_back (item); 16+ } 17+ return result; 18+ } 19+ 20 dir_paths common:: 21 extract_library_search_dirs (const scope& bs) const 22 { 23@@ -987,8 +998,19 @@ namespace build2 24 msvc_extract_library_search_dirs (v, r); 25 else 26 gcc_extract_library_search_dirs (v, r); 27+ 28 }; 29 30+ // NIX_LDFLAGS are implicitly used when linking, 31+ // so its -L flags effectively specify system dirs. 32+ // However, they are only enabled when actually linking and are thus 33+ // not detected by build2, so we need to manually pick them up here. 34+ if (auto s = getenv ("NIX_LDFLAGS")) { 35+ // TODO: do we need more robust args splitting here? e.g. shlex.split 36+ auto args = split (s.value (), ' '); 37+ gcc_extract_library_search_dirs (args, r); 38+ } 39+ 40 // Note that the compiler mode options are in sys_lib_dirs. 41 // 42 if (auto l = bs[c_loptions]) extract (*l, c_loptions);