authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-20 17:02:29-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-20 17:02:29-05:00
loge381a42de9c0f0c5439a926b0ac99026a0373f49
tree97efb484ce5823d10cc43d24d39b4a17a72896d4
parentb0d2ebe529593566f209d34d5bbbfd72cde2a6b9
signaturelock-open Commit is signed but in an unrecognized format.

quick fix: add -mcpu=baseline support to zig0

When the build.zig logic to build libzigstage2 was converted to a cmake command, it neglected to use baseline CPU features rather than compiling with native features. This adds a hard coded flag `-mcpu=baseline` which can be used to detect the native target, but mark it as non-native so that it does not get the CPU features specific to the host used to compile libzigstage2. Full `-mcpu` support is happening in the upcoming pull request #4509, and so this "quick fix" will be cleaned up in that branch, before it is merged to master. closes #4506

2 files changed, 7 insertions(+), 0 deletions(-)

CMakeLists.txt+1
......@@ -616,6 +616,7 @@ endif()
616616
617617set(BUILD_LIBSTAGE2_ARGS "build-lib"
618618 "src-self-hosted/stage2.zig"
619 -mcpu=baseline
619620 --name zigstage2
620621 --override-lib-dir "${CMAKE_SOURCE_DIR}/lib"
621622 --cache on
src/main.cpp+6
......@@ -450,6 +450,7 @@ static int main0(int argc, char **argv) {
450450 const char *cpu = nullptr;
451451 const char *features = nullptr;
452452 CodeModel code_model = CodeModelDefault;
453 bool baseline_cpu = false;
453454
454455 ZigList<const char *> llvm_argv = {0};
455456 llvm_argv.append("zig (LLVM option parsing)");
......@@ -716,6 +717,8 @@ static int main0(int argc, char **argv) {
716717 emit_llvm_ir = true;
717718 } else if (strcmp(arg, "-fno-emit-llvm-ir") == 0) {
718719 emit_llvm_ir = false;
720 } else if (strcmp(arg, "-mcpu=baseline") == 0) {
721 baseline_cpu = true;
719722 } else if (i + 1 >= argc) {
720723 fprintf(stderr, "Expected another argument after %s\n", arg);
721724 return print_error_usage(arg0);
......@@ -977,6 +980,9 @@ static int main0(int argc, char **argv) {
977980 fprintf(stderr, "-target-glibc provided but no -target parameter\n");
978981 return print_error_usage(arg0);
979982 }
983 if (baseline_cpu) {
984 target.is_native = false;
985 }
980986 } else {
981987 if ((err = target_parse_triple(&target, target_string))) {
982988 if (err == ErrorUnknownArchitecture && target.arch != ZigLLVM_UnknownArch) {