mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 07:08:48 +00:00
Add -default-to-nil-allocator flag (sets ODIN_DEFAULT_TO_NIL_ALLOCATOR)
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
package runtime
|
package runtime
|
||||||
|
|
||||||
when ODIN_OS == "freestanding" {
|
when ODIN_DEFAULT_TO_NIL_ALLOCATOR || ODIN_OS == "freestanding" {
|
||||||
// mem.nil_allocator reimplementation
|
// mem.nil_allocator reimplementation
|
||||||
|
|
||||||
default_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode,
|
default_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode,
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ struct BuildContext {
|
|||||||
String ODIN_ROOT; // Odin ROOT
|
String ODIN_ROOT; // Odin ROOT
|
||||||
bool ODIN_DEBUG; // Odin in debug mode
|
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_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;
|
TargetEndianKind endian_kind;
|
||||||
|
|
||||||
|
|||||||
@@ -739,6 +739,7 @@ void init_universal(void) {
|
|||||||
add_global_string_constant(str_lit("ODIN_ROOT"), bc->ODIN_ROOT);
|
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_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_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_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));
|
add_global_constant(str_lit("ODIN_NO_DYNAMIC_LITERALS"), t_untyped_bool, exact_value_bool(bc->no_dynamic_literals));
|
||||||
|
|
||||||
|
|||||||
+10
-2
@@ -580,6 +580,8 @@ enum BuildFlagKind {
|
|||||||
BuildFlag_IgnoreUnknownAttributes,
|
BuildFlag_IgnoreUnknownAttributes,
|
||||||
BuildFlag_ExtraLinkerFlags,
|
BuildFlag_ExtraLinkerFlags,
|
||||||
|
|
||||||
|
BuildFlag_DefaultToNilAllocator,
|
||||||
|
|
||||||
BuildFlag_Compact,
|
BuildFlag_Compact,
|
||||||
BuildFlag_GlobalDefinitions,
|
BuildFlag_GlobalDefinitions,
|
||||||
BuildFlag_GoToDefinitions,
|
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_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_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_Compact, str_lit("compact"), BuildFlagParam_None);
|
||||||
add_flag(&build_flags, BuildFlag_GlobalDefinitions, str_lit("global-definitions"), 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);
|
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;
|
build_context.extra_linker_flags = value.value_string;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case BuildFlag_DefaultToNilAllocator:
|
||||||
|
build_context.ODIN_DEFAULT_TO_NIL_ALLOCATOR = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case BuildFlag_Compact:
|
case BuildFlag_Compact:
|
||||||
if (!build_context.query_data_set_settings.ok) {
|
if (!build_context.query_data_set_settings.ok) {
|
||||||
gb_printf_err("Invalid use of -compact flag, only allowed with 'odin query'\n");
|
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
|
#endif
|
||||||
} else if (command == "version") {
|
} else if (command == "version") {
|
||||||
gb_printf("%.*s version %.*s", LIT(args[0]), LIT(ODIN_VERSION));
|
gb_printf("%.*s version %.*s", LIT(args[0]), LIT(ODIN_VERSION));
|
||||||
|
|
||||||
#ifdef NIGHTLY
|
#ifdef NIGHTLY
|
||||||
gb_printf("-nightly");
|
gb_printf("-nightly");
|
||||||
#endif
|
#endif
|
||||||
@@ -1693,7 +1701,7 @@ int main(int arg_count, char const **arg_ptr) {
|
|||||||
#ifdef GIT_SHA
|
#ifdef GIT_SHA
|
||||||
gb_printf("-%s", GIT_SHA);
|
gb_printf("-%s", GIT_SHA);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gb_printf("\n");
|
gb_printf("\n");
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user