From 5ec9be0b03b17c849078c2a3f652a86e723fd1c2 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 20 Nov 2022 16:20:30 -0700 Subject: [PATCH] CMake: choose native CPU instead of baseline by default --- CMakeLists.txt | 6 +++--- src/stage1/zig0.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b9a11a000..d006de0b01 100644 --- a/CMakeLists.txt +++ b/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 diff --git a/src/stage1/zig0.cpp b/src/stage1/zig0.cpp index ea0c397243..96d33a093c 100644 --- a/src/stage1/zig0.cpp +++ b/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) {