diff --git a/contrib/stack-collapse.py b/contrib/stack-collapse.py index ee77e1589..f5602c95c 100755 --- a/contrib/stack-collapse.py +++ b/contrib/stack-collapse.py @@ -1,12 +1,11 @@ #!/usr/bin/env nix-shell #!nix-shell -i python3 -p python3 --pure -# To be used with `--trace-function-calls` and `-vvvv` and -# `flamegraph.pl`. +# To be used with `--trace-function-calls` and `flamegraph.pl`. # # For example: # -# nix-instantiate --trace-function-calls -vvvv '' -A hello 2> nix-function-calls.trace +# nix-instantiate --trace-function-calls '' -A hello 2> nix-function-calls.trace # ./contrib/stack-collapse.py nix-function-calls.trace > nix-function-calls.folded # nix-shell -p flamegraph --run "flamegraph.pl nix-function-calls.folded > nix-function-calls.svg" diff --git a/doc/manual/expressions/builtins.xml b/doc/manual/expressions/builtins.xml index 9bd86e120..e164d1441 100644 --- a/doc/manual/expressions/builtins.xml +++ b/doc/manual/expressions/builtins.xml @@ -1605,12 +1605,18 @@ stdenv.mkDerivation (rec { builtins.tryEval e - Try to evaluate e. + Try to shallowly evaluate e. Return a set containing the attributes success (true if e evaluated successfully, false if an error was thrown) and value, equalling e - if successful and false otherwise. + if successful and false otherwise. Note that this + doesn't evaluate e deeply, so + let e = { x = throw ""; }; in (builtins.tryEval e).success + will be true. Using builtins.deepSeq + one can get the expected result: let e = { x = throw ""; + }; in (builtins.tryEval (builtins.deepSeq e e)).success will be + false. diff --git a/doc/manual/packages/garbage-collection.xml b/doc/manual/packages/garbage-collection.xml index a1b0ef22a..b506f22b0 100644 --- a/doc/manual/packages/garbage-collection.xml +++ b/doc/manual/packages/garbage-collection.xml @@ -52,12 +52,13 @@ garbage collector as follows: $ nix-store --gc -The behaviour of the gargage collector is affected by the keep- -derivations (default: true) and keep-outputs +The behaviour of the gargage collector is affected by the +keep-derivations (default: true) and keep-outputs (default: false) options in the Nix configuration file. The defaults will ensure -that all derivations that are not build-time dependencies of garbage collector roots -will be collected but that all output paths that are not runtime dependencies -will be collected. (This is usually what you want, but while you are developing +that all derivations that are build-time dependencies of garbage collector roots +will be kept and that all output paths that are runtime dependencies +will be kept as well. All other derivations or paths will be collected. +(This is usually what you want, but while you are developing it may make sense to keep outputs to ensure that rebuild times are quick.) If you are feeling uncertain, you can also first view what files would diff --git a/src/libexpr/function-trace.hh b/src/libexpr/function-trace.hh index 8234b7603..8b0ec848d 100644 --- a/src/libexpr/function-trace.hh +++ b/src/libexpr/function-trace.hh @@ -12,13 +12,13 @@ struct FunctionCallTrace FunctionCallTrace(const Pos & pos) : pos(pos) { auto duration = std::chrono::high_resolution_clock::now().time_since_epoch(); auto ns = std::chrono::duration_cast(duration); - vomit("function-trace entered %1% at %2%", pos, ns.count()); + printMsg(lvlInfo, "function-trace entered %1% at %2%", pos, ns.count()); } ~FunctionCallTrace() { auto duration = std::chrono::high_resolution_clock::now().time_since_epoch(); auto ns = std::chrono::duration_cast(duration); - vomit("function-trace exited %1% at %2%", pos, ns.count()); + printMsg(lvlInfo, "function-trace exited %1% at %2%", pos, ns.count()); } }; } diff --git a/src/libstore/build.cc b/src/libstore/build.cc index 38762ad0d..53e357435 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -2364,7 +2364,7 @@ void DerivationGoal::startBuilder() child = clone(childEntry, stack + stackSize, flags, this); } if (child == -1 && (errno == EPERM || errno == EINVAL)) { - /* Some distros patch Linux to not allow unpriveleged + /* Some distros patch Linux to not allow unprivileged * user namespaces. If we get EPERM or EINVAL, try * without CLONE_NEWUSER and see if that works. */ @@ -2410,8 +2410,7 @@ void DerivationGoal::startBuilder() writeFile("/proc/" + std::to_string(pid) + "/gid_map", (format("%d %d 1") % sandboxGid % hostGid).str()); - /* Signal the builder that we've updated its user - namespace. */ + /* Signal the builder that we've updated its user namespace. */ writeFull(userNamespaceSync.writeSide.get(), "1"); userNamespaceSync.writeSide = -1; diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc index a166f4ee2..7d3da1cc8 100644 --- a/src/libstore/gc.cc +++ b/src/libstore/gc.cc @@ -783,7 +783,11 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results) assertStorePath(i); tryToDelete(state, i); if (state.dead.find(i) == state.dead.end()) - throw Error(format("cannot delete path '%1%' since it is still alive") % i); + throw Error(format( + "cannot delete path '%1%' since it is still alive. " + "To find out why use: " + "nix-store --query --roots" + ) % i); } } else if (options.maxFreed > 0) { diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 89b699414..b7f202a6b 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -198,6 +198,7 @@ void RemoteStore::setOptions(Connection & conn) overrides.erase(settings.maxSilentTime.name); overrides.erase(settings.buildCores.name); overrides.erase(settings.useSubstitutes.name); + overrides.erase(settings.showTrace.name); conn.to << overrides.size(); for (auto & i : overrides) conn.to << i.first << i.second.value; @@ -228,7 +229,7 @@ struct ConnectionHandle ~ConnectionHandle() { - if (!daemonException && std::uncaught_exceptions()) { + if (!daemonException && std::uncaught_exception()) { handle.markBad(); debug("closing daemon connection because of an exception"); } diff --git a/src/libutil/json.hh b/src/libutil/json.hh index 45a22f011..02a39917f 100644 --- a/src/libutil/json.hh +++ b/src/libutil/json.hh @@ -170,7 +170,7 @@ public: ~JSONPlaceholder() { - assert(!first || std::uncaught_exceptions()); + assert(!first || std::uncaught_exception()); } template diff --git a/src/libutil/util.cc b/src/libutil/util.cc index 89a75b3d4..98a7ea397 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -1196,7 +1196,7 @@ void _interrupted() /* Block user interrupts while an exception is being handled. Throwing an exception while another exception is being handled kills the program! */ - if (!interruptThrown && !std::uncaught_exceptions()) { + if (!interruptThrown && !std::uncaught_exception()) { interruptThrown = true; throw Interrupted("interrupted by the user"); } diff --git a/src/nix-build/nix-build.cc b/src/nix-build/nix-build.cc index 605802f72..53a564676 100755 --- a/src/nix-build/nix-build.cc +++ b/src/nix-build/nix-build.cc @@ -282,12 +282,12 @@ static void _main(int argc, char * * argv) absolute = canonPath(absPath(i), true); } catch (Error & e) {}; if (store->isStorePath(absolute) && std::regex_match(absolute, std::regex(".*\\.drv(!.*)?"))) - drvs.push_back(DrvInfo(*state, store, absolute)); - else - /* If we're in a #! script, interpret filenames - relative to the script. */ - exprs.push_back(state->parseExprFromFile(resolveExprPath(state->checkSourcePath(lookupFileArg(*state, - inShebang && !packages ? absPath(i, absPath(dirOf(script))) : i))))); + drvs.push_back(DrvInfo(*state, store, absolute)); + else + /* If we're in a #! script, interpret filenames + relative to the script. */ + exprs.push_back(state->parseExprFromFile(resolveExprPath(state->checkSourcePath(lookupFileArg(*state, + inShebang && !packages ? absPath(i, absPath(dirOf(script))) : i))))); } } diff --git a/tests/function-trace.sh b/tests/function-trace.sh index f7d93b435..182a4d5c2 100755 --- a/tests/function-trace.sh +++ b/tests/function-trace.sh @@ -8,7 +8,6 @@ expect_trace() { actual=$( nix-instantiate \ --trace-function-calls \ - -vvvv \ --expr "$expr" 2>&1 \ | grep "function-trace" \ | sed -e 's/ [0-9]*$//'