Commit 5ec9be0b03

Andrew Kelley <andrew@ziglang.org>
2022-11-21 00:20:30
CMake: choose native CPU instead of baseline by default
1 parent 69d1ea7
Changed files (2)
src/stage1/zig0.cpp
@@ -186,7 +186,7 @@ static Error target_parse_triple(struct ZigTarget *target, const char *zig_tripl
     if (zig_triple == nullptr) {
         get_native_target(target);
 
-        if (mcpu == nullptr) {
+        if (mcpu == nullptr || strcmp(mcpu, "native") == 0) {
             target->llvm_cpu_name = ZigLLVMGetHostCPUName();
             target->llvm_cpu_features = ZigLLVMGetNativeFeatures();
         } else if (strcmp(mcpu, "baseline") == 0) {
CMakeLists.txt
@@ -121,7 +121,7 @@ string(REGEX REPLACE "\\\\" "\\\\\\\\" ZIG_LIBC_INCLUDE_DIR_ESCAPED "${ZIG_LIBC_
 option(ZIG_TEST_COVERAGE "Build Zig with test coverage instrumentation" OFF)
 
 set(ZIG_TARGET_TRIPLE "native" CACHE STRING "arch-os-abi to output binaries for")
-set(ZIG_TARGET_MCPU "baseline" CACHE STRING "-mcpu parameter to output binaries for")
+set(ZIG_TARGET_MCPU "native" CACHE STRING "-mcpu parameter to output binaries for")
 set(ZIG_EXECUTABLE "" CACHE STRING "(when cross compiling) path to already-built zig binary")
 set(ZIG_SINGLE_THREADED off CACHE BOOL "limit the zig compiler to use only 1 thread")
 set(ZIG_OMIT_STAGE2 off CACHE BOOL "omit the stage2 backend from stage1")
@@ -1036,8 +1036,8 @@ set(BUILD_ZIG2_ARGS
     "-femit-bin=${ZIG2_OBJECT}"
     -fcompiler-rt
     ${ZIG_SINGLE_THREADED_ARG}
-    -target "${ZIG_TARGET_TRIPLE}"
-    -mcpu "${ZIG_TARGET_MCPU}"
+    -target native
+    -mcpu native
     -lc
     --pkg-begin build_options "${ZIG_CONFIG_ZIG_OUT}"
     --pkg-end