mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-06 04:57:55 +00:00
Support LLVM >=17.0.1 on Darwin and Linux
This commit is contained in:
@@ -52,7 +52,7 @@ config_darwin() {
|
||||
fi
|
||||
fi
|
||||
|
||||
MAX_LLVM_VERSION=("14.999.999")
|
||||
MAX_LLVM_VERSION=("17.999.999")
|
||||
if [ $(version $($LLVM_CONFIG --version)) -gt $(version $MAX_LLVM_VERSION) ]; then
|
||||
echo "Tried to use " $(which $LLVM_CONFIG) "version" $($LLVM_CONFIG --version)
|
||||
panic "Requirement: llvm-config must be base version smaller than 15"
|
||||
@@ -102,6 +102,8 @@ config_linux() {
|
||||
LLVM_CONFIG=llvm-config-11-64
|
||||
elif [ -x "$(command -v llvm-config-14)" ]; then
|
||||
LLVM_CONFIG=llvm-config-14
|
||||
elif [ -x "$(command -v llvm-config-17)" ]; then
|
||||
LLVM_CONFIG=llvm-config-17
|
||||
else
|
||||
panic "Unable to find LLVM-config"
|
||||
fi
|
||||
@@ -113,7 +115,7 @@ config_linux() {
|
||||
panic "Requirement: llvm-config must be base version greater than 11"
|
||||
fi
|
||||
|
||||
MAX_LLVM_VERSION=("14.999.999")
|
||||
MAX_LLVM_VERSION=("17.999.999")
|
||||
if [ $(version $($LLVM_CONFIG --version)) -gt $(version $MAX_LLVM_VERSION) ]; then
|
||||
echo "Tried to use " $(which $LLVM_CONFIG) "version" $($LLVM_CONFIG --version)
|
||||
panic "Requirement: llvm-config must be base version smaller than 15"
|
||||
|
||||
@@ -2602,17 +2602,37 @@ gb_internal bool lb_generate_code(lbGenerator *gen) {
|
||||
|
||||
|
||||
if (build_context.sanitizer_flags & SanitizerFlag_Address) {
|
||||
auto paths = array_make<String>(heap_allocator(), 0, 1);
|
||||
if (build_context.metrics.os == TargetOs_windows) {
|
||||
auto paths = array_make<String>(heap_allocator(), 0, 1);
|
||||
String path = concatenate_strings(permanent_allocator(), build_context.ODIN_ROOT, str_lit("\\bin\\llvm\\windows\\clang_rt.asan-x86_64.lib"));
|
||||
array_add(&paths, path);
|
||||
Entity *lib = alloc_entity_library_name(nullptr, make_token_ident("asan_lib"), nullptr, slice_from_array(paths), str_lit("asan_lib"));
|
||||
array_add(&gen->foreign_libraries, lib);
|
||||
} else if (build_context.metrics.os == TargetOs_darwin || build_context.metrics.os == TargetOs_linux) {
|
||||
if (!build_context.extra_linker_flags.text) {
|
||||
build_context.extra_linker_flags = str_lit("-fsanitize=address");
|
||||
} else {
|
||||
build_context.extra_linker_flags = concatenate_strings(permanent_allocator(), build_context.extra_linker_flags, str_lit(" -fsanitize=address"));
|
||||
}
|
||||
}
|
||||
Entity *lib = alloc_entity_library_name(nullptr, make_token_ident("asan_lib"), nullptr, slice_from_array(paths), str_lit("asan_lib"));
|
||||
array_add(&gen->foreign_libraries, lib);
|
||||
}
|
||||
if (build_context.sanitizer_flags & SanitizerFlag_Memory) {
|
||||
if (build_context.metrics.os == TargetOs_darwin || build_context.metrics.os == TargetOs_linux) {
|
||||
if (!build_context.extra_linker_flags.text) {
|
||||
build_context.extra_linker_flags = str_lit("-fsanitize=memory");
|
||||
} else {
|
||||
build_context.extra_linker_flags = concatenate_strings(permanent_allocator(), build_context.extra_linker_flags, str_lit(" -fsanitize=memory"));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (build_context.sanitizer_flags & SanitizerFlag_Thread) {
|
||||
if (build_context.metrics.os == TargetOs_darwin || build_context.metrics.os == TargetOs_linux) {
|
||||
if (!build_context.extra_linker_flags.text) {
|
||||
build_context.extra_linker_flags = str_lit("-fsanitize=thread");
|
||||
} else {
|
||||
build_context.extra_linker_flags = concatenate_strings(permanent_allocator(), build_context.extra_linker_flags, str_lit(" -fsanitize=thread"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gb_sort_array(gen->foreign_libraries.data, gen->foreign_libraries.count, foreign_library_cmp);
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
#include <llvm-c/Object.h>
|
||||
#include <llvm-c/BitWriter.h>
|
||||
#include <llvm-c/DebugInfo.h>
|
||||
#if LLVM_VERSION_MAJOR >= 17 && (LLVM_VERSION_MINOR > 0 || (LLVM_VERSION_MINOR == 0 && LLVM_VERSION_PATCH > 0))
|
||||
#include <llvm-c/Transforms/PassBuilder.h>
|
||||
#else
|
||||
#include <llvm-c/Transforms/AggressiveInstCombine.h>
|
||||
#include <llvm-c/Transforms/InstCombine.h>
|
||||
#include <llvm-c/Transforms/IPO.h>
|
||||
@@ -23,6 +26,7 @@
|
||||
#include <llvm-c/Transforms/Utils.h>
|
||||
#include <llvm-c/Transforms/Vectorize.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if LLVM_VERSION_MAJOR < 11
|
||||
#error "LLVM Version 11 is the minimum required"
|
||||
|
||||
@@ -89,8 +89,8 @@ gb_global Timings global_timings = {0};
|
||||
#if LLVM_VERSION_MAJOR < 11
|
||||
#error LLVM Version 11+ is required => "brew install llvm@11"
|
||||
#endif
|
||||
#if LLVM_VERSION_MAJOR > 14
|
||||
#error LLVM Version 11..=14 is required => "brew install llvm@14"
|
||||
#if (LLVM_VERSION_MAJOR > 14 && LLVM_VERSION_MAJOR < 17) || LLVM_VERSION_MAJOR > 17
|
||||
#error LLVM Version 11..=14 or =17 is required => "brew install llvm@14"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user