浏览代码

Add `LLVM_BACKEND_SUPPORT` macro to make the backend optional

gingerBill 5 年之前
父节点
当前提交
ed4d21045b
共有 2 个文件被更改,包括 14 次插入2 次删除
  1. 3 1
      build.bat
  2. 11 1
      src/main.cpp

+ 3 - 1
build.bat

@@ -13,6 +13,8 @@ if "%1" == "1" (
 )
 
 set compiler_flags= -nologo -Oi -TP -fp:precise -Gm- -MP -FC -EHsc- -GR- -GF
+set compiler_defines= -DLLVM_BACKEND_SUPPORT
+
 
 if %release_mode% EQU 0 ( rem Debug
 	set compiler_flags=%compiler_flags% -Od -MDd -Z7
@@ -41,7 +43,7 @@ if %release_mode% EQU 0 ( rem Debug
 	set linker_flags=%linker_flags% -debug
 )
 
-set compiler_settings=%compiler_includes% %compiler_flags% %compiler_warnings%
+set compiler_settings=%compiler_includes% %compiler_flags% %compiler_warnings% %compiler_defines%
 set linker_settings=%libs% %linker_flags%
 
 del *.pdb > NUL 2> NUL

+ 11 - 1
src/main.cpp

@@ -18,7 +18,10 @@ gb_global Timings global_timings = {0};
 #include "docs.cpp"
 #include "checker.cpp"
 
+
+#if defined(LLVM_BACKEND_SUPPORT)
 #include "llvm_backend.cpp"
+#endif
 
 #include "ir.cpp"
 #include "ir_opt.cpp"
@@ -126,6 +129,7 @@ i32 system_exec_command_line_app(char const *name, char const *fmt, ...) {
 
 
 
+#if defined(LLVM_BACKEND_SUPPORT)
 i32 linker_stage(lbGenerator *gen) {
 	i32 exit_code = 0;
 
@@ -420,7 +424,7 @@ i32 linker_stage(lbGenerator *gen) {
 
 	return exit_code;
 }
-
+#endif
 
 Array<String> setup_args(int argc, char const **argv) {
 	gbAllocator a = heap_allocator();
@@ -1586,6 +1590,8 @@ int main(int arg_count, char const **arg_ptr) {
 	}
 
 	if (build_context.use_llvm_api) {
+#if defined(LLVM_BACKEND_SUPPORT)
+
 		timings_start_section(timings, str_lit("LLVM API Code Gen"));
 		lbGenerator gen = {};
 		if (!lb_init_generator(&gen, &checker)) {
@@ -1616,6 +1622,10 @@ int main(int arg_count, char const **arg_ptr) {
 		}
 
 		return 0;
+#else
+		gb_printf_err("LLVM C API backend is not supported on this platform yet\n");
+		return 1;
+#endif
 	} else {
 		irGen ir_gen = {0};
 		if (!ir_gen_init(&ir_gen, &checker)) {