CMake: choose native CPU instead of baseline by default

This commit is contained in:
Andrew Kelley 2022-11-20 16:20:30 -07:00
parent 69d1ea769b
commit 5ec9be0b03
2 changed files with 4 additions and 4 deletions

View File

@ -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

View File

@ -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) {