Skip to content
← Back

src/driver/compiler_environment.ghul

1
namespace Driver is
2
// Every environment variable the compiler reads, including any flag for
3
// an experiment, is declared here and read through this class, because
4
// System.Environment is not available on the wasm and llvm targets and
5
// Ghul.Environment is the mechanism that works on all three. Nothing
6
// else in src/ reads the environment.
7
8
/// The process environment as the compiler reads it: one accessor for
9
/// each environment variable it consults, and the process's own exit
10
/// and path.
11
class COMPILER_ENVIRONMENT is
12
_environment: Ghul.Environment static => Ghul.ENVIRONMENT.instance
13
14
_get(name: string) -> string? static => _environment[name]
15
16
/// Ends the process with `code` as its exit status.
17
///
18
/// - code: the exit status
19
exit(code: int) static is
20
_environment.exit(code)
21
si
22
23
/// The path of the running executable, or null where it is not
24
/// known.
25
process_path: string? static => _environment.process_path
26
27
/// `PATH`: where an executable is searched for.
28
path: string? static => _get("PATH")
29
30
/// `DOTNET_ROOT`: where the .NET SDK is installed, where it is set.
31
dotnet_root: string? static => _get("DOTNET_ROOT")
32
33
/// `GHUL_LLVM`: the ghul-llvm executable to link with, where it is
34
/// set.
35
llvm_linker: string? static => _get("GHUL_LLVM")
36
37
/// `GHUL_LLVM_RUNTIME`: a directory ghul-llvm searches for libraries
38
/// first, where it is set.
39
llvm_runtime: string? static => _get("GHUL_LLVM_RUNTIME")
40
41
/// `GHUL_PURE_SLOT_TRACE`: trace the pure-slot check.
42
pure_slot_trace: bool static => _get("GHUL_PURE_SLOT_TRACE")?
43
44
/// `GHUL_NARROWING_STUDY`: where to write the narrowing study, where
45
/// it is set.
46
narrowing_study: string? static => _get("GHUL_NARROWING_STUDY")
47
48
/// `GHUL_TRACE_INFERENCE`: what to trace inference for, where it is
49
/// set.
50
trace_inference: string? static => _get("GHUL_TRACE_INFERENCE")
51
52
/// `GHUL_PIPE_FUSION_STUDY`: where to write the pipe fusion study,
53
/// where it is set.
54
pipe_fusion_study: string? static => _get("GHUL_PIPE_FUSION_STUDY")
55
56
/// `GHUL_EFFECTS_TIMING`: time the effect analyses.
57
effects_timing: bool static => _get("GHUL_EFFECTS_TIMING")?
58
59
/// `GHUL_EFFECTS_VERIFY`: check a seeded store-free solve against an
60
/// unseeded one.
61
effects_verify: bool static => _get("GHUL_EFFECTS_VERIFY")?
62
63
/// `GHUL_EMIT_TRACE`: name each function as its body is emitted.
64
emit_trace: bool static => _get("GHUL_EMIT_TRACE")?
65
66
/// `GHUL_CROSSING_TRACE`: trace the crossings at locations containing
67
/// this text, where it is set.
68
crossing_trace: string? static => _get("GHUL_CROSSING_TRACE")
69
70
/// `GHUL_RETRY_STATS`: count compile-expressions retries.
71
retry_stats: bool static => _get("GHUL_RETRY_STATS")?
72
73
/// `GHUL_RETRY_STATS_LOG`: where to write the retry counts, where it
74
/// is set.
75
retry_stats_log: string? static => _get("GHUL_RETRY_STATS_LOG")
76
77
/// `GHUL_NO_ITERATION_CLEAR`: keep compile state between
78
/// compile-expressions iterations.
79
no_iteration_clear: bool static => _get("GHUL_NO_ITERATION_CLEAR")?
80
81
/// `GHUL_FUSION_LATE_DECLINE`: report each fused pipe stage restored
82
/// after a late decline.
83
fusion_late_decline: bool static => _get("GHUL_FUSION_LATE_DECLINE")?
84
85
/// `GHUL_SOLVE_FILEWISE`: re-walk whole files rather than single
86
/// bodies when the effect solve needs another round.
87
solve_filewise: bool static => _get("GHUL_SOLVE_FILEWISE")?
88
89
/// `GHUL_KILL_DUMP`: where to write the narrowing kills, where it is
90
/// set.
91
kill_dump: string? static => _get("GHUL_KILL_DUMP")
92
si
93
si