aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/bin/guess.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-04-07 11:33:05 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-04-07 11:43:04 +0200
commite9f69e067da3e096e1e64be70ec2b6de30f71d2c (patch)
tree478c9f0ec86a225398424bcc9305270ca6800339 /libbuild2/bin/guess.cxx
parent5e51d523e71231cb190e9ed981962df527f4ee7e (diff)
Register environment variables for hermetic build configurations
Diffstat (limited to 'libbuild2/bin/guess.cxx')
-rw-r--r--libbuild2/bin/guess.cxx51
1 files changed, 48 insertions, 3 deletions
diff --git a/libbuild2/bin/guess.cxx b/libbuild2/bin/guess.cxx
index 9f15030..219b8e8 100644
--- a/libbuild2/bin/guess.cxx
+++ b/libbuild2/bin/guess.cxx
@@ -326,6 +326,9 @@ namespace build2
fail << "unable to guess " << *rl << " signature";
}
+ // None of the ar/ranlib implementations we recognize seem to use
+ // environment variables (not even Microsoft lib.exe).
+ //
return ar_cache.insert (move (key),
ar_info {
move (arp),
@@ -333,13 +336,39 @@ namespace build2
move (arr.signature),
move (arr.checksum),
move (*arr.version),
+ nullptr,
move (rlp),
move (rlr.id),
move (rlr.signature),
- move (rlr.checksum)});
+ move (rlr.checksum),
+ nullptr});
}
+ // Linker environment variables (see also the cc module which duplicates
+ // some of these).
+ //
+ // Notes:
+ //
+ // - GNU linkers search in LD_LIBRARY_PATH in addition to LD_RUN_PATH but
+ // we assume the former is part of the built-in list. Interestingly,
+ // LLD does not search in either.
+ //
+ // - The LLD family of linkers have a bunch of undocumented, debugging-
+ // related variables (LLD_REPRODUCE, LLD_VERSION, LLD_IN_TEST) that we
+ // ignore.
+ //
+ // - ld64 uses a ton of environment variables (according to the source
+ // code) but none of them are documented in the man pages. So someone
+ // will need to figure out what's important (some of them are clearly
+ // for debugging of ld itself).
+ //
+ static const char* gnu_ld_env[] = {
+ "LD_RUN_PATH", "GNUTARGET", "LDEMULATION", "COLLECT_NO_DEMANGLE", nullptr};
+
+ static const char* msvc_ld_env[] = {
+ "LIB", "LINK", "_LINK_", nullptr};
+
// Extracting ld information requires running it which can become
// expensive if done repeatedly. So we cache the result.
//
@@ -522,15 +551,26 @@ namespace build2
if (r.empty ())
fail << "unable to guess " << ld << " signature";
+ const char* const* ld_env ((r.id == "gnu" ||
+ r.id == "gnu-gold") ? gnu_ld_env :
+ (r.id == "msvc" ||
+ r.id == "msvc-lld") ? msvc_ld_env :
+ nullptr);
+
return ld_cache.insert (move (key),
ld_info {
move (pp),
move (r.id),
move (r.signature),
move (r.checksum),
- move (r.version)});
+ move (r.version),
+ ld_env});
}
+ // Resource compiler environment variables.
+ //
+ static const char* msvc_rc_env[] = {"INCLUDE", nullptr};
+
// Extracting rc information requires running it which can become
// expensive if done repeatedly. So we cache the result.
//
@@ -632,12 +672,17 @@ namespace build2
if (r.empty ())
fail << "unable to guess " << rc << " signature";
+ const char* const* rc_env ((r.id == "msvc" ||
+ r.id == "msvc-llvm") ? msvc_rc_env :
+ nullptr);
+
return rc_cache.insert (move (key),
rc_info {
move (pp),
move (r.id),
move (r.signature),
- move (r.checksum)});
+ move (r.checksum),
+ rc_env});
}
}
}