[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
https://github.com/perry-ca edited https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
perry-ca wrote: ping @MaskRay. Thanks https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
MaskRay wrote: Clang configuration files https://clang.llvm.org/docs/UsersManual.html#configuration-files cover your use case and the feature is exactly designed to avoid such cmake default configs. https://blogs.gentoo.org/mgorny/2022/10/07/clang-in-gentoo-now-sets-default-runtimes-via-config-file/ You can add `-march=...` in` clang.cfg` beside the `clang` executable. https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
perry-ca wrote: @MaskRay Got it. The problem with that solution is that if you use --target you won't get the correct arch. This would be a problem for any cross compilation. For example, say you cross compile from zLinux (which wouldn't have the config file), the arch would be arch8. And if you cross compiled from z/OS (with the config file) to zLinux then the default arch would be arch10. Both of these would be incorrect. We also use the config files for installation specific information. It is common for users to have their own config files. If we require that the option be in the config file then we would be creating a very error prone situation. We need to be able to change the arch default based on the target triple. https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/89854 >From 85da4a229ddeeb6c86ecfb0ba19ac921494a2b40 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Tue, 23 Apr 2024 20:16:15 -0500 Subject: [PATCH] Set the default arch for z/OS to be arch10 --- clang/CMakeLists.txt | 2 ++ clang/include/clang/Config/config.h.cmake| 3 +++ clang/lib/Basic/Targets/SystemZ.h| 7 +++ clang/lib/Driver/ToolChains/Arch/SystemZ.cpp | 5 - clang/lib/Driver/ToolChains/Arch/SystemZ.h | 3 ++- clang/lib/Driver/ToolChains/CommonArgs.cpp | 2 +- clang/lib/Driver/ToolChains/Gnu.cpp | 3 ++- clang/test/Preprocessor/predefined-arch-macros.c | 16 8 files changed, 33 insertions(+), 8 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index f092766fa19f0..f06fbec1d02f9 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -270,6 +270,8 @@ set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING set(CLANG_SYSTEMZ_DEFAULT_ARCH "z10" CACHE STRING "SystemZ Default Arch") +set(CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH "zEC12" CACHE STRING "SystemZ z/OS Default Arch") + set(CLANG_VENDOR ${PACKAGE_VENDOR} CACHE STRING "Vendor-specific text for showing with version information.") diff --git a/clang/include/clang/Config/config.h.cmake b/clang/include/clang/Config/config.h.cmake index 27ed69e21562b..004c5c95c00cf 100644 --- a/clang/include/clang/Config/config.h.cmake +++ b/clang/include/clang/Config/config.h.cmake @@ -32,6 +32,9 @@ /* Default architecture for SystemZ. */ #define CLANG_SYSTEMZ_DEFAULT_ARCH "${CLANG_SYSTEMZ_DEFAULT_ARCH}" +/* Default architecture for SystemZ for z/OS. */ +#define CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH "${CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH}" + /* Multilib basename for libdir. */ #define CLANG_INSTALL_LIBDIR_BASENAME "${CLANG_INSTALL_LIBDIR_BASENAME}" diff --git a/clang/lib/Basic/Targets/SystemZ.h b/clang/lib/Basic/Targets/SystemZ.h index 8e302acd51b8a..45fb7e447b642 100644 --- a/clang/lib/Basic/Targets/SystemZ.h +++ b/clang/lib/Basic/Targets/SystemZ.h @@ -24,7 +24,6 @@ namespace targets { class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { static const char *const GCCRegNames[]; - std::string CPU; int ISARevision; bool HasTransactionalExecution; bool HasVector; @@ -33,7 +32,8 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { public: SystemZTargetInfo(const llvm::Triple &Triple, const TargetOptions &) - : TargetInfo(Triple), CPU("z10"), ISARevision(8), + : TargetInfo(Triple), +ISARevision(getISARevision(Triple.isOSzOS() ? "zEC12" : "z10")), HasTransactionalExecution(false), HasVector(false), SoftFloat(false), UnalignedSymbols(false) { IntMaxType = SignedLong; @@ -140,8 +140,7 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { } bool setCPU(const std::string &Name) override { -CPU = Name; -ISARevision = getISARevision(CPU); +ISARevision = getISARevision(Name); return ISARevision != -1; } diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp index 2213f431eb811..7baeffc00053a 100644 --- a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp +++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp @@ -34,7 +34,8 @@ systemz::FloatABI systemz::getSystemZFloatABI(const Driver &D, return ABI; } -std::string systemz::getSystemZTargetCPU(const ArgList &Args) { +std::string systemz::getSystemZTargetCPU(const Driver &, const ArgList &Args, + const llvm::Triple &T) { if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) { llvm::StringRef CPUName = A->getValue(); @@ -48,6 +49,8 @@ std::string systemz::getSystemZTargetCPU(const ArgList &Args) { return std::string(CPUName); } + if (T.isOSzOS()) +return CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH; return CLANG_SYSTEMZ_DEFAULT_ARCH; } diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.h b/clang/lib/Driver/ToolChains/Arch/SystemZ.h index 1e42b68a8f3c2..438dab8765bc3 100644 --- a/clang/lib/Driver/ToolChains/Arch/SystemZ.h +++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.h @@ -27,7 +27,8 @@ enum class FloatABI { FloatABI getSystemZFloatABI(const Driver &D, const llvm::opt::ArgList &Args); -std::string getSystemZTargetCPU(const llvm::opt::ArgList &Args); +std::string getSystemZTargetCPU(const Driver &D, const llvm::opt::ArgList &Args, +const llvm::Triple &T); void getSystemZTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args, std::vector &Features); diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index b65b96db16bd7..73f5abfaafcba 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/89854 >From 85da4a229ddeeb6c86ecfb0ba19ac921494a2b40 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Tue, 23 Apr 2024 20:16:15 -0500 Subject: [PATCH 1/2] Set the default arch for z/OS to be arch10 --- clang/CMakeLists.txt | 2 ++ clang/include/clang/Config/config.h.cmake| 3 +++ clang/lib/Basic/Targets/SystemZ.h| 7 +++ clang/lib/Driver/ToolChains/Arch/SystemZ.cpp | 5 - clang/lib/Driver/ToolChains/Arch/SystemZ.h | 3 ++- clang/lib/Driver/ToolChains/CommonArgs.cpp | 2 +- clang/lib/Driver/ToolChains/Gnu.cpp | 3 ++- clang/test/Preprocessor/predefined-arch-macros.c | 16 8 files changed, 33 insertions(+), 8 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index f092766fa19f0..f06fbec1d02f9 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -270,6 +270,8 @@ set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING set(CLANG_SYSTEMZ_DEFAULT_ARCH "z10" CACHE STRING "SystemZ Default Arch") +set(CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH "zEC12" CACHE STRING "SystemZ z/OS Default Arch") + set(CLANG_VENDOR ${PACKAGE_VENDOR} CACHE STRING "Vendor-specific text for showing with version information.") diff --git a/clang/include/clang/Config/config.h.cmake b/clang/include/clang/Config/config.h.cmake index 27ed69e21562b..004c5c95c00cf 100644 --- a/clang/include/clang/Config/config.h.cmake +++ b/clang/include/clang/Config/config.h.cmake @@ -32,6 +32,9 @@ /* Default architecture for SystemZ. */ #define CLANG_SYSTEMZ_DEFAULT_ARCH "${CLANG_SYSTEMZ_DEFAULT_ARCH}" +/* Default architecture for SystemZ for z/OS. */ +#define CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH "${CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH}" + /* Multilib basename for libdir. */ #define CLANG_INSTALL_LIBDIR_BASENAME "${CLANG_INSTALL_LIBDIR_BASENAME}" diff --git a/clang/lib/Basic/Targets/SystemZ.h b/clang/lib/Basic/Targets/SystemZ.h index 8e302acd51b8a..45fb7e447b642 100644 --- a/clang/lib/Basic/Targets/SystemZ.h +++ b/clang/lib/Basic/Targets/SystemZ.h @@ -24,7 +24,6 @@ namespace targets { class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { static const char *const GCCRegNames[]; - std::string CPU; int ISARevision; bool HasTransactionalExecution; bool HasVector; @@ -33,7 +32,8 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { public: SystemZTargetInfo(const llvm::Triple &Triple, const TargetOptions &) - : TargetInfo(Triple), CPU("z10"), ISARevision(8), + : TargetInfo(Triple), +ISARevision(getISARevision(Triple.isOSzOS() ? "zEC12" : "z10")), HasTransactionalExecution(false), HasVector(false), SoftFloat(false), UnalignedSymbols(false) { IntMaxType = SignedLong; @@ -140,8 +140,7 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { } bool setCPU(const std::string &Name) override { -CPU = Name; -ISARevision = getISARevision(CPU); +ISARevision = getISARevision(Name); return ISARevision != -1; } diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp index 2213f431eb811..7baeffc00053a 100644 --- a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp +++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp @@ -34,7 +34,8 @@ systemz::FloatABI systemz::getSystemZFloatABI(const Driver &D, return ABI; } -std::string systemz::getSystemZTargetCPU(const ArgList &Args) { +std::string systemz::getSystemZTargetCPU(const Driver &, const ArgList &Args, + const llvm::Triple &T) { if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) { llvm::StringRef CPUName = A->getValue(); @@ -48,6 +49,8 @@ std::string systemz::getSystemZTargetCPU(const ArgList &Args) { return std::string(CPUName); } + if (T.isOSzOS()) +return CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH; return CLANG_SYSTEMZ_DEFAULT_ARCH; } diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.h b/clang/lib/Driver/ToolChains/Arch/SystemZ.h index 1e42b68a8f3c2..438dab8765bc3 100644 --- a/clang/lib/Driver/ToolChains/Arch/SystemZ.h +++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.h @@ -27,7 +27,8 @@ enum class FloatABI { FloatABI getSystemZFloatABI(const Driver &D, const llvm::opt::ArgList &Args); -std::string getSystemZTargetCPU(const llvm::opt::ArgList &Args); +std::string getSystemZTargetCPU(const Driver &D, const llvm::opt::ArgList &Args, +const llvm::Triple &T); void getSystemZTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args, std::vector &Features); diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index b65b96db16bd7..73f5abfaafcba 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Dr
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
perry-ca wrote: I removed the ability to make z/OS default arch configurable at build time. We don't really need it and this makes the code simpler. https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
MaskRay wrote: > @MaskRay Got it. > > The problem with that solution is that if you use --target you won't get the > correct arch. This would be a problem for any cross compilation. For example, > say you cross compile from zLinux (which wouldn't have the config file), the > arch would be arch8. And if you cross compiled from z/OS (with the config > file) to zLinux then the default arch would be arch10. Both of these would be > incorrect. > > We also use the config files for installation specific information. It is > common for users to have their own config files. If we require that the > option be in the config file then we would be creating a very error prone > situation. > > We need to be able to change the arch default based on the target triple. Sorry for the late reply. Such driver defaults via cmake variable would make testing brittle. Users expect that `check-clang` pass regardless of the cmake variable setting. If a test changes behavior due to different `-march=`, there are a few choices: * add a `REQUIRES: zos-new-default-march` directive * hard code a `-march=` Neither is immediately noticeable. In the past clang/test/Driver has had many such tests that require fixup. We have tried removing some unnecessary `CLANG_DEFAULT_*`. https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
perry-ca wrote: @MaskRay no worries. This brittle test issue was a reason I trying to keep the default for zLinux unchanged by this. I have posted a new commit that eliminates the cmake variable for z/OS. https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
@@ -11,6 +11,8 @@ // //===--===// +#include "clang/Config/config.h" MaskRay wrote: unneeded include https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
@@ -10,6 +10,8 @@ // //===--===// +#include "clang/Config/config.h" MaskRay wrote: unneeded include https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
@@ -11,6 +11,8 @@ // //===--===// +#include "clang/Config/config.h" perry-ca wrote: This is needed for the change in SystemZ.h to replace the hard coded `"z10"` string with the CLANG_SYSTEMZ_DEFAULT_ARCH cmake variable. This applies to the other comment too. https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
@@ -11,6 +11,8 @@ // //===--===// +#include "clang/Config/config.h" MaskRay wrote: If SystemZ.h uses CLANG_SYSTEMZ_DEFAULT_ARCH, that file should have `#include "clang/Config/config.h"` as IWYU https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
@@ -11,6 +11,8 @@ // //===--===// +#include "clang/Config/config.h" perry-ca wrote: That was my preference too except clang/Config/config.h has a clause that it can only be included once and will generate an error if it is included a second time. https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
MaskRay wrote: > > @MaskRay Got it. > > The problem with that solution is that if you use --target you won't get > > the correct arch. This would be a problem for any cross compilation. For > > example, say you cross compile from zLinux (which wouldn't have the config > > file), the arch would be arch8. And if you cross compiled from z/OS (with > > the config file) to zLinux then the default arch would be arch10. Both of > > these would be incorrect. > > We also use the config files for installation specific information. It is > > common for users to have their own config files. If we require that the > > option be in the config file then we would be creating a very error prone > > situation. > > We need to be able to change the arch default based on the target triple. > > Sorry for the late reply. Such driver defaults via cmake variable would make > testing brittle. Users expect that `check-clang` pass regardless of the cmake > variable setting. If a test changes behavior due to different `-march=`, > there are a few choices: > > * add a `REQUIRES: zos-new-default-march` directive > * hard code a `-march=` > > Neither is immediately noticeable. In the past clang/test/Driver has had many > such tests that require fixup. We have tried removing some unnecessary > `CLANG_DEFAULT_*`. I just realized that https://reviews.llvm.org/D75914 added `CLANG_SYSTEMZ_DEFAULT_ARCH` for Ubuntu. @xnox @uweigand I think we want to avoid such CMake options/clang `config.h` As an alternative, if the clang executable is at `/tmp/Rel/bin/clang`, you can add `/tmp/Rel/bin/s390x-unknown-linux-gnu.cfg` with content `-march=z13`. https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/89854 >From 85da4a229ddeeb6c86ecfb0ba19ac921494a2b40 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Tue, 23 Apr 2024 20:16:15 -0500 Subject: [PATCH 1/2] Set the default arch for z/OS to be arch10 --- clang/CMakeLists.txt | 2 ++ clang/include/clang/Config/config.h.cmake| 3 +++ clang/lib/Basic/Targets/SystemZ.h| 7 +++ clang/lib/Driver/ToolChains/Arch/SystemZ.cpp | 5 - clang/lib/Driver/ToolChains/Arch/SystemZ.h | 3 ++- clang/lib/Driver/ToolChains/CommonArgs.cpp | 2 +- clang/lib/Driver/ToolChains/Gnu.cpp | 3 ++- clang/test/Preprocessor/predefined-arch-macros.c | 16 8 files changed, 33 insertions(+), 8 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index f092766fa19f0..f06fbec1d02f9 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -270,6 +270,8 @@ set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING set(CLANG_SYSTEMZ_DEFAULT_ARCH "z10" CACHE STRING "SystemZ Default Arch") +set(CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH "zEC12" CACHE STRING "SystemZ z/OS Default Arch") + set(CLANG_VENDOR ${PACKAGE_VENDOR} CACHE STRING "Vendor-specific text for showing with version information.") diff --git a/clang/include/clang/Config/config.h.cmake b/clang/include/clang/Config/config.h.cmake index 27ed69e21562b..004c5c95c00cf 100644 --- a/clang/include/clang/Config/config.h.cmake +++ b/clang/include/clang/Config/config.h.cmake @@ -32,6 +32,9 @@ /* Default architecture for SystemZ. */ #define CLANG_SYSTEMZ_DEFAULT_ARCH "${CLANG_SYSTEMZ_DEFAULT_ARCH}" +/* Default architecture for SystemZ for z/OS. */ +#define CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH "${CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH}" + /* Multilib basename for libdir. */ #define CLANG_INSTALL_LIBDIR_BASENAME "${CLANG_INSTALL_LIBDIR_BASENAME}" diff --git a/clang/lib/Basic/Targets/SystemZ.h b/clang/lib/Basic/Targets/SystemZ.h index 8e302acd51b8a..45fb7e447b642 100644 --- a/clang/lib/Basic/Targets/SystemZ.h +++ b/clang/lib/Basic/Targets/SystemZ.h @@ -24,7 +24,6 @@ namespace targets { class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { static const char *const GCCRegNames[]; - std::string CPU; int ISARevision; bool HasTransactionalExecution; bool HasVector; @@ -33,7 +32,8 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { public: SystemZTargetInfo(const llvm::Triple &Triple, const TargetOptions &) - : TargetInfo(Triple), CPU("z10"), ISARevision(8), + : TargetInfo(Triple), +ISARevision(getISARevision(Triple.isOSzOS() ? "zEC12" : "z10")), HasTransactionalExecution(false), HasVector(false), SoftFloat(false), UnalignedSymbols(false) { IntMaxType = SignedLong; @@ -140,8 +140,7 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { } bool setCPU(const std::string &Name) override { -CPU = Name; -ISARevision = getISARevision(CPU); +ISARevision = getISARevision(Name); return ISARevision != -1; } diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp index 2213f431eb811..7baeffc00053a 100644 --- a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp +++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp @@ -34,7 +34,8 @@ systemz::FloatABI systemz::getSystemZFloatABI(const Driver &D, return ABI; } -std::string systemz::getSystemZTargetCPU(const ArgList &Args) { +std::string systemz::getSystemZTargetCPU(const Driver &, const ArgList &Args, + const llvm::Triple &T) { if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) { llvm::StringRef CPUName = A->getValue(); @@ -48,6 +49,8 @@ std::string systemz::getSystemZTargetCPU(const ArgList &Args) { return std::string(CPUName); } + if (T.isOSzOS()) +return CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH; return CLANG_SYSTEMZ_DEFAULT_ARCH; } diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.h b/clang/lib/Driver/ToolChains/Arch/SystemZ.h index 1e42b68a8f3c2..438dab8765bc3 100644 --- a/clang/lib/Driver/ToolChains/Arch/SystemZ.h +++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.h @@ -27,7 +27,8 @@ enum class FloatABI { FloatABI getSystemZFloatABI(const Driver &D, const llvm::opt::ArgList &Args); -std::string getSystemZTargetCPU(const llvm::opt::ArgList &Args); +std::string getSystemZTargetCPU(const Driver &D, const llvm::opt::ArgList &Args, +const llvm::Triple &T); void getSystemZTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args, std::vector &Features); diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index b65b96db16bd7..73f5abfaafcba 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Dr
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
xnox wrote: @fhe > > > @MaskRay Got it. > > > The problem with that solution is that if you use --target you won't get > > > the correct arch. This would be a problem for any cross compilation. For > > > example, say you cross compile from zLinux (which wouldn't have the > > > config file), the arch would be arch8. And if you cross compiled from > > > z/OS (with the config file) to zLinux then the default arch would be > > > arch10. Both of these would be incorrect. > > > We also use the config files for installation specific information. It is > > > common for users to have their own config files. If we require that the > > > option be in the config file then we would be creating a very error prone > > > situation. > > > We need to be able to change the arch default based on the target triple. > > > > > > Sorry for the late reply. Such driver defaults via cmake variable would > > make testing brittle. Users expect that `check-clang` pass regardless of > > the cmake variable setting. If a test changes behavior due to different > > `-march=`, there are a few choices: > > > > * add a `REQUIRES: zos-new-default-march` directive > > * hard code a `-march=` > > > > Neither is immediately noticeable. In the past clang/test/Driver has had > > many such tests that require fixup. We have tried removing some unnecessary > > `CLANG_DEFAULT_*`. > > I just realized that https://reviews.llvm.org/D75914 added > `CLANG_SYSTEMZ_DEFAULT_ARCH` for Ubuntu. @xnox @uweigand > > I think we want to avoid such CMake options/clang `config.h` > > As an alternative, if the clang executable is at `/tmp/Rel/bin/clang`, you > can add `/tmp/Rel/bin/s390x-unknown-linux-gnu.cfg` with content `-march=z13`. > > Once we drop `CLANG_SYSTEMZ_DEFAULT_ARCH`, the `config.h` include will not be > needed. I don't understand your proposal. In Ubuntu we need to set built-in default arch value, to a higher one than upstream has it at, for all builds without any toolchain configs. Such that any builds with any toolchain configs by default target a higher arch setting. arch10 is way too old and slow. and z13 might not be enough either for latest devel distributions, i.e. next development ubuntu release may be bumping further above z13. https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
perry-ca wrote: ping @MaskRay ^^^ https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/89854 >From 85da4a229ddeeb6c86ecfb0ba19ac921494a2b40 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Tue, 23 Apr 2024 20:16:15 -0500 Subject: [PATCH 1/3] Set the default arch for z/OS to be arch10 --- clang/CMakeLists.txt | 2 ++ clang/include/clang/Config/config.h.cmake| 3 +++ clang/lib/Basic/Targets/SystemZ.h| 7 +++ clang/lib/Driver/ToolChains/Arch/SystemZ.cpp | 5 - clang/lib/Driver/ToolChains/Arch/SystemZ.h | 3 ++- clang/lib/Driver/ToolChains/CommonArgs.cpp | 2 +- clang/lib/Driver/ToolChains/Gnu.cpp | 3 ++- clang/test/Preprocessor/predefined-arch-macros.c | 16 8 files changed, 33 insertions(+), 8 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index f092766fa19f0..f06fbec1d02f9 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -270,6 +270,8 @@ set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING set(CLANG_SYSTEMZ_DEFAULT_ARCH "z10" CACHE STRING "SystemZ Default Arch") +set(CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH "zEC12" CACHE STRING "SystemZ z/OS Default Arch") + set(CLANG_VENDOR ${PACKAGE_VENDOR} CACHE STRING "Vendor-specific text for showing with version information.") diff --git a/clang/include/clang/Config/config.h.cmake b/clang/include/clang/Config/config.h.cmake index 27ed69e21562b..004c5c95c00cf 100644 --- a/clang/include/clang/Config/config.h.cmake +++ b/clang/include/clang/Config/config.h.cmake @@ -32,6 +32,9 @@ /* Default architecture for SystemZ. */ #define CLANG_SYSTEMZ_DEFAULT_ARCH "${CLANG_SYSTEMZ_DEFAULT_ARCH}" +/* Default architecture for SystemZ for z/OS. */ +#define CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH "${CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH}" + /* Multilib basename for libdir. */ #define CLANG_INSTALL_LIBDIR_BASENAME "${CLANG_INSTALL_LIBDIR_BASENAME}" diff --git a/clang/lib/Basic/Targets/SystemZ.h b/clang/lib/Basic/Targets/SystemZ.h index 8e302acd51b8a..45fb7e447b642 100644 --- a/clang/lib/Basic/Targets/SystemZ.h +++ b/clang/lib/Basic/Targets/SystemZ.h @@ -24,7 +24,6 @@ namespace targets { class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { static const char *const GCCRegNames[]; - std::string CPU; int ISARevision; bool HasTransactionalExecution; bool HasVector; @@ -33,7 +32,8 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { public: SystemZTargetInfo(const llvm::Triple &Triple, const TargetOptions &) - : TargetInfo(Triple), CPU("z10"), ISARevision(8), + : TargetInfo(Triple), +ISARevision(getISARevision(Triple.isOSzOS() ? "zEC12" : "z10")), HasTransactionalExecution(false), HasVector(false), SoftFloat(false), UnalignedSymbols(false) { IntMaxType = SignedLong; @@ -140,8 +140,7 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { } bool setCPU(const std::string &Name) override { -CPU = Name; -ISARevision = getISARevision(CPU); +ISARevision = getISARevision(Name); return ISARevision != -1; } diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp index 2213f431eb811..7baeffc00053a 100644 --- a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp +++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp @@ -34,7 +34,8 @@ systemz::FloatABI systemz::getSystemZFloatABI(const Driver &D, return ABI; } -std::string systemz::getSystemZTargetCPU(const ArgList &Args) { +std::string systemz::getSystemZTargetCPU(const Driver &, const ArgList &Args, + const llvm::Triple &T) { if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) { llvm::StringRef CPUName = A->getValue(); @@ -48,6 +49,8 @@ std::string systemz::getSystemZTargetCPU(const ArgList &Args) { return std::string(CPUName); } + if (T.isOSzOS()) +return CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH; return CLANG_SYSTEMZ_DEFAULT_ARCH; } diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.h b/clang/lib/Driver/ToolChains/Arch/SystemZ.h index 1e42b68a8f3c2..438dab8765bc3 100644 --- a/clang/lib/Driver/ToolChains/Arch/SystemZ.h +++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.h @@ -27,7 +27,8 @@ enum class FloatABI { FloatABI getSystemZFloatABI(const Driver &D, const llvm::opt::ArgList &Args); -std::string getSystemZTargetCPU(const llvm::opt::ArgList &Args); +std::string getSystemZTargetCPU(const Driver &D, const llvm::opt::ArgList &Args, +const llvm::Triple &T); void getSystemZTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args, std::vector &Features); diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index b65b96db16bd7..73f5abfaafcba 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Dr
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 2ace7bdcfe640c69bd4dcf508d39485e0ef7ea06 fe5ad9c1bc0b1c0d60451f017d7ec7a8233aaf26 -- clang/lib/Basic/Targets/SystemZ.h clang/lib/Driver/ToolChains/Arch/SystemZ.cpp clang/lib/Driver/ToolChains/Arch/SystemZ.h clang/lib/Driver/ToolChains/CommonArgs.cpp clang/lib/Driver/ToolChains/Gnu.cpp clang/test/Preprocessor/predefined-arch-macros.c `` View the diff from clang-format here. ``diff diff --git a/clang/lib/Basic/Targets/SystemZ.h b/clang/lib/Basic/Targets/SystemZ.h index 15df4f3df6..a6e08ea993 100644 --- a/clang/lib/Basic/Targets/SystemZ.h +++ b/clang/lib/Basic/Targets/SystemZ.h @@ -32,8 +32,7 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { public: SystemZTargetInfo(const llvm::Triple &Triple, const TargetOptions &) - : TargetInfo(Triple), -ISARevision(getISARevision("z10")), + : TargetInfo(Triple), ISARevision(getISARevision("z10")), HasTransactionalExecution(false), HasVector(false), SoftFloat(false), UnalignedSymbols(false) { IntMaxType = SignedLong; `` https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
perry-ca wrote: I removed the additional use of CLANG_SYSTEMZ_DEFAULT_ARCH and left that for a separate discussion. The only code clean up left here is the elimination of the `CPU` member that wasn't used. https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/89854 >From 85da4a229ddeeb6c86ecfb0ba19ac921494a2b40 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Tue, 23 Apr 2024 20:16:15 -0500 Subject: [PATCH 1/4] Set the default arch for z/OS to be arch10 --- clang/CMakeLists.txt | 2 ++ clang/include/clang/Config/config.h.cmake| 3 +++ clang/lib/Basic/Targets/SystemZ.h| 7 +++ clang/lib/Driver/ToolChains/Arch/SystemZ.cpp | 5 - clang/lib/Driver/ToolChains/Arch/SystemZ.h | 3 ++- clang/lib/Driver/ToolChains/CommonArgs.cpp | 2 +- clang/lib/Driver/ToolChains/Gnu.cpp | 3 ++- clang/test/Preprocessor/predefined-arch-macros.c | 16 8 files changed, 33 insertions(+), 8 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index f092766fa19f0..f06fbec1d02f9 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -270,6 +270,8 @@ set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING set(CLANG_SYSTEMZ_DEFAULT_ARCH "z10" CACHE STRING "SystemZ Default Arch") +set(CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH "zEC12" CACHE STRING "SystemZ z/OS Default Arch") + set(CLANG_VENDOR ${PACKAGE_VENDOR} CACHE STRING "Vendor-specific text for showing with version information.") diff --git a/clang/include/clang/Config/config.h.cmake b/clang/include/clang/Config/config.h.cmake index 27ed69e21562b..004c5c95c00cf 100644 --- a/clang/include/clang/Config/config.h.cmake +++ b/clang/include/clang/Config/config.h.cmake @@ -32,6 +32,9 @@ /* Default architecture for SystemZ. */ #define CLANG_SYSTEMZ_DEFAULT_ARCH "${CLANG_SYSTEMZ_DEFAULT_ARCH}" +/* Default architecture for SystemZ for z/OS. */ +#define CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH "${CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH}" + /* Multilib basename for libdir. */ #define CLANG_INSTALL_LIBDIR_BASENAME "${CLANG_INSTALL_LIBDIR_BASENAME}" diff --git a/clang/lib/Basic/Targets/SystemZ.h b/clang/lib/Basic/Targets/SystemZ.h index 8e302acd51b8a..45fb7e447b642 100644 --- a/clang/lib/Basic/Targets/SystemZ.h +++ b/clang/lib/Basic/Targets/SystemZ.h @@ -24,7 +24,6 @@ namespace targets { class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { static const char *const GCCRegNames[]; - std::string CPU; int ISARevision; bool HasTransactionalExecution; bool HasVector; @@ -33,7 +32,8 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { public: SystemZTargetInfo(const llvm::Triple &Triple, const TargetOptions &) - : TargetInfo(Triple), CPU("z10"), ISARevision(8), + : TargetInfo(Triple), +ISARevision(getISARevision(Triple.isOSzOS() ? "zEC12" : "z10")), HasTransactionalExecution(false), HasVector(false), SoftFloat(false), UnalignedSymbols(false) { IntMaxType = SignedLong; @@ -140,8 +140,7 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { } bool setCPU(const std::string &Name) override { -CPU = Name; -ISARevision = getISARevision(CPU); +ISARevision = getISARevision(Name); return ISARevision != -1; } diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp index 2213f431eb811..7baeffc00053a 100644 --- a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp +++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp @@ -34,7 +34,8 @@ systemz::FloatABI systemz::getSystemZFloatABI(const Driver &D, return ABI; } -std::string systemz::getSystemZTargetCPU(const ArgList &Args) { +std::string systemz::getSystemZTargetCPU(const Driver &, const ArgList &Args, + const llvm::Triple &T) { if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) { llvm::StringRef CPUName = A->getValue(); @@ -48,6 +49,8 @@ std::string systemz::getSystemZTargetCPU(const ArgList &Args) { return std::string(CPUName); } + if (T.isOSzOS()) +return CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH; return CLANG_SYSTEMZ_DEFAULT_ARCH; } diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.h b/clang/lib/Driver/ToolChains/Arch/SystemZ.h index 1e42b68a8f3c2..438dab8765bc3 100644 --- a/clang/lib/Driver/ToolChains/Arch/SystemZ.h +++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.h @@ -27,7 +27,8 @@ enum class FloatABI { FloatABI getSystemZFloatABI(const Driver &D, const llvm::opt::ArgList &Args); -std::string getSystemZTargetCPU(const llvm::opt::ArgList &Args); +std::string getSystemZTargetCPU(const Driver &D, const llvm::opt::ArgList &Args, +const llvm::Triple &T); void getSystemZTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args, std::vector &Features); diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index b65b96db16bd7..73f5abfaafcba 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Dr
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
MaskRay wrote: > @FHe > > > > > @MaskRay Got it. > > > > The problem with that solution is that if you use --target you won't > > > > get the correct arch. This would be a problem for any cross > > > > compilation. For example, say you cross compile from zLinux (which > > > > wouldn't have the config file), the arch would be arch8. And if you > > > > cross compiled from z/OS (with the config file) to zLinux then the > > > > default arch would be arch10. Both of these would be incorrect. > > > > We also use the config files for installation specific information. It > > > > is common for users to have their own config files. If we require that > > > > the option be in the config file then we would be creating a very error > > > > prone situation. > > > > We need to be able to change the arch default based on the target > > > > triple. > > > > > > > > > Sorry for the late reply. Such driver defaults via cmake variable would > > > make testing brittle. Users expect that `check-clang` pass regardless of > > > the cmake variable setting. If a test changes behavior due to different > > > `-march=`, there are a few choices: > > > > > > * add a `REQUIRES: zos-new-default-march` directive > > > * hard code a `-march=` > > > > > > Neither is immediately noticeable. In the past clang/test/Driver has had > > > many such tests that require fixup. We have tried removing some > > > unnecessary `CLANG_DEFAULT_*`. > > > > > > I just realized that > > [reviews.llvm.org/D75914](https://reviews.llvm.org/D75914) added > > `CLANG_SYSTEMZ_DEFAULT_ARCH` for Ubuntu. @xnox @uweigand > > I think we want to avoid such CMake options/clang `config.h` > > As an alternative, if the clang executable is at `/tmp/Rel/bin/clang`, you > > can add `/tmp/Rel/bin/s390x-unknown-linux-gnu.cfg` with content > > `-march=z13`. > > Once we drop `CLANG_SYSTEMZ_DEFAULT_ARCH`, the `config.h` include will not > > be needed. > > I don't understand your proposal. In Ubuntu we need to set built-in default > arch value, to a higher one than upstream has it at, for all builds without > any toolchain configs. Such that any builds with any toolchain configs by > default target a higher arch setting. > > arch10 is way too old and slow. > > and z13 might not be enough either for latest devel distributions, i.e. next > development ubuntu release may be bumping further above z13. > > Does your proposal address above needs? Yes. See this part: > As an alternative, if the clang executable is at /tmp/Rel/bin/clang, you can > add /tmp/Rel/bin/s390x-unknown-linux-gnu.cfg with content -march=z13. We should then remove CLANG_SYSTEMZ_DEFAULT_ARCH (https://reviews.llvm.org/D75914) https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
@@ -4141,6 +4141,20 @@ // Begin SystemZ/GCC/Linux tests +// RUN: %clang -E -dM %s -o - 2>&1 \ +// RUN: -target s390x-ibm-zos \ MaskRay wrote: `--target=` for new driver tests. However, this does not test clangDriver and therefore `%clang_cc1` is preferred. (You can ignore previous lines that obey the convention. I can fix them later.) https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
https://github.com/MaskRay approved this pull request. https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
xnox wrote: Requiring a config file when previously was not needed is a regression in behaviour for distributions. I guess Ubuntu would have to continue to patch this back in. Built-in defaults exist for a reason and yes at times need to be higher. This change risks performance regressions for RHEL SUSE and Ubuntu. Please call out this change in release notes. https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits