From a6cd3bf713b3c5748a2135278243b879a1305654 Mon Sep 17 00:00:00 2001 From: David Gonzalez Martin Date: Sun, 22 Jun 2025 14:08:24 -0600 Subject: [PATCH] Pass cpu model option --- src/compiler.bbb | 20 +++++++++++++++++++- src/compiler.cpp | 21 ++++++++++++++++++++- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/compiler.bbb b/src/compiler.bbb index d31a008..0ed37e1 100644 --- a/src/compiler.bbb +++ b/src/compiler.bbb @@ -18665,6 +18665,7 @@ names: [_][]u8 = >build_mode: BuildMode = .debug_none; >has_debug_info: u1 = 1; + >is_host_cpu_model: u1 = 1; if (argument_count >= 4) { @@ -18693,6 +18694,23 @@ names: [_][]u8 = } } + if (argument_count >= 6) + { + >is_host_cpu_model_string = c_string_to_slice(arguments[5]); + if (string_equal(is_host_cpu_model_string, "true")) + { + is_host_cpu_model = 1; + } + else if (string_equal(is_host_cpu_model_string, "false")) + { + is_host_cpu_model = 0; + } + else + { + return 1; + } + } + >relative_file_path_pointer = arguments[2]; if (!relative_file_path_pointer) { @@ -18704,7 +18722,7 @@ names: [_][]u8 = compile_file(arena, { .relative_file_path = relative_file_path, .build_mode = build_mode, - .host_cpu_model = 0, + .host_cpu_model = is_host_cpu_model, .has_debug_info = has_debug_info, .silent = 0, }, envp); diff --git a/src/compiler.cpp b/src/compiler.cpp index 73076bb..53b871e 100644 --- a/src/compiler.cpp +++ b/src/compiler.cpp @@ -535,6 +535,7 @@ void entry_point(Slice arguments, Slice envp) auto build_mode = BuildMode::debug_none; auto has_debug_info = true; + auto is_host_cpu_model = true; if (arguments.length >= 4) { @@ -583,12 +584,30 @@ void entry_point(Slice arguments, Slice envp) } } + if (arguments.length >= 6) + { + auto is_host_cpu_model_string = c_string_to_slice(arguments[5]); + if (is_host_cpu_model_string.equal(string_literal("true"))) + { + is_host_cpu_model = true; + } + else if (is_host_cpu_model_string.equal(string_literal("false"))) + { + is_host_cpu_model = false; + } + else + { + bb_fail_with_message(string_literal("Wrong value for is_host_cpu_model\n")); + } + } + auto relative_file_path = c_string_to_slice(arguments[2]); compile_file(arena, { .relative_file_path = relative_file_path, .build_mode = build_mode, .has_debug_info = has_debug_info, + .host_cpu_model = is_host_cpu_model, .silent = false, }); } break; @@ -601,7 +620,6 @@ void entry_point(Slice arguments, Slice envp) } bool has_debug_info_array[] = {true, false}; - bool is_host_cpu_model_array[] = {true, false}; for (auto name: names) { @@ -649,6 +667,7 @@ void entry_point(Slice arguments, Slice envp) .relative_file_path = string_literal("src/compiler.bbb"), .build_mode = compiler_build_mode, .has_debug_info = compiler_has_debug_info, + .host_cpu_model = true, .silent = true, });