mirror of
https://github.com/odin-lang/Odin.git
synced 2026-07-30 02:47:47 +00:00
Merge branch 'master' into bill/fixed-capacity-dynamic-array
This commit is contained in:
@@ -1683,7 +1683,20 @@ gb_internal void init_android_values(bool with_sdk) {
|
||||
gb_exit(1);
|
||||
}
|
||||
|
||||
bc->ODIN_ANDROID_NDK_TOOLCHAIN_LIB = concatenate_strings(permanent_allocator(), bc->ODIN_ANDROID_NDK_TOOLCHAIN, str_lit("sysroot/usr/lib/aarch64-linux-android/"));
|
||||
switch (bc->metrics.arch) {
|
||||
case TargetArch_arm64:
|
||||
bc->ODIN_ANDROID_NDK_TOOLCHAIN_LIB = str_lit("aarch64-linux-android");
|
||||
break;
|
||||
case TargetArch_arm32:
|
||||
bc->ODIN_ANDROID_NDK_TOOLCHAIN_LIB = str_lit("arm-linux-androideabi");
|
||||
break;
|
||||
case TargetArch_amd64:
|
||||
bc->ODIN_ANDROID_NDK_TOOLCHAIN_LIB = str_lit("x86_64-linux-android");
|
||||
break;
|
||||
case TargetArch_i386:
|
||||
bc->ODIN_ANDROID_NDK_TOOLCHAIN_LIB = str_lit("i686-linux-android");
|
||||
break;
|
||||
}
|
||||
|
||||
char buf[32] = {};
|
||||
gb_snprintf(buf, gb_size_of(buf), "%d/", bc->ODIN_ANDROID_API_LEVEL);
|
||||
@@ -1958,9 +1971,22 @@ gb_internal void init_build_context(TargetMetrics *cross_target, Subtarget subta
|
||||
} else if (metrics->os == TargetOs_linux && subtarget == Subtarget_Android) {
|
||||
switch (metrics->arch) {
|
||||
case TargetArch_arm64:
|
||||
bc->metrics.target_triplet = str_lit("aarch64-none-linux-android");
|
||||
bc->metrics.target_triplet = str_lit("aarch64-linux-android");
|
||||
bc->reloc_mode = RelocMode_PIC;
|
||||
break;
|
||||
case TargetArch_arm32:
|
||||
bc->metrics.target_triplet = str_lit("armv7a-linux-androideabi");
|
||||
bc->reloc_mode = RelocMode_PIC;
|
||||
break;
|
||||
case TargetArch_amd64:
|
||||
bc->metrics.target_triplet = str_lit("x86_64-linux-android");
|
||||
bc->reloc_mode = RelocMode_PIC;
|
||||
break;
|
||||
case TargetArch_i386:
|
||||
bc->metrics.target_triplet = str_lit("i686-linux-android");
|
||||
bc->reloc_mode = RelocMode_PIC;
|
||||
break;
|
||||
|
||||
default:
|
||||
GB_PANIC("Unknown architecture for -subtarget:android");
|
||||
}
|
||||
|
||||
@@ -2971,14 +2971,21 @@ gb_internal void check_comparison(CheckerContext *c, Ast *node, Operand *x, Oper
|
||||
|
||||
if (check_is_assignable_to(c, x, y->type) ||
|
||||
check_is_assignable_to(c, y, x->type)) {
|
||||
if (x->type->failure || y->type->failure) {
|
||||
// // skip any failures
|
||||
x->mode = Addressing_Value;
|
||||
x->type = t_untyped_bool;
|
||||
return;
|
||||
}
|
||||
|
||||
Type *err_type = x->type;
|
||||
bool defined = false;
|
||||
switch (op) {
|
||||
case Token_CmpEq:
|
||||
case Token_NotEq:
|
||||
defined = (is_type_comparable(x->type) && is_type_comparable(y->type)) ||
|
||||
(is_operand_nil(*x) && type_has_nil(y->type)) ||
|
||||
(is_operand_nil(*y) && type_has_nil(x->type));
|
||||
defined = ((is_operand_nil(*x) && type_has_nil(y->type)) ||
|
||||
(is_operand_nil(*y) && type_has_nil(x->type)) ||
|
||||
is_type_comparable(x->type) && is_type_comparable(y->type));
|
||||
break;
|
||||
case Token_Lt:
|
||||
case Token_Gt:
|
||||
@@ -4476,9 +4483,9 @@ gb_internal void check_binary_expr(CheckerContext *c, Operand *x, Ast *node, Typ
|
||||
truncated: r = a - b*trunc(a/b)
|
||||
floored: r = a - b*floor(a/b)
|
||||
|
||||
IFF a/0 == 0, then (a%0 == a) or (a%%0 == a)
|
||||
IFF a/0 == a, then (a%0 == 0) or (a%%0 == 0)
|
||||
IFF a/0 == 0b111..., then (a%0 == a) or (a%%0 == a)
|
||||
If and only if (⟺) a/0 == 0, then (a%0 == a) or (a%%0 == a)
|
||||
If and only if (⟺) a/0 == a, then (a%0 == 0) or (a%%0 == 0)
|
||||
If and only if (⟺) a/0 == 0b111..., then (a%0 == a) or (a%%0 == a)
|
||||
*/
|
||||
|
||||
switch (zero_behaviour) {
|
||||
|
||||
@@ -1853,7 +1853,7 @@ gb_internal Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_para
|
||||
if (is_using && (feature_flags & OptInFeatureFlag_UsingStmt) == 0) {
|
||||
ERROR_BLOCK();
|
||||
error(param, "'using' has been disallowed as it is considered bad practice to use as a statement/procedure parameter outside of immediate refactoring");
|
||||
error_line("\tIt you do require it for refactoring purposes or legacy code, it can be enabled on a per-file basis with '#+feature using-stmt'\n");
|
||||
error_line("\tIf you do require it for refactoring purposes or legacy code, it can be enabled on a per-file basis with '#+feature using-stmt'\n");
|
||||
}
|
||||
|
||||
if (type_expr == nullptr) {
|
||||
|
||||
@@ -2240,7 +2240,7 @@ gb_internal void add_type_info_type_internal(CheckerContext *c, Type *t) {
|
||||
|
||||
case Type_BitSet:
|
||||
add_type_info_type_internal(c, bt->BitSet.elem);
|
||||
add_type_info_type_internal(c, bt->BitSet.underlying);
|
||||
add_type_info_type_internal(c, bit_set_to_int(bt));
|
||||
break;
|
||||
|
||||
case Type_Pointer:
|
||||
@@ -2484,7 +2484,7 @@ gb_internal void add_min_dep_type_info(Checker *c, Type *t) {
|
||||
|
||||
case Type_BitSet:
|
||||
add_min_dep_type_info(c, bt->BitSet.elem);
|
||||
add_min_dep_type_info(c, bt->BitSet.underlying);
|
||||
add_min_dep_type_info(c, bit_set_to_int(bt));
|
||||
break;
|
||||
|
||||
case Type_Pointer:
|
||||
|
||||
@@ -676,7 +676,7 @@ try_cross_linking:;
|
||||
defer (gb_string_free(glue));
|
||||
|
||||
glue = gb_string_append_fmt(glue, "bin/clang");
|
||||
glue = gb_string_append_fmt(glue, " --target=aarch64-linux-android%d ", ODIN_ANDROID_API_LEVEL);
|
||||
glue = gb_string_append_fmt(glue, " --target=%s%d ", build_context.metrics.target_triplet, ODIN_ANDROID_API_LEVEL);
|
||||
glue = gb_string_appendc(glue, "-c \"");
|
||||
glue = gb_string_append_length(glue, ODIN_ANDROID_NDK.text, ODIN_ANDROID_NDK.len);
|
||||
glue = gb_string_appendc(glue, "sources/android/native_app_glue/android_native_app_glue.c");
|
||||
@@ -697,8 +697,9 @@ try_cross_linking:;
|
||||
|
||||
glue = gb_string_appendc(glue, "\"-I");
|
||||
glue = gb_string_append_length(glue, ODIN_ANDROID_NDK_TOOLCHAIN.text, ODIN_ANDROID_NDK_TOOLCHAIN.len);
|
||||
glue = gb_string_appendc(glue, "sysroot/usr/include/aarch64-linux-android/");
|
||||
glue = gb_string_appendc(glue, "\" ");
|
||||
glue = gb_string_appendc(glue, "sysroot/usr/include/");
|
||||
glue = gb_string_append_length(glue, ODIN_ANDROID_NDK_TOOLCHAIN_LIB.text, ODIN_ANDROID_NDK_TOOLCHAIN_LIB.len);
|
||||
glue = gb_string_appendc(glue, "/\" ");
|
||||
|
||||
|
||||
glue = gb_string_appendc(glue, "-Wno-macro-redefined ");
|
||||
@@ -969,7 +970,7 @@ try_cross_linking:;
|
||||
gbString ndk_bin_directory = gb_string_make_length(temporary_allocator(), ODIN_ANDROID_NDK_TOOLCHAIN.text, ODIN_ANDROID_NDK_TOOLCHAIN.len);
|
||||
link_command_line = gb_string_appendc(link_command_line, ndk_bin_directory);
|
||||
link_command_line = gb_string_appendc(link_command_line, "bin/clang");
|
||||
link_command_line = gb_string_append_fmt(link_command_line, " --target=aarch64-linux-android%d ", ODIN_ANDROID_API_LEVEL);
|
||||
link_command_line = gb_string_append_fmt(link_command_line, " --target=%s%d ", build_context.metrics.target_triplet, ODIN_ANDROID_API_LEVEL);
|
||||
} else {
|
||||
link_command_line = gb_string_appendc(link_command_line, clang_path);
|
||||
}
|
||||
|
||||
@@ -66,6 +66,19 @@ gb_internal String get_final_microarchitecture() {
|
||||
gb_internal String get_default_features() {
|
||||
BuildContext *bc = &build_context;
|
||||
|
||||
if (bc->microarch == str_lit("native")) {
|
||||
String features = make_string_c(LLVMGetHostCPUFeatures());
|
||||
|
||||
// Update the features string so LLVM uses it later.
|
||||
if (bc->target_features_string.len > 0) {
|
||||
bc->target_features_string = concatenate3_strings(permanent_allocator(), features, str_lit(","), bc->target_features_string);
|
||||
} else {
|
||||
bc->target_features_string = features;
|
||||
}
|
||||
|
||||
return features;
|
||||
}
|
||||
|
||||
int off = 0;
|
||||
for (int i = 0; i < bc->metrics.arch; i += 1) {
|
||||
off += target_microarch_counts[i];
|
||||
|
||||
@@ -1424,8 +1424,8 @@ gb_internal LLVMValueRef lb_integer_modulo(lbProcedure *p, LLVMValueRef lhs, LLV
|
||||
truncated: r = a - b*trunc(a/b)
|
||||
floored: r = a - b*floor(a/b)
|
||||
|
||||
IFF a/0 == 0, then (a%0 == a) or (a%%0 == a)
|
||||
IFF a/0 == a, then (a%0 == 0) or (a%%0 == 0)
|
||||
If and only if (⟺) a/0 == 0, then (a%0 == a) or (a%%0 == a)
|
||||
If and only if (⟺) a/0 == a, then (a%0 == 0) or (a%%0 == 0)
|
||||
*/
|
||||
|
||||
switch (behaviour) {
|
||||
|
||||
Reference in New Issue
Block a user