[PATCH] D138449: support: fix getProcessTriple in universal builds
Jon Roelofs via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 14 13:45:07 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdc078e6eaacf: TargetParser: fix getProcessTriple in universal builds (authored by jroelofs).
Changed prior to commit:
https://reviews.llvm.org/D138449?vs=476936&id=540555#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D138449/new/
https://reviews.llvm.org/D138449
Files:
llvm/lib/TargetParser/Host.cpp
Index: llvm/lib/TargetParser/Host.cpp
===================================================================
--- llvm/lib/TargetParser/Host.cpp
+++ llvm/lib/TargetParser/Host.cpp
@@ -1878,10 +1878,44 @@
bool sys::getHostCPUFeatures(StringMap<bool> &Features) { return false; }
#endif
+#if __APPLE__
+/// \returns the \p triple, but with the Host's arch spliced in.
+static Triple withHostArch(Triple T) {
+#if defined(__arm__)
+ T.setArch(Triple::arm);
+ T.setArchName("arm");
+#elif defined(__arm64e__)
+ T.setArch(Triple::aarch64, Triple::AArch64SubArch_arm64e);
+ T.setArchName("arm64e");
+#elif defined(__aarch64__)
+ T.setArch(Triple::aarch64);
+ T.setArchName("arm64");
+#elif defined(__x86_64h__)
+ T.setArch(Triple::x86_64);
+ T.setArchName("x86_64h");
+#elif defined(__x86_64__)
+ T.setArch(Triple::x86_64);
+ T.setArchName("x86_64");
+#elif defined(__powerpc__)
+ T.setArch(Triple::ppc);
+ T.setArchName("powerpc");
+#else
+# error "Unimplemented host arch fixup"
+#endif
+ return T;
+}
+#endif
+
std::string sys::getProcessTriple() {
std::string TargetTripleString = updateTripleOSVersion(LLVM_HOST_TRIPLE);
Triple PT(Triple::normalize(TargetTripleString));
+#if __APPLE__
+ /// In Universal builds, LLVM_HOST_TRIPLE will have the wrong arch in one of
+ /// the slices. This fixes that up.
+ PT = withHostArch(PT);
+#endif
+
if (sizeof(void *) == 8 && PT.isArch32Bit())
PT = PT.get64BitArchVariant();
if (sizeof(void *) == 4 && PT.isArch64Bit())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138449.540555.patch
Type: text/x-patch
Size: 1495 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230714/4ae25493/attachment.bin>
More information about the llvm-commits
mailing list