MaskRay created this revision. MaskRay added reviewers: hvdijk, phosek, sylvestre.ledru, tstellar. Herald added subscribers: abrachet, pengfei. Herald added a reviewer: ctetreau. Herald added a reviewer: ctetreau. MaskRay requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
This changed `-dumpmachine` does no normalization and follows GCC more closely (`gcc -dumpmachine` on Debian may be `x86_64-linux-gnu`). --- Vendors have different ideas on the canonical triple. llvm/cmake/config.guess prefers x86_64-unknown-linux-gnu. RedHat prefers x86_64-redhat-linux. Suse prefers x86_64-suse-linux. Debian/Ubuntu prefer x86_64-linux-gnu. Traditionally they contribute their normalization rules to Triple.cpp or Clang Driver. This is an unfortunate state: (a) less popular systems tend to patch Clang downstream (b) Clang Driver has unneeded complexity. To fix the unfortunate state, we should just respect --target/LLVM_DEFAULT_TARGET_TRIPLE and do no normalization at all. `-dumpmachine` can be handy when the user wants the configure-time LLVM_DEFAULT_TARGET_TRIPLE. `--print-target-triple` still prints the normalized triple. I think we probably should remove its usage in CMake compiler-rt in favor of `-dumpmachine`. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D111367 Files: clang/lib/Driver/Driver.cpp clang/test/Driver/dumpmachine.c Index: clang/test/Driver/dumpmachine.c =================================================================== --- /dev/null +++ clang/test/Driver/dumpmachine.c @@ -0,0 +1,16 @@ +/// Test that -dumpmachine prints the triple without normalization. + +/// config.guess may prefer x86_64-pc-linux-gnu, but we respect --target= verbatim. +// RUN: %clang --target=x86_64-linux-gnu -dumpmachine | FileCheck %s --check-prefix=X86_64 +// X86_64: x86_64-linux-gnu + +/// Note: GCC doesn't convert -dumpmachine output for multilib -m32/-mx32/-m64. +// RUN: %clang --target=x86_64-redhat-linux -m32 -dumpmachine | FileCheck %s --check-prefix=X86_64_M32 +// X86_64_M32: i386-redhat-linux + +// RUN: %clang --target=xxx-pc-freebsd -dumpmachine | FileCheck %s --check-prefix=XXX +// XXX: xxx-pc-freebsd + +/// Fuchsia prefers normalization. +// RUN: %clang --target=aarch64-fuchsia -dumpmachine | FileCheck %s --check-prefix=FUCHSIA +// FUCHSIA: aarch64-unknown-fuchsia Index: clang/lib/Driver/Driver.cpp =================================================================== --- clang/lib/Driver/Driver.cpp +++ clang/lib/Driver/Driver.cpp @@ -1770,7 +1770,7 @@ // don't expect inconsistencies w.r.t. that to matter in practice. if (C.getArgs().hasArg(options::OPT_dumpmachine)) { - llvm::outs() << C.getDefaultToolChain().getTripleString() << '\n'; + llvm::outs() << C.getDriver().getTargetTriple() << '\n'; return false; }
Index: clang/test/Driver/dumpmachine.c =================================================================== --- /dev/null +++ clang/test/Driver/dumpmachine.c @@ -0,0 +1,16 @@ +/// Test that -dumpmachine prints the triple without normalization. + +/// config.guess may prefer x86_64-pc-linux-gnu, but we respect --target= verbatim. +// RUN: %clang --target=x86_64-linux-gnu -dumpmachine | FileCheck %s --check-prefix=X86_64 +// X86_64: x86_64-linux-gnu + +/// Note: GCC doesn't convert -dumpmachine output for multilib -m32/-mx32/-m64. +// RUN: %clang --target=x86_64-redhat-linux -m32 -dumpmachine | FileCheck %s --check-prefix=X86_64_M32 +// X86_64_M32: i386-redhat-linux + +// RUN: %clang --target=xxx-pc-freebsd -dumpmachine | FileCheck %s --check-prefix=XXX +// XXX: xxx-pc-freebsd + +/// Fuchsia prefers normalization. +// RUN: %clang --target=aarch64-fuchsia -dumpmachine | FileCheck %s --check-prefix=FUCHSIA +// FUCHSIA: aarch64-unknown-fuchsia Index: clang/lib/Driver/Driver.cpp =================================================================== --- clang/lib/Driver/Driver.cpp +++ clang/lib/Driver/Driver.cpp @@ -1770,7 +1770,7 @@ // don't expect inconsistencies w.r.t. that to matter in practice. if (C.getArgs().hasArg(options::OPT_dumpmachine)) { - llvm::outs() << C.getDefaultToolChain().getTripleString() << '\n'; + llvm::outs() << C.getDriver().getTargetTriple() << '\n'; return false; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits