Commit ad438a95c5
Changed files (3)
src/codegen.cpp
@@ -8762,7 +8762,9 @@ void add_cc_args(CodeGen *g, ZigList<const char *> &args, const char *out_dep_pa
}
if (g->zig_target->is_native) {
- args.append("-march=native");
+ if (target_supports_clang_march_native(g->zig_target)) {
+ args.append("-march=native");
+ }
} else {
args.append("-target");
args.append(buf_ptr(&g->llvm_triple_str));
src/target.cpp
@@ -1583,9 +1583,19 @@ bool target_os_requires_libc(Os os) {
}
bool target_supports_fpic(const ZigTarget *target) {
- // This is not whether the target supports Position Independent Code, but whether the -fPIC
- // C compiler argument is valid.
- return target->os != OsWindows;
+ // This is not whether the target supports Position Independent Code, but whether the -fPIC
+ // C compiler argument is valid.
+ return target->os != OsWindows;
+}
+
+bool target_supports_clang_march_native(const ZigTarget *target) {
+ // Whether clang supports -march=native on this target.
+ // Arguably it should always work, but in reality it gives:
+ // error: the clang compiler does not support '-march=native'
+ // If we move CPU detection logic into Zig itelf, we will not need this,
+ // instead we will always pass target features and CPU configuration explicitly.
+ return target->arch != ZigLLVM_aarch64 &&
+ target->arch != ZigLLVM_aarch64_be;
}
bool target_supports_stack_probing(const ZigTarget *target) {
src/target.hpp
@@ -182,6 +182,7 @@ bool target_can_build_libc(const ZigTarget *target);
const char *target_libc_generic_name(const ZigTarget *target);
bool target_is_libc_lib_name(const ZigTarget *target, const char *name);
bool target_supports_fpic(const ZigTarget *target);
+bool target_supports_clang_march_native(const ZigTarget *target);
bool target_requires_pic(const ZigTarget *target, bool linking_libc);
bool target_requires_pie(const ZigTarget *target);
bool target_abi_is_gnu(ZigLLVM_EnvironmentType abi);