diff options
| author | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2024-06-10 03:47:20 -0400 |
|---|---|---|
| committer | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2024-06-10 03:47:20 -0400 |
| commit | ff7fcb6d380d1e45402de2b2e0d2b577ad9f6d59 (patch) | |
| tree | 31cd2f33173e608f8995cc92ac3b29da1240850d /src | |
| parent | 5985c6e3df25dc693a554f824ba3d1d1f3b8086a (diff) | |
Add compilation-related constants
`ODIN_VERSION_HASH` is the `git` SHA hash of the commit the Odin
compiler was built with.
`ODIN_MICROARCH_STRING` is the string passed to `-microarch` when
the program was built.
`ODIN_OPTIMIZATION_MODE` is an enum value of which optimization mode was
used to build the program.
Diffstat (limited to 'src')
| -rw-r--r-- | src/checker.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/checker.cpp b/src/checker.cpp index 8a58bb425..08a03ac62 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -1040,6 +1040,8 @@ gb_internal void init_universal(void) { add_global_enum_constant(fields, "ODIN_ARCH", bc->metrics.arch); add_global_string_constant("ODIN_ARCH_STRING", target_arch_names[bc->metrics.arch]); } + + add_global_string_constant("ODIN_MICROARCH_STRING", bc->microarch); { GlobalEnumValue values[BuildMode_COUNT] = { @@ -1131,6 +1133,17 @@ gb_internal void init_universal(void) { add_global_constant("ODIN_COMPILE_TIMESTAMP", t_untyped_integer, exact_value_i64(odin_compile_timestamp())); { + String version = {}; + + #ifdef GIT_SHA + version.text = cast(u8 *)GIT_SHA; + version.len = gb_strlen(GIT_SHA); + #endif + + add_global_string_constant("ODIN_VERSION_HASH", version); + } + + { bool f16_supported = lb_use_new_pass_system(); if (is_arch_wasm()) { f16_supported = false; @@ -1167,6 +1180,18 @@ gb_internal void init_universal(void) { add_global_constant("ODIN_SANITIZER_FLAGS", named_type, exact_value_u64(bc->sanitizer_flags)); } + { + GlobalEnumValue values[5] = { + {"None", -1}, + {"Minimal", 0}, + {"Size", 1}, + {"Speed", 2}, + {"Aggressive", 3}, + }; + + auto fields = add_global_enum_type(str_lit("Odin_Optimization_Mode"), values, gb_count_of(values)); + add_global_enum_constant(fields, "ODIN_OPTIMIZATION_MODE", bc->optimization_level); + } // Builtin Procedures |