refactor(tvix): Replace several DiscardLogsSink() with std::cerr
Introduces the actual log sink in several places where we actually want the build logs to thread through correctly. This should cover *most* build paths. Change-Id: I735dff8a79f7e35a5874eb89b4abb980f9703dc2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1827 Reviewed-by: glittershark <grfn@gws.fyi> Tested-by: BuildkiteCI
This commit is contained in:
		
							parent
							
								
									262af89f81
								
							
						
					
					
						commit
						06681c35a9
					
				
					 7 changed files with 15 additions and 24 deletions
				
			
		
							
								
								
									
										7
									
								
								third_party/nix/src/libexpr/primops.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								third_party/nix/src/libexpr/primops.cc
									
										
									
									
										vendored
									
									
								
							|  | @ -2,6 +2,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <algorithm> | #include <algorithm> | ||||||
| #include <cstring> | #include <cstring> | ||||||
|  | #include <iostream> | ||||||
| #include <regex> | #include <regex> | ||||||
| 
 | 
 | ||||||
| #include <absl/strings/str_split.h> | #include <absl/strings/str_split.h> | ||||||
|  | @ -92,11 +93,7 @@ void EvalState::realiseContext(const PathSet& context) { | ||||||
|   store->queryMissing(drvs, willBuild, willSubstitute, unknown, downloadSize, |   store->queryMissing(drvs, willBuild, willSubstitute, unknown, downloadSize, | ||||||
|                       narSize); |                       narSize); | ||||||
| 
 | 
 | ||||||
|   // TODO(tazjin): Figure out where these logs are supposed to go ...
 |   nix::util::OkOrThrow(store->buildPaths(std::cerr, drvs)); | ||||||
|   // unless we keep a per-store stream open persistently there's no
 |  | ||||||
|   // "generic" way to send logs anywhere for cases like this (IFD).
 |  | ||||||
|   auto discard_logs = DiscardLogsSink(); |  | ||||||
|   nix::util::OkOrThrow(store->buildPaths(discard_logs, drvs)); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* Load and evaluate an expression from path specified by the
 | /* Load and evaluate an expression from path specified by the
 | ||||||
|  |  | ||||||
							
								
								
									
										2
									
								
								third_party/nix/src/libexpr/primops.hh
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								third_party/nix/src/libexpr/primops.hh
									
										
									
									
										vendored
									
									
								
							|  | @ -6,7 +6,7 @@ | ||||||
| namespace nix { | namespace nix { | ||||||
| 
 | 
 | ||||||
| struct RegisterPrimOp { | struct RegisterPrimOp { | ||||||
|   typedef std::vector<std::tuple<std::string, size_t, PrimOpFun>> PrimOps; |   using PrimOps = std::vector<std::tuple<std::string, size_t, PrimOpFun> >; | ||||||
|   static PrimOps* primOps; |   static PrimOps* primOps; | ||||||
|   /* You can register a constant by passing an arity of 0. fun
 |   /* You can register a constant by passing an arity of 0. fun
 | ||||||
|      will get called during EvalState initialization, so there |      will get called during EvalState initialization, so there | ||||||
|  |  | ||||||
							
								
								
									
										3
									
								
								third_party/nix/src/nix-build/nix-build.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								third_party/nix/src/nix-build/nix-build.cc
									
										
									
									
										vendored
									
									
								
							|  | @ -359,8 +359,7 @@ static void _main(int argc, char** argv) { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (!dryRun) { |     if (!dryRun) { | ||||||
|       auto discard_logs = DiscardLogsSink(); |       util::OkOrThrow(store->buildPaths(std::cerr, paths, buildMode)); | ||||||
|       util::OkOrThrow(store->buildPaths(discard_logs, paths, buildMode)); |  | ||||||
|     } |     } | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										4
									
								
								third_party/nix/src/nix-env/nix-env.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								third_party/nix/src/nix-env/nix-env.cc
									
										
									
									
										vendored
									
									
								
							|  | @ -722,10 +722,8 @@ static void opSet(Globals& globals, Strings opFlags, Strings opArgs) { | ||||||
|     if (globals.dryRun) { |     if (globals.dryRun) { | ||||||
|       return; |       return; | ||||||
|     } |     } | ||||||
|     auto discard_logs = DiscardLogsSink(); |  | ||||||
|     nix::util::OkOrThrow(globals.state->store->buildPaths( |     nix::util::OkOrThrow(globals.state->store->buildPaths( | ||||||
|         discard_logs, paths, |         std::cerr, paths, globals.state->repair != 0u ? bmRepair : bmNormal)); | ||||||
|         globals.state->repair != 0u ? bmRepair : bmNormal)); |  | ||||||
|   } else { |   } else { | ||||||
|     printMissing(globals.state->store, {drv.queryOutPath()}); |     printMissing(globals.state->store, {drv.queryOutPath()}); | ||||||
|     if (globals.dryRun) { |     if (globals.dryRun) { | ||||||
|  |  | ||||||
							
								
								
									
										7
									
								
								third_party/nix/src/nix-env/user-env.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								third_party/nix/src/nix-env/user-env.cc
									
										
									
									
										vendored
									
									
								
							|  | @ -1,5 +1,7 @@ | ||||||
| #include "nix-env/user-env.hh" | #include "nix-env/user-env.hh" | ||||||
| 
 | 
 | ||||||
|  | #include <iostream> | ||||||
|  | 
 | ||||||
| #include <glog/logging.h> | #include <glog/logging.h> | ||||||
| 
 | 
 | ||||||
| #include "libexpr/eval-inline.hh" | #include "libexpr/eval-inline.hh" | ||||||
|  | @ -38,9 +40,8 @@ bool createUserEnv(EvalState& state, DrvInfos& elems, const Path& profile, | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   DLOG(INFO) << "building user environment dependencies"; |   DLOG(INFO) << "building user environment dependencies"; | ||||||
|   auto discard_logs = DiscardLogsSink(); |  | ||||||
|   util::OkOrThrow(state.store->buildPaths( |   util::OkOrThrow(state.store->buildPaths( | ||||||
|       discard_logs, drvsToBuild, state.repair != 0u ? bmRepair : bmNormal)); |       std::cerr, drvsToBuild, state.repair != 0u ? bmRepair : bmNormal)); | ||||||
| 
 | 
 | ||||||
|   /* Construct the whole top level derivation. */ |   /* Construct the whole top level derivation. */ | ||||||
|   PathSet references; |   PathSet references; | ||||||
|  | @ -140,7 +141,7 @@ bool createUserEnv(EvalState& state, DrvInfos& elems, const Path& profile, | ||||||
|   /* Realise the resulting store expression. */ |   /* Realise the resulting store expression. */ | ||||||
|   DLOG(INFO) << "building user environment"; |   DLOG(INFO) << "building user environment"; | ||||||
|   util::OkOrThrow(state.store->buildPaths( |   util::OkOrThrow(state.store->buildPaths( | ||||||
|       discard_logs, {topLevelDrv}, state.repair != 0u ? bmRepair : bmNormal)); |       std::cerr, {topLevelDrv}, state.repair != 0u ? bmRepair : bmNormal)); | ||||||
| 
 | 
 | ||||||
|   /* Switch the current user environment to the output path. */ |   /* Switch the current user environment to the output path. */ | ||||||
|   auto store2 = state.store.dynamic_pointer_cast<LocalFSStore>(); |   auto store2 = state.store.dynamic_pointer_cast<LocalFSStore>(); | ||||||
|  |  | ||||||
							
								
								
									
										12
									
								
								third_party/nix/src/nix-store/nix-store.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								third_party/nix/src/nix-store/nix-store.cc
									
										
									
									
										vendored
									
									
								
							|  | @ -69,8 +69,7 @@ static PathSet realisePath(Path path, bool build = true) { | ||||||
| 
 | 
 | ||||||
|   if (isDerivation(p.first)) { |   if (isDerivation(p.first)) { | ||||||
|     if (build) { |     if (build) { | ||||||
|       auto discard_logs = DiscardLogsSink(); |       util::OkOrThrow(store->buildPaths(std::cerr, {path})); | ||||||
|       util::OkOrThrow(store->buildPaths(discard_logs, {path})); |  | ||||||
|     } |     } | ||||||
|     Derivation drv = store->derivationFromPath(p.first); |     Derivation drv = store->derivationFromPath(p.first); | ||||||
|     rootNr++; |     rootNr++; | ||||||
|  | @ -186,9 +185,8 @@ static void opRealise(Strings opFlags, Strings opArgs) { | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   /* Build all paths at the same time to exploit parallelism. */ |   /* Build all paths at the same time to exploit parallelism. */ | ||||||
|   auto discard_logs = DiscardLogsSink(); |  | ||||||
|   util::OkOrThrow(store->buildPaths( |   util::OkOrThrow(store->buildPaths( | ||||||
|       discard_logs, PathSet(paths.begin(), paths.end()), buildMode)); |       std::cerr, PathSet(paths.begin(), paths.end()), buildMode)); | ||||||
| 
 | 
 | ||||||
|   if (!ignoreUnknown) { |   if (!ignoreUnknown) { | ||||||
|     for (auto& i : paths) { |     for (auto& i : paths) { | ||||||
|  | @ -1006,8 +1004,7 @@ static void opServe(Strings opFlags, Strings opArgs) { | ||||||
|              does one path at a time. */ |              does one path at a time. */ | ||||||
|           if (!willSubstitute.empty()) { |           if (!willSubstitute.empty()) { | ||||||
|             try { |             try { | ||||||
|               auto discard_logs = DiscardLogsSink(); |               util::OkOrThrow(store->buildPaths(std::cerr, willSubstitute)); | ||||||
|               util::OkOrThrow(store->buildPaths(discard_logs, willSubstitute)); |  | ||||||
|             } catch (Error& e) { |             } catch (Error& e) { | ||||||
|               LOG(WARNING) << e.msg(); |               LOG(WARNING) << e.msg(); | ||||||
|             } |             } | ||||||
|  | @ -1069,8 +1066,7 @@ static void opServe(Strings opFlags, Strings opArgs) { | ||||||
| 
 | 
 | ||||||
|         try { |         try { | ||||||
|           MonitorFdHup monitor(in.fd); |           MonitorFdHup monitor(in.fd); | ||||||
|           auto discard_logs = DiscardLogsSink(); |           util::OkOrThrow(store->buildPaths(std::cerr, paths)); | ||||||
|           util::OkOrThrow(store->buildPaths(discard_logs, paths)); |  | ||||||
|           out << 0; |           out << 0; | ||||||
|         } catch (Error& e) { |         } catch (Error& e) { | ||||||
|           assert(e.status); |           assert(e.status); | ||||||
|  |  | ||||||
							
								
								
									
										4
									
								
								third_party/nix/src/nix/installables.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								third_party/nix/src/nix/installables.cc
									
										
									
									
										vendored
									
									
								
							|  | @ -1,3 +1,4 @@ | ||||||
|  | #include <iostream> | ||||||
| #include <regex> | #include <regex> | ||||||
| #include <utility> | #include <utility> | ||||||
| 
 | 
 | ||||||
|  | @ -274,8 +275,7 @@ Buildables build( | ||||||
|   if (mode == DryRun) { |   if (mode == DryRun) { | ||||||
|     printMissing(store, pathsToBuild); |     printMissing(store, pathsToBuild); | ||||||
|   } else if (mode == Build) { |   } else if (mode == Build) { | ||||||
|     auto discard_logs = DiscardLogsSink(); |     util::OkOrThrow(store->buildPaths(std::cerr, pathsToBuild)); | ||||||
|     util::OkOrThrow(store->buildPaths(discard_logs, pathsToBuild)); |  | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   return buildables; |   return buildables; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue