about summary refs log tree commit diff
path: root/third_party/nix/src/libexpr/eval.hh
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2020-08-02T22·54+0100
committertazjin <mail@tazj.in>2020-08-03T08·38+0000
commit46c78aa0f9e843554079f59bd104e6376a8c9141 (patch)
treee6a9fe4c968dfb19740f02a5c0b2fc7dec87e166 /third_party/nix/src/libexpr/eval.hh
parent6e04b235069e1f4f22218d0a56e452ce36cceff0 (diff)
refactor(3p/nix): Only initialise garbage-collector where needed r/1557
Only libexpr depends on the garbage collector, specifically only
instantiations of EvalState actually require the GC to be initialised.

Rather than always starting it for the whole program, even if it is
not needed, this change moves the GC initialisation into libexpr,
guarded by absl::call_once.

This should make it possible to run the nix daemon without the garbage
collector interfering, granted that things are correcty separated and
the daemon does not actually invoke the evaluator.

Based on my investigation so far, the daemon logic itself does not
require libexpr to be present at all - so I think it is safe - but the
current monobinary might have some tricks up its sleeve that will
cause problems for us. We can deal with those if they arise.

Relates to https://b.tvl.fyi/issues/30

Change-Id: I61c745f96420c02e089bd3c362ac3ccb117d3073
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1584
Tested-by: BuildkiteCI
Reviewed-by: edef <edef@edef.eu>
Reviewed-by: kanepyork <rikingcoding@gmail.com>
Diffstat (limited to 'third_party/nix/src/libexpr/eval.hh')
-rw-r--r--third_party/nix/src/libexpr/eval.hh10
1 files changed, 7 insertions, 3 deletions
diff --git a/third_party/nix/src/libexpr/eval.hh b/third_party/nix/src/libexpr/eval.hh
index 2c285ed5c111..e08ec04ef598 100644
--- a/third_party/nix/src/libexpr/eval.hh
+++ b/third_party/nix/src/libexpr/eval.hh
@@ -16,6 +16,13 @@
 #include "libutil/hash.hh"
 
 namespace nix {
+namespace expr {
+
+// Initialise the Boehm GC once per program instance. This should be
+// called in places that require the garbage collector.
+void InitGC();
+
+}  // namespace expr
 
 class Store;
 class EvalState;
@@ -59,9 +66,6 @@ std::ostream& operator<<(std::ostream& str, const Value& v);
 typedef std::pair<std::string, std::string> SearchPathElem;
 typedef std::list<SearchPathElem> SearchPath;
 
-/* Initialise the Boehm GC, if applicable. */
-void initGC();
-
 typedef std::map<Path, Expr*, std::less<Path>,
                  traceable_allocator<std::pair<const Path, Expr*>>>
     FileParseCache;