mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Replace local @(no_red_zone) with global -disable-red-zone
This commit is contained in:
@@ -278,6 +278,7 @@ struct BuildContext {
|
|||||||
bool copy_file_contents;
|
bool copy_file_contents;
|
||||||
|
|
||||||
RelocMode reloc_mode;
|
RelocMode reloc_mode;
|
||||||
|
bool disable_red_zone;
|
||||||
|
|
||||||
|
|
||||||
u32 cmd_doc_flags;
|
u32 cmd_doc_flags;
|
||||||
@@ -1002,6 +1003,13 @@ void init_build_context(TargetMetrics *cross_target) {
|
|||||||
bc->threaded_checker = true;
|
bc->threaded_checker = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (bc->disable_red_zone) {
|
||||||
|
if (!(bc->metrics.os == TargetOs_freestanding && !is_arch_wasm())) {
|
||||||
|
gb_printf_err("-disable-red-zone is not support for this target");
|
||||||
|
gb_exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// NOTE(zangent): The linker flags to set the build architecture are different
|
// NOTE(zangent): The linker flags to set the build architecture are different
|
||||||
// across OSs. It doesn't make sense to allocate extra data on the heap
|
// across OSs. It doesn't make sense to allocate extra data on the heap
|
||||||
|
|||||||
@@ -826,14 +826,6 @@ void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) {
|
|||||||
}
|
}
|
||||||
e->Procedure.optimization_mode = cast(ProcedureOptimizationMode)ac.optimization_mode;
|
e->Procedure.optimization_mode = cast(ProcedureOptimizationMode)ac.optimization_mode;
|
||||||
|
|
||||||
if (ac.no_red_zone) {
|
|
||||||
if (!is_arch_wasm()) {
|
|
||||||
e->Procedure.no_red_zone = true;
|
|
||||||
} else {
|
|
||||||
error(e->token, "@(no_red_zone) is not supported on this target architecture");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ac.objc_name.len || ac.objc_is_class_method || ac.objc_type) {
|
if (ac.objc_name.len || ac.objc_is_class_method || ac.objc_type) {
|
||||||
if (ac.objc_name.len == 0 && ac.objc_is_class_method) {
|
if (ac.objc_name.len == 0 && ac.objc_is_class_method) {
|
||||||
error(e->token, "@(objc_name) is required with @(objc_is_class_method)");
|
error(e->token, "@(objc_name) is required with @(objc_is_class_method)");
|
||||||
|
|||||||
@@ -3128,13 +3128,6 @@ DECL_ATTRIBUTE_PROC(proc_decl_attribute) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if (name == "no_red_zone") {
|
|
||||||
if (value != nullptr) {
|
|
||||||
error(elem, "Expected no value for '%.*s'", LIT(name));
|
|
||||||
} else {
|
|
||||||
ac->no_red_zone = true;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,7 +117,6 @@ struct AttributeContext {
|
|||||||
bool test : 1;
|
bool test : 1;
|
||||||
bool init : 1;
|
bool init : 1;
|
||||||
bool set_cold : 1;
|
bool set_cold : 1;
|
||||||
bool no_red_zone : 1;
|
|
||||||
u32 optimization_mode; // ProcedureOptimizationMode
|
u32 optimization_mode; // ProcedureOptimizationMode
|
||||||
|
|
||||||
String objc_class;
|
String objc_class;
|
||||||
|
|||||||
@@ -226,7 +226,6 @@ struct Entity {
|
|||||||
bool is_foreign;
|
bool is_foreign;
|
||||||
bool is_export;
|
bool is_export;
|
||||||
bool generated_from_polymorphic;
|
bool generated_from_polymorphic;
|
||||||
bool no_red_zone;
|
|
||||||
ProcedureOptimizationMode optimization_mode;
|
ProcedureOptimizationMode optimization_mode;
|
||||||
} Procedure;
|
} Procedure;
|
||||||
struct {
|
struct {
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool ignore_body)
|
|||||||
lb_add_attribute_to_proc(m, p->value, "naked");
|
lb_add_attribute_to_proc(m, p->value, "naked");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity->Procedure.no_red_zone) {
|
if (!entity->Procedure.is_foreign && build_context.disable_red_zone) {
|
||||||
lb_add_attribute_to_proc(m, p->value, "noredzone");
|
lb_add_attribute_to_proc(m, p->value, "noredzone");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -626,6 +626,7 @@ enum BuildFlagKind {
|
|||||||
BuildFlag_Microarch,
|
BuildFlag_Microarch,
|
||||||
|
|
||||||
BuildFlag_RelocMode,
|
BuildFlag_RelocMode,
|
||||||
|
BuildFlag_DisableRedZone,
|
||||||
|
|
||||||
BuildFlag_TestName,
|
BuildFlag_TestName,
|
||||||
|
|
||||||
@@ -782,6 +783,7 @@ bool parse_build_flags(Array<String> args) {
|
|||||||
add_flag(&build_flags, BuildFlag_Microarch, str_lit("microarch"), BuildFlagParam_String, Command__does_build);
|
add_flag(&build_flags, BuildFlag_Microarch, str_lit("microarch"), BuildFlagParam_String, Command__does_build);
|
||||||
|
|
||||||
add_flag(&build_flags, BuildFlag_RelocMode, str_lit("reloc-mode"), BuildFlagParam_String, Command__does_build);
|
add_flag(&build_flags, BuildFlag_RelocMode, str_lit("reloc-mode"), BuildFlagParam_String, Command__does_build);
|
||||||
|
add_flag(&build_flags, BuildFlag_DisableRedZone, str_lit("disable-red-zone"), BuildFlagParam_None, Command__does_build);
|
||||||
|
|
||||||
add_flag(&build_flags, BuildFlag_TestName, str_lit("test-name"), BuildFlagParam_String, Command_test);
|
add_flag(&build_flags, BuildFlag_TestName, str_lit("test-name"), BuildFlagParam_String, Command_test);
|
||||||
|
|
||||||
@@ -1365,6 +1367,9 @@ bool parse_build_flags(Array<String> args) {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case BuildFlag_DisableRedZone:
|
||||||
|
build_context.disable_red_zone = true;
|
||||||
|
break;
|
||||||
case BuildFlag_TestName: {
|
case BuildFlag_TestName: {
|
||||||
GB_ASSERT(value.kind == ExactValue_String);
|
GB_ASSERT(value.kind == ExactValue_String);
|
||||||
{
|
{
|
||||||
@@ -2096,6 +2101,9 @@ void print_show_help(String const arg0, String const &command) {
|
|||||||
print_usage_line(3, "pic");
|
print_usage_line(3, "pic");
|
||||||
print_usage_line(3, "dynamic-no-pic");
|
print_usage_line(3, "dynamic-no-pic");
|
||||||
print_usage_line(0, "");
|
print_usage_line(0, "");
|
||||||
|
|
||||||
|
print_usage_line(1, "-disable-red-zone");
|
||||||
|
print_usage_line(2, "Disable red zone on a supported freestanding target");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check) {
|
if (check) {
|
||||||
|
|||||||
Reference in New Issue
Block a user