aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2020-09-15 12:27:53 +0100
committergingerBill <bill@gingerbill.org>2020-09-15 12:27:53 +0100
commitedbad0709efe050441f3bc27fe22a9597b2bae06 (patch)
treec6f2bad57a7cd8deb2403b44d3b9094ee7862073 /src
parentbfc7d74967b0c5b8c2696fdfcb02fe449c9d94ef (diff)
Add -default-to-nil-allocator flag (sets `ODIN_DEFAULT_TO_NIL_ALLOCATOR`)
Diffstat (limited to 'src')
-rw-r--r--src/build_settings.cpp1
-rw-r--r--src/checker.cpp1
-rw-r--r--src/main.cpp12
3 files changed, 12 insertions, 2 deletions
diff --git a/src/build_settings.cpp b/src/build_settings.cpp
index 39deb4063..0d5352347 100644
--- a/src/build_settings.cpp
+++ b/src/build_settings.cpp
@@ -111,6 +111,7 @@ struct BuildContext {
String ODIN_ROOT; // Odin ROOT
bool ODIN_DEBUG; // Odin in debug mode
bool ODIN_DISABLE_ASSERT; // Whether the default 'assert' et al is disabled in code or not
+ bool ODIN_DEFAULT_TO_NIL_ALLOCATOR; // Whether the default allocator is a "nil" allocator or not (i.e. it does nothing)
TargetEndianKind endian_kind;
diff --git a/src/checker.cpp b/src/checker.cpp
index 7659a42ff..5c93e12b6 100644
--- a/src/checker.cpp
+++ b/src/checker.cpp
@@ -739,6 +739,7 @@ void init_universal(void) {
add_global_string_constant(str_lit("ODIN_ROOT"), bc->ODIN_ROOT);
add_global_constant(str_lit("ODIN_DEBUG"), t_untyped_bool, exact_value_bool(bc->ODIN_DEBUG));
add_global_constant(str_lit("ODIN_DISABLE_ASSERT"), t_untyped_bool, exact_value_bool(bc->ODIN_DISABLE_ASSERT));
+ add_global_constant(str_lit("ODIN_DEFAULT_TO_NIL_ALLOCATOR"), t_untyped_bool, exact_value_bool(bc->ODIN_DEFAULT_TO_NIL_ALLOCATOR));
add_global_constant(str_lit("ODIN_USE_LLVM_API"), t_untyped_bool, exact_value_bool(bc->use_llvm_api));
add_global_constant(str_lit("ODIN_NO_DYNAMIC_LITERALS"), t_untyped_bool, exact_value_bool(bc->no_dynamic_literals));
diff --git a/src/main.cpp b/src/main.cpp
index 13d9e53bf..ed90095ef 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -580,6 +580,8 @@ enum BuildFlagKind {
BuildFlag_IgnoreUnknownAttributes,
BuildFlag_ExtraLinkerFlags,
+ BuildFlag_DefaultToNilAllocator,
+
BuildFlag_Compact,
BuildFlag_GlobalDefinitions,
BuildFlag_GoToDefinitions,
@@ -676,6 +678,8 @@ bool parse_build_flags(Array<String> args) {
add_flag(&build_flags, BuildFlag_IgnoreUnknownAttributes, str_lit("ignore-unknown-attributes"), BuildFlagParam_None);
add_flag(&build_flags, BuildFlag_ExtraLinkerFlags, str_lit("extra-linker-flags"), BuildFlagParam_String);
+ add_flag(&build_flags, BuildFlag_DefaultToNilAllocator, str_lit("default-to-nil-allocator"), BuildFlagParam_None);
+
add_flag(&build_flags, BuildFlag_Compact, str_lit("compact"), BuildFlagParam_None);
add_flag(&build_flags, BuildFlag_GlobalDefinitions, str_lit("global-definitions"), BuildFlagParam_None);
add_flag(&build_flags, BuildFlag_GoToDefinitions, str_lit("go-to-definitions"), BuildFlagParam_None);
@@ -1099,6 +1103,10 @@ bool parse_build_flags(Array<String> args) {
build_context.extra_linker_flags = value.value_string;
break;
+ case BuildFlag_DefaultToNilAllocator:
+ build_context.ODIN_DEFAULT_TO_NIL_ALLOCATOR = true;
+ break;
+
case BuildFlag_Compact:
if (!build_context.query_data_set_settings.ok) {
gb_printf_err("Invalid use of -compact flag, only allowed with 'odin query'\n");
@@ -1685,7 +1693,7 @@ int main(int arg_count, char const **arg_ptr) {
#endif
} else if (command == "version") {
gb_printf("%.*s version %.*s", LIT(args[0]), LIT(ODIN_VERSION));
-
+
#ifdef NIGHTLY
gb_printf("-nightly");
#endif
@@ -1693,7 +1701,7 @@ int main(int arg_count, char const **arg_ptr) {
#ifdef GIT_SHA
gb_printf("-%s", GIT_SHA);
#endif
-
+
gb_printf("\n");
return 0;
} else {