From ba817d153ce1cd48dd37e47d2e4243270f78e9f0 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 24 Feb 2021 23:21:34 +0000 Subject: Get compiling on Mac Mini M1 --- src/main.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 346488ca8..a40a96ea9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -28,6 +28,14 @@ gb_global Timings global_timings = {0}; #if defined(LLVM_BACKEND_SUPPORT) #include "llvm_backend.cpp" + +#if defined(GB_SYSTEM_OSX) + #include + #if LLVM_VERSION_MAJOR < 11 + #error LLVM Version 11+ is required => "brew install llvm@11" + #endif +#endif + #endif #include "ir.cpp" -- cgit v1.2.3 From 58422711d1fdb6af8d4c97e375197647926df622 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 25 Feb 2021 00:22:47 +0000 Subject: Remove sret attribute in llvm_abi.cpp --- src/llvm_abi.cpp | 17 +++++++++++++---- src/main.cpp | 4 ++++ 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'src/main.cpp') diff --git a/src/llvm_abi.cpp b/src/llvm_abi.cpp index 327165da5..6c7c681a6 100644 --- a/src/llvm_abi.cpp +++ b/src/llvm_abi.cpp @@ -443,7 +443,10 @@ namespace lbAbi386 { case 4: return lb_arg_type_direct(return_type, LLVMIntTypeInContext(c, 32), nullptr, nullptr); case 8: return lb_arg_type_direct(return_type, LLVMIntTypeInContext(c, 64), nullptr, nullptr); } - return lb_arg_type_indirect(return_type, lb_create_enum_attribute(c, "sret", true)); + LLVMAttributeRef attr = nullptr; + // TODO(bill): sret doesn't work correct for LLVM C API + // attr = lb_create_enum_attribute(c, "sret", true); + return lb_arg_type_indirect(return_type, attr); } return non_struct(c, return_type, true); } @@ -601,7 +604,8 @@ namespace lbAbiAmd64SysV { if (attribute_kind == Amd64TypeAttribute_ByVal) { attribute = lb_create_enum_attribute(c, "byval", true); } else if (attribute_kind == Amd64TypeAttribute_StructRect) { - attribute = lb_create_enum_attribute(c, "sret", true); + // TODO(bill): sret doesn't work correct for LLVM C API + // attribute = lb_create_enum_attribute(c, "sret", true); } return lb_arg_type_indirect(type, attribute); } else { @@ -900,7 +904,10 @@ namespace lbAbiAmd64SysV { case 4: return lb_arg_type_direct(return_type, LLVMIntTypeInContext(c, 32), nullptr, nullptr); case 8: return lb_arg_type_direct(return_type, LLVMIntTypeInContext(c, 64), nullptr, nullptr); } - return lb_arg_type_indirect(return_type, lb_create_enum_attribute(c, "sret", true)); + LLVMAttributeRef attr = nullptr; + // TODO(bill): sret doesn't work correct for LLVM C API + // attr = lb_create_enum_attribute(c, "sret", true); + return lb_arg_type_indirect(return_type, attr); } else if (build_context.metrics.os == TargetOs_windows && lb_is_type_kind(return_type, LLVMIntegerTypeKind) && lb_sizeof(return_type) == 16) { return lb_arg_type_direct(return_type, LLVMIntTypeInContext(c, 128), nullptr, nullptr); } @@ -1048,7 +1055,9 @@ namespace lbAbiArm64 { } return lb_arg_type_direct(type, cast_type, nullptr, nullptr); } else { - LLVMAttributeRef attr = lb_create_enum_attribute(c, "sret", true); + LLVMAttributeRef attr = nullptr; + // TODO(bill): sret doesn't work correct for LLVM C API + // attr = lb_create_enum_attribute(c, "sret", true); return lb_arg_type_indirect(type, attr); } } diff --git a/src/main.cpp b/src/main.cpp index a40a96ea9..4545f6f21 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -439,7 +439,11 @@ void linker_stage(lbGenerator *gen) { // This sets a requirement of Mountain Lion and up, but the compiler doesn't work without this limit. // NOTE: If you change this (although this minimum is as low as you can go with Odin working) // make sure to also change the 'mtriple' param passed to 'opt' + #if defined(GB_CPU_ARM) + " -macosx_version_min 11.0.0 " + #else " -macosx_version_min 10.8.0 " + #endif // This points the linker to where the entry point is " -e _main " #endif -- cgit v1.2.3 From 4d13a435900c6668760b6099a998c41fa1fb1717 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 25 Feb 2021 00:39:44 +0000 Subject: Enforce -llvm-api on Mac M1 --- src/main.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 4545f6f21..4ab4df7be 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1842,6 +1842,15 @@ void print_show_unused(Checker *c) { print_usage_line(0, ""); } +void enforce_platform_settings(void) { +#if defined(GB_SYSTEM_OSX) && defined(GB_CPU_ARM) + #if defined(USE_NEW_LLVM_ABI_SYSTEM) + build_context.use_llvm_api = true; + #endif +#endif +} + + int main(int arg_count, char const **arg_ptr) { if (arg_count < 2) { usage(make_string_c(arg_ptr[0])); @@ -1995,7 +2004,7 @@ int main(int arg_count, char const **arg_ptr) { return 0; } - + enforce_platform_settings(); // NOTE(bill): add 'shared' directory if it is not already set if (!find_library_collection_path(str_lit("shared"), nullptr)) { -- cgit v1.2.3