From 46c78aa0f9e843554079f59bd104e6376a8c9141 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sun, 2 Aug 2020 23:54:16 +0100 Subject: refactor(3p/nix): Only initialise garbage-collector where needed 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 Reviewed-by: kanepyork --- third_party/nix/src/tests/attr-set.cc | 2 +- third_party/nix/src/tests/language-tests.cc | 2 +- third_party/nix/src/tests/value-to-json.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'third_party/nix/src/tests') diff --git a/third_party/nix/src/tests/attr-set.cc b/third_party/nix/src/tests/attr-set.cc index e8ad86664b9d..ae323e6bd3d3 100644 --- a/third_party/nix/src/tests/attr-set.cc +++ b/third_party/nix/src/tests/attr-set.cc @@ -115,7 +115,7 @@ class AttrSetTest : public ::testing::Test { protected: EvalState* eval_state_; void SetUp() override { - nix::initGC(); + nix::expr::InitGC(); auto store = std::make_shared(); eval_state_ = new EvalState({"."}, ref(store)); symbol_table = &eval_state_->symbols; diff --git a/third_party/nix/src/tests/language-tests.cc b/third_party/nix/src/tests/language-tests.cc index 9fb453e5e537..af4a7dbfa86f 100644 --- a/third_party/nix/src/tests/language-tests.cc +++ b/third_party/nix/src/tests/language-tests.cc @@ -111,7 +111,7 @@ class NixEnvironment : public testing::Environment { public: void SetUp() override { google::InitGoogleLogging("--logtostderr=false"); - nix::initGC(); + nix::expr::InitGC(); } }; diff --git a/third_party/nix/src/tests/value-to-json.cc b/third_party/nix/src/tests/value-to-json.cc index 573eb658285d..45427425306f 100644 --- a/third_party/nix/src/tests/value-to-json.cc +++ b/third_party/nix/src/tests/value-to-json.cc @@ -12,7 +12,7 @@ class ValueTest : public ::testing::Test { protected: - static void SetUpTestCase() { nix::initGC(); } + static void SetUpTestCase() { nix::expr::InitGC(); } static void TearDownTestCase() {} }; -- cgit 1.4.1