From 4e5b8f2c61f09f3f328f1b8dcd4aeaa65a864f33 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 20 Oct 2020 12:35:12 +0100 Subject: Add `-build-mode:assembly` for `-llvm-api` --- src/main.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 64da5b5b4..149c1522d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1061,6 +1061,8 @@ bool parse_build_flags(Array args) { build_context.build_mode = BuildMode_Object; } else if (str == "exe") { build_context.build_mode = BuildMode_Executable; + } else if (str == "asm" || str == "assembly" || str == "assembler") { + build_context.build_mode = BuildMode_Assembly; } else { gb_printf_err("Unknown build mode '%.*s'\n", LIT(str)); bad_flags = true; @@ -1762,6 +1764,12 @@ int main(int arg_count, char const **arg_ptr) { return 1; } } + if (!build_context.use_llvm_api) { + if (build_context.build_mode == BuildMode_Assembly) { + print_usage_line(0, "-build-mode:assembly is only supported with the -llvm-api backend", LIT(args[0])); + return 1; + } + } init_universal(); // TODO(bill): prevent compiling without a linker @@ -1825,11 +1833,16 @@ int main(int arg_count, char const **arg_ptr) { } lb_generate_code(&gen); - if (build_context.build_mode != BuildMode_Object) { - i32 linker_stage_exit_count = linker_stage(&gen); - if (linker_stage_exit_count != 0) { - return linker_stage_exit_count; + switch (build_context.build_mode) { + case BuildMode_Executable: + case BuildMode_DynamicLibrary: + { + i32 linker_stage_exit_count = linker_stage(&gen); + if (linker_stage_exit_count != 0) { + return linker_stage_exit_count; + } } + break; } if (build_context.show_timings) { -- cgit v1.2.3