From 4bb8f8f973c6866a060b125c5470f7b02e5e8ea8 Mon Sep 17 00:00:00 2001 From: David Gonzalez Martin Date: Thu, 5 Jun 2025 06:12:51 -0600 Subject: [PATCH] Compile self-hosted executables in all build modes --- src/compiler.cpp | 124 ++++++++++++++++++++++++----------------------- 1 file changed, 64 insertions(+), 60 deletions(-) diff --git a/src/compiler.cpp b/src/compiler.cpp index 5aaa999..c495f85 100644 --- a/src/compiler.cpp +++ b/src/compiler.cpp @@ -602,68 +602,72 @@ void entry_point(Slice arguments, Slice envp) Slice name_slice = array_to_slice(names); for (auto name: name_slice(0, 1)) { - // COMPILATION START + for (BuildMode build_mode = BuildMode::debug_none; build_mode < BuildMode::count; build_mode = (BuildMode)((backing_type(BuildMode))build_mode + 1)) + { + for (bool has_debug_info : has_debug_info_array) + { + // COMPILATION START - BuildMode build_mode = BuildMode::debug_none; - bool has_debug_info = true; - String relative_file_path_parts[] = { string_literal("tests/"), name, string_literal(".bbb") }; - auto relative_file_path = arena_join_string(arena, array_to_slice(relative_file_path_parts)); - char* const compiler_arguments[] = - { - (char*)compiler.pointer, - (char*)"compile", - (char*)relative_file_path.pointer, - (char*)build_mode_to_string(build_mode).pointer, - (char*)(has_debug_info ? "true" : "false"), - 0, - }; - Slice arg_slice = array_to_slice(compiler_arguments); - arg_slice.length -= 1; - auto execution = os_execute(arena, arg_slice, environment, {}); - auto success = execution.termination_kind == TerminationKind::exit && execution.termination_code == 0; - if (!success) - { - print(string_literal("Self-hosted test failed to compile: ")); - print(name); - print(string_literal("\n")); - bb_fail(); + String relative_file_path_parts[] = { string_literal("tests/"), name, string_literal(".bbb") }; + auto relative_file_path = arena_join_string(arena, array_to_slice(relative_file_path_parts)); + char* const compiler_arguments[] = + { + (char*)compiler.pointer, + (char*)"compile", + (char*)relative_file_path.pointer, + (char*)build_mode_to_string(build_mode).pointer, + (char*)(has_debug_info ? "true" : "false"), + 0, + }; + Slice arg_slice = array_to_slice(compiler_arguments); + arg_slice.length -= 1; + auto execution = os_execute(arena, arg_slice, environment, {}); + auto success = execution.termination_kind == TerminationKind::exit && execution.termination_code == 0; + if (!success) + { + print(string_literal("Self-hosted test failed to compile: ")); + print(name); + print(string_literal("\n")); + bb_fail(); + } + + // COMPILATION END + + // RUN START + + String exe_parts[] = { + string_literal("self-hosted-bb-cache/"), + build_mode_to_string(compiler_build_mode), + string_literal("_"), + compiler_has_debug_info ? string_literal("di") : string_literal("nodi"), + string_literal("/"), + build_mode_to_string(build_mode), + string_literal("_"), + has_debug_info ? string_literal("di") : string_literal("nodi"), + string_literal("/"), + name, + }; + String exe_path = arena_join_string(arena, array_to_slice(exe_parts)); + char* const run_arguments[] = + { + (char*)exe_path.pointer, + 0, + }; + arg_slice = array_to_slice(run_arguments); + arg_slice.length -= 1; + execution = os_execute(arena, arg_slice, environment, {}); + success = execution.termination_kind == TerminationKind::exit && execution.termination_code == 0; + if (!success) + { + print(string_literal("Self-hosted test failed to run: ")); + print(name); + print(string_literal("\n")); + bb_fail(); + } + + // RUN END + } } - - // COMPILATION END - - // RUN START - - String exe_parts[] = { - string_literal("self-hosted-bb-cache/"), - build_mode_to_string(compiler_build_mode), - string_literal("_"), - compiler_has_debug_info ? string_literal("di") : string_literal("nodi"), - string_literal("/"), - build_mode_to_string(build_mode), - string_literal("_"), - has_debug_info ? string_literal("di") : string_literal("nodi"), - string_literal("/"), - name, - }; - String exe_path = arena_join_string(arena, array_to_slice(exe_parts)); - char* const run_arguments[] = - { - (char*)exe_path.pointer, - 0, - }; - arg_slice = array_to_slice(run_arguments); - arg_slice.length -= 1; - execution = os_execute(arena, arg_slice, environment, {}); - success = execution.termination_kind == TerminationKind::exit && execution.termination_code == 0; - if (!success) - { - print(string_literal("Self-hosted test failed to run: ")); - print(name); - print(string_literal("\n")); - bb_fail(); - } - - // RUN END } } }