aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2020-10-20 12:35:12 +0100
committergingerBill <bill@gingerbill.org>2020-10-20 12:35:12 +0100
commit4e5b8f2c61f09f3f328f1b8dcd4aeaa65a864f33 (patch)
tree8e75a2938b012b3243e1b894a48fe778f856062b /src/main.cpp
parent0be6ddc7e2149a1f6b8fbc08ecf2674926c11785 (diff)
Add `-build-mode:assembly` for `-llvm-api`
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp21
1 files changed, 17 insertions, 4 deletions
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<String> 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) {