mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Get compiling on Mac Mini M1
This commit is contained in:
+10
-4
@@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
release_mode=$1
|
release_mode=$1
|
||||||
|
|
||||||
warnings_to_disable="-std=c++11 -Wno-switch -Wno-pointer-sign -Wno-tautological-constant-out-of-range-compare -Wno-tautological-compare -Wno-macro-redefined"
|
warnings_to_disable="-std=c++11 -Wno-switch"
|
||||||
libraries="-pthread -ldl -lm -lstdc++"
|
|
||||||
|
libraries="-pthread -ldl -lm -lstdc++ -lz -lcurses -lxml2"
|
||||||
other_args="-DLLVM_BACKEND_SUPPORT -DUSE_NEW_LLVM_ABI_SYSTEM"
|
other_args="-DLLVM_BACKEND_SUPPORT -DUSE_NEW_LLVM_ABI_SYSTEM"
|
||||||
compiler="clang"
|
compiler="clang"
|
||||||
|
|
||||||
@@ -22,10 +23,15 @@ if [[ "$(uname)" == "Darwin" ]]; then
|
|||||||
# MacOS provides a symlink to clang called gcc, but it's nice to be explicit here.
|
# MacOS provides a symlink to clang called gcc, but it's nice to be explicit here.
|
||||||
compiler="clang"
|
compiler="clang"
|
||||||
|
|
||||||
|
llvm_config_flags="--cxxflags --ldflags"
|
||||||
|
# llvm_config_flags="${llvm_config_flags} --link-static"
|
||||||
|
llvm_config="llvm-config ${llvm_config_flags}"
|
||||||
|
|
||||||
other_args="${other_args} -liconv"
|
other_args="${other_args} -liconv"
|
||||||
|
other_args="${other_args} `${llvm_config}` -lLLVM-C"
|
||||||
elif [[ "$(uname)" == "FreeBSD" ]]; then
|
elif [[ "$(uname)" == "FreeBSD" ]]; then
|
||||||
compiler="clang"
|
compiler="clang"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
${compiler} src/main.cpp ${warnings_to_disable} ${libraries} ${other_args} -o odin \
|
${compiler} src/main.cpp ${warnings_to_disable} ${libraries} ${other_args} -o odin
|
||||||
&& ./odin run examples/demo/demo.odin -llvm-api
|
# && ./odin run examples/demo/demo.odin -llvm-api
|
||||||
|
|||||||
+16
-12
@@ -23,7 +23,7 @@ enum TargetArchKind {
|
|||||||
|
|
||||||
TargetArch_amd64,
|
TargetArch_amd64,
|
||||||
TargetArch_386,
|
TargetArch_386,
|
||||||
TargetArch_aarch64,
|
TargetArch_arm64,
|
||||||
TargetArch_wasm32,
|
TargetArch_wasm32,
|
||||||
|
|
||||||
TargetArch_COUNT,
|
TargetArch_COUNT,
|
||||||
@@ -54,7 +54,7 @@ String target_arch_names[TargetArch_COUNT] = {
|
|||||||
str_lit(""),
|
str_lit(""),
|
||||||
str_lit("amd64"),
|
str_lit("amd64"),
|
||||||
str_lit("386"),
|
str_lit("386"),
|
||||||
str_lit("aarch64"),
|
str_lit("arm64"),
|
||||||
str_lit("wasm32"),
|
str_lit("wasm32"),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -270,13 +270,13 @@ gb_global TargetMetrics target_darwin_amd64 = {
|
|||||||
str_lit("e-m:o-i64:64-f80:128-n8:16:32:64-S128"),
|
str_lit("e-m:o-i64:64-f80:128-n8:16:32:64-S128"),
|
||||||
};
|
};
|
||||||
|
|
||||||
gb_global TargetMetrics target_darwin_aarch64 = {
|
gb_global TargetMetrics target_darwin_arm64 = {
|
||||||
TargetOs_darwin,
|
TargetOs_darwin,
|
||||||
TargetArch_aarch64,
|
TargetArch_arm64,
|
||||||
8,
|
8,
|
||||||
16,
|
16,
|
||||||
str_lit("aarch64-apple-darwin"),
|
str_lit("arm64-apple-macosx11.0.0"),
|
||||||
str_lit("e-m:o-i64:64-f64:128-n8:16:32:64-S128"), // TODO(bill): Is this correct?
|
str_lit("e-m:o-i64:64-i128:128-n32:64-S128"), // TODO(bill): Is this correct?
|
||||||
};
|
};
|
||||||
|
|
||||||
gb_global TargetMetrics target_freebsd_386 = {
|
gb_global TargetMetrics target_freebsd_386 = {
|
||||||
@@ -322,7 +322,7 @@ struct NamedTargetMetrics {
|
|||||||
|
|
||||||
gb_global NamedTargetMetrics named_targets[] = {
|
gb_global NamedTargetMetrics named_targets[] = {
|
||||||
{ str_lit("darwin_amd64"), &target_darwin_amd64 },
|
{ str_lit("darwin_amd64"), &target_darwin_amd64 },
|
||||||
{ str_lit("darwin_aarch64"), &target_darwin_aarch64 },
|
{ str_lit("darwin_arm64"), &target_darwin_arm64 },
|
||||||
{ str_lit("essence_amd64"), &target_essence_amd64 },
|
{ str_lit("essence_amd64"), &target_essence_amd64 },
|
||||||
{ str_lit("js_wasm32"), &target_js_wasm32 },
|
{ str_lit("js_wasm32"), &target_js_wasm32 },
|
||||||
{ str_lit("linux_386"), &target_linux_386 },
|
{ str_lit("linux_386"), &target_linux_386 },
|
||||||
@@ -733,7 +733,11 @@ void init_build_context(TargetMetrics *cross_target) {
|
|||||||
#if defined(GB_SYSTEM_WINDOWS)
|
#if defined(GB_SYSTEM_WINDOWS)
|
||||||
metrics = &target_windows_amd64;
|
metrics = &target_windows_amd64;
|
||||||
#elif defined(GB_SYSTEM_OSX)
|
#elif defined(GB_SYSTEM_OSX)
|
||||||
metrics = &target_darwin_amd64;
|
#if defined(GB_CPU_ARM)
|
||||||
|
metrics = &target_darwin_arm64;
|
||||||
|
#else
|
||||||
|
metrics = &target_darwin_amd64;
|
||||||
|
#endif
|
||||||
#elif defined(GB_SYSTEM_FREEBSD)
|
#elif defined(GB_SYSTEM_FREEBSD)
|
||||||
metrics = &target_freebsd_amd64;
|
metrics = &target_freebsd_amd64;
|
||||||
#else
|
#else
|
||||||
@@ -820,18 +824,18 @@ void init_build_context(TargetMetrics *cross_target) {
|
|||||||
bc->link_flags = str_lit("-arch x86 ");
|
bc->link_flags = str_lit("-arch x86 ");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (bc->metrics.arch == TargetArch_aarch64) {
|
} else if (bc->metrics.arch == TargetArch_arm64) {
|
||||||
if (bc->microarch.len == 0) {
|
if (bc->microarch.len == 0) {
|
||||||
llc_flags = gb_string_appendc(llc_flags, "-march=aarch64 ");
|
llc_flags = gb_string_appendc(llc_flags, "-march=arm64 ");
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (bc->metrics.os) {
|
switch (bc->metrics.os) {
|
||||||
case TargetOs_darwin:
|
case TargetOs_darwin:
|
||||||
bc->link_flags = str_lit("-arch aarch64 ");
|
bc->link_flags = str_lit("-arch arm64 ");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!bc->use_llvm_api) {
|
if (!bc->use_llvm_api) {
|
||||||
gb_printf_err("The aarch64 architecture is only supported with -llvm-api\n");;
|
gb_printf_err("The arm64 architecture is only supported with -llvm-api\n");;
|
||||||
gb_exit(1);
|
gb_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -909,7 +909,7 @@ namespace lbAbiAmd64SysV {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
namespace lbAbiAarch64 {
|
namespace lbAbiArm64 {
|
||||||
Array<lbArgType> compute_arg_types(LLVMContextRef c, LLVMTypeRef *arg_types, unsigned arg_count);
|
Array<lbArgType> compute_arg_types(LLVMContextRef c, LLVMTypeRef *arg_types, unsigned arg_count);
|
||||||
lbArgType compute_return_type(LLVMContextRef c, LLVMTypeRef return_type, bool return_is_defined);
|
lbArgType compute_return_type(LLVMContextRef c, LLVMTypeRef return_type, bool return_is_defined);
|
||||||
bool is_homogenous_aggregate(LLVMContextRef c, LLVMTypeRef type, LLVMTypeRef *base_type_, unsigned *member_count_);
|
bool is_homogenous_aggregate(LLVMContextRef c, LLVMTypeRef type, LLVMTypeRef *base_type_, unsigned *member_count_);
|
||||||
@@ -1123,8 +1123,8 @@ LB_ABI_INFO(lb_get_abi_info) {
|
|||||||
}
|
}
|
||||||
} else if (build_context.metrics.arch == TargetArch_386) {
|
} else if (build_context.metrics.arch == TargetArch_386) {
|
||||||
return lbAbi386::abi_info(c, arg_types, arg_count, return_type, return_is_defined, calling_convention);
|
return lbAbi386::abi_info(c, arg_types, arg_count, return_type, return_is_defined, calling_convention);
|
||||||
} else if (build_context.metrics.arch == TargetArch_aarch64) {
|
} else if (build_context.metrics.arch == TargetArch_arm64) {
|
||||||
return lbAbiAarch64::abi_info(c, arg_types, arg_count, return_type, return_is_defined, calling_convention);
|
return lbAbiArm64::abi_info(c, arg_types, arg_count, return_type, return_is_defined, calling_convention);
|
||||||
} else if (build_context.metrics.arch == TargetArch_wasm32) {
|
} else if (build_context.metrics.arch == TargetArch_wasm32) {
|
||||||
return lbAbi386::abi_info(c, arg_types, arg_count, return_type, return_is_defined, calling_convention);
|
return lbAbi386::abi_info(c, arg_types, arg_count, return_type, return_is_defined, calling_convention);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,14 @@ gb_global Timings global_timings = {0};
|
|||||||
|
|
||||||
#if defined(LLVM_BACKEND_SUPPORT)
|
#if defined(LLVM_BACKEND_SUPPORT)
|
||||||
#include "llvm_backend.cpp"
|
#include "llvm_backend.cpp"
|
||||||
|
|
||||||
|
#if defined(GB_SYSTEM_OSX)
|
||||||
|
#include <llvm/Config/llvm-config.h>
|
||||||
|
#if LLVM_VERSION_MAJOR < 11
|
||||||
|
#error LLVM Version 11+ is required => "brew install llvm@11"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "ir.cpp"
|
#include "ir.cpp"
|
||||||
|
|||||||
Reference in New Issue
Block a user