LLVM 22: New compiler suite

This commit is contained in:
Chris Jones
2026-02-24 12:26:29 +00:00
parent 84d7fa8e0a
commit 6a0da96c92
28 changed files with 1438 additions and 2 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,50 @@
From e27d02d4c95a48cfa3aa9f7c0f3d6dd4f45e4f22 Mon Sep 17 00:00:00 2001
Date: Sun, 16 May 2021 13:07:20 -0700
Subject: [PATCH 01/24] MacPorts-only: clang use MP omp locations
look in ${prefix}/lib/libomp for omp libraries
* this patch requires post-patch reinplace
---
clang/lib/Driver/ToolChains/Clang.cpp | 2 ++
clang/lib/Driver/ToolChains/CommonArgs.cpp | 6 ++++++
2 files changed, 8 insertions(+)
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 1976b48e0f6a..981f35e36a0e 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5463,6 +5463,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
case Driver::OMPRT_OMP:
case Driver::OMPRT_IOMP5:
// Clang can generate useful OpenMP code for these two runtime libraries.
+ // Automatically find MacPorts' omp.h
+ CmdArgs.push_back("-I@@PREFIX@@/include/libomp");
CmdArgs.push_back("-fopenmp");
// If no option regarding the use of TLS in OpenMP codegeneration is
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index bcaea71dca94..a88833055be7 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -668,12 +668,18 @@ bool tools::addOpenMPRuntime(ArgStringList &CmdArgs, const ToolChain &TC,
switch (RTKind) {
case Driver::OMPRT_OMP:
+ // Automatically find MacPorts' libomp
+ CmdArgs.push_back("-L@@PREFIX@@/lib/libomp");
CmdArgs.push_back("-lomp");
break;
case Driver::OMPRT_GOMP:
+ // Automatically find MacPorts' libomp
+ CmdArgs.push_back("-L@@PREFIX@@/lib/libomp");
CmdArgs.push_back("-lgomp");
break;
case Driver::OMPRT_IOMP5:
+ // Automatically find MacPorts' libomp
+ CmdArgs.push_back("-L@@PREFIX@@/lib/libomp");
CmdArgs.push_back("-liomp5");
break;
case Driver::OMPRT_Unknown:
--
2.21.1 (Apple Git-122.3)
@@ -0,0 +1,20 @@
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index d96294e06d57..87cd29543803 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -520,11 +520,13 @@ bool AsmPrinter::doInitialization(Module &M) {
// use the directive, where it would need the same conditionalization
// anyway.
if (Target.isOSBinFormatMachO() && Target.isOSDarwin()) {
- Triple TVT(M.getDarwinTargetVariantTriple());
- OutStreamer->emitVersionForTarget(
+ if (MAI->useIntegratedAssembler()) {
+ Triple TVT(M.getDarwinTargetVariantTriple());
+ OutStreamer->emitVersionForTarget(
Target, M.getSDKVersion(),
M.getDarwinTargetVariantTriple().empty() ? nullptr : &TVT,
M.getDarwinTargetVariantSDKVersion());
+ }
}
// Allow the target to emit any magic that it wants at the start of the file.
@@ -0,0 +1,84 @@
From 898f186abe78b972d294949c260b279f76b32a2b Mon Sep 17 00:00:00 2001
Date: Mon, 17 May 2021 21:14:25 -0700
Subject: [PATCH 03/24] MacPorts Only: Prepare clang-format for replacement
with absolute path
---
clang/tools/clang-format/clang-format-bbedit.applescript | 2 +-
clang/tools/clang-format/clang-format-diff.py | 2 +-
clang/tools/clang-format/clang-format-sublime.py | 2 +-
clang/tools/clang-format/clang-format.el | 3 +--
clang/tools/clang-format/clang-format.py | 2 +-
5 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/clang/tools/clang-format/clang-format-bbedit.applescript b/clang/tools/clang-format/clang-format-bbedit.applescript
index fa88fe900480..eb09448be561 100644
--- a/clang/tools/clang-format/clang-format-bbedit.applescript
+++ b/clang/tools/clang-format/clang-format-bbedit.applescript
@@ -15,7 +15,7 @@ tell application "BBEdit"
end tell
set filePath to urlToPOSIXPath(fileURL)
-set newContents to do shell script "/path/to/clang-format -offset=" & selectionOffset & " -length=" & selectionLength & " " & quoted form of filePath
+set newContents to do shell script "@CLANG_FORMAT_PATH@ -offset=" & selectionOffset & " -length=" & selectionLength & " " & quoted form of filePath
tell application "BBEdit"
-- "set contents of text document 1 to newContents" scrolls to the bottom while
diff --git a/clang/tools/clang-format/clang-format-diff.py b/clang/tools/clang-format/clang-format-diff.py
index 6e653a134289..cbcf21474ccd 100755
--- a/clang/tools/clang-format/clang-format-diff.py
+++ b/clang/tools/clang-format/clang-format-diff.py
@@ -92,7 +92,7 @@
)
parser.add_argument(
"-binary",
- default="clang-format",
+ default="@CLANG_FORMAT_PATH@",
help="location of binary to use for clang-format",
)
args = parser.parse_args()
diff --git a/clang/tools/clang-format/clang-format-sublime.py b/clang/tools/clang-format/clang-format-sublime.py
index 20c867092ef5..ae823c1d05b6 100644
--- a/clang/tools/clang-format/clang-format-sublime.py
+++ b/clang/tools/clang-format/clang-format-sublime.py
@@ -18,7 +18,7 @@ import sublime_plugin
import subprocess
# Change this to the full path if clang-format is not on the path.
-binary = "clang-format"
+binary = "@CLANG_FORMAT_PATH@"
# Change this to format according to other formatting styles. See the output of
# 'clang-format --help' for a list of supported styles. The default looks for
diff --git a/clang/tools/clang-format/clang-format.el b/clang/tools/clang-format/clang-format.el
index 768acb3a5d0d..e702bc6af4db 100644
--- a/clang/tools/clang-format/clang-format.el
+++ b/clang/tools/clang-format/clang-format.el
@@ -37,8 +37,7 @@
:group 'tools)
(defcustom clang-format-executable
- (or (executable-find "clang-format")
- "clang-format")
+ "@CLANG_FORMAT_PATH@"
"Location of the clang-format executable.
A string containing the name or the full path of the executable."
diff --git a/clang/tools/clang-format/clang-format.py b/clang/tools/clang-format/clang-format.py
index 76fedb648147..9cb9825cbe5d 100644
--- a/clang/tools/clang-format/clang-format.py
+++ b/clang/tools/clang-format/clang-format.py
@@ -49,6 +49,6 @@ import vim
# set g:clang_format_path to the path to clang-format if it is not on the path
# Change this to the full path if clang-format is not on the path.
-binary = "clang-format"
+binary = "@CLANG_FORMAT_PATH@"
if vim.eval('exists("g:clang_format_path")') == "1":
binary = vim.eval("g:clang_format_path")
--
2.21.1 (Apple Git-122.3)
@@ -0,0 +1,25 @@
From 6ff25e20ec478fcb76148c062beef0ca8d88f897 Mon Sep 17 00:00:00 2001
Date: Mon, 17 May 2021 21:15:35 -0700
Subject: [PATCH 04/24] MacPorts Only: Fix name of scan-view executable inside
scan-build
---
clang/tools/scan-build/bin/scan-build | 2 ++
1 file changed, 2 insertions(+)
diff --git a/clang/tools/scan-build/bin/scan-build b/clang/tools/scan-build/bin/scan-build
index 645f5507b6fa..2eecc3b9a1dd 100755
--- a/clang/tools/scan-build/bin/scan-build
+++ b/clang/tools/scan-build/bin/scan-build
@@ -969,6 +969,8 @@ sub Finalize {
if ($Options{ViewResults} and -r "$Options{OutputDir}/index.html") {
Diag "Viewing analysis results in '$Options{OutputDir}' using scan-view.\n";
my $ScanView = Cwd::realpath("$RealBin/scan-view");
+ if (! -x $ScanView) { $ScanView = Cwd::realpath("$RealBin/bin/scan-view"); }
+ if (! -x $ScanView) { $ScanView = Cwd::realpath("$RealBin/../scan-view/scan-view"); }
if (! -x $ScanView) { $ScanView = "scan-view"; }
if (! -x $ScanView) { $ScanView = Cwd::realpath("$RealBin/../../scan-view/bin/scan-view"); }
if (! -x $ScanView) { $ScanView = `which scan-view`; chomp $ScanView; }
--
2.21.1 (Apple Git-122.3)
@@ -0,0 +1,108 @@
From 4e850191efa6659de85a4ff9be7c896cfb0bb1ec Mon Sep 17 00:00:00 2001
Date: Mon, 17 May 2021 21:28:40 -0700
Subject: [PATCH 05/24] clang: support macports-libstdcxx
requires reinplace of search paths
---
clang/include/clang/Driver/ToolChain.h | 3 +-
clang/lib/Driver/ToolChain.cpp | 3 ++
clang/lib/Driver/ToolChains/Darwin.cpp | 40 ++++++++++++++-----
clang/lib/Driver/ToolChains/Hexagon.cpp | 2 +
clang/lib/Lex/InitHeaderSearch.cpp | 2 +-
7 files changed, 63 insertions(+), 11 deletions(-)
create mode 100644 clang/lib/Frontend/CompilerInvocation.cpp.rej
diff --git a/clang/include/clang/Driver/ToolChain.h b/clang/include/clang/Driver/ToolChain.h
index 28c37a44e1eb..78fcaec7bfb0 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -94,6 +94,7 @@ public:
enum CXXStdlibType {
CST_Libcxx,
+ CST_MacPortsLibstdcxx,
CST_Libstdcxx
};
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index b2ddef141a75..6160843b6885 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -850,6 +850,8 @@
cxxStdlibType = ToolChain::CST_Libcxx;
else if (LibName == "libstdc++")
cxxStdlibType = ToolChain::CST_Libstdcxx;
+ else if (LibName == "macports-libstdc++" || LibName == "libstdc++_macports")
+ cxxStdlibType = ToolChain::CST_MacPortsLibstdcxx;
else if (LibName == "platform")
cxxStdlibType = GetDefaultCXXStdlibType();
else {
@@ -969,6 +971,7 @@ void ToolChain::AddCXXStdlibLibArgs(const ArgList &Args,
break;
case ToolChain::CST_Libstdcxx:
+ case ToolChain::CST_MacPortsLibstdcxx:
CmdArgs.push_back("-lstdc++");
break;
}
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp
index eb7bd4aec898..daa8e520e404 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2282,6 +2282,16 @@
break;
}
+ case ToolChain::CST_MacPortsLibstdcxx: {
+ bool IsBaseFoundMacPorts = AddGnuCPlusPlusIncludePaths(DriverArgs, CC1Args, llvm::StringRef("@@MACPORTS_GCC_INCLUDE_DIR@@"),
+ "",
+ "@@MACPORTS_HOST_NAME@@",
+ @@MACPORTS_TEST_32_64@@);
+ if (!IsBaseFoundMacPorts) {
+ getDriver().Diag(diag::warn_drv_libstdcxx_not_found);
+ }}
+ break;
+
case ToolChain::CST_Libstdcxx:
llvm::SmallString<128> UsrIncludeCxx = Sysroot;
llvm::sys::path::append(UsrIncludeCxx, "usr", "include", "c++");
@@ -2349,6 +2360,10 @@
CmdArgs.push_back("-lc++");
break;
+ case ToolChain::CST_MacPortsLibstdcxx:
+ CmdArgs.push_back("@@MACPORTS_libstdc++@@");
+ break;
+
case ToolChain::CST_Libstdcxx:
// Unfortunately, -lstdc++ doesn't always exist in the standard search path;
// it was previously found in the gcc lib dir. However, for all the Darwin
diff --git a/clang/lib/Driver/ToolChains/Hexagon.cpp b/clang/lib/Driver/ToolChains/Hexagon.cpp
index fb54f73bcd4c..0260a32096af 100644
--- a/clang/lib/Driver/ToolChains/Hexagon.cpp
+++ b/clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -758,6 +758,8 @@ HexagonToolChain::GetCXXStdlibType(const ArgList &Args) const {
return ToolChain::CST_Libstdcxx;
}
StringRef Value = A->getValue();
+ if (Value == "macports-libstdc++" || Value == "libstdc++_macports")
+ return ToolChain::CST_MacPortsLibstdcxx;
if (Value != "libstdc++" && Value != "libc++")
getDriver().Diag(diag::err_drv_invalid_stdlib_name) << A->getAsString(Args);
diff --git a/clang/lib/Frontend/InitHeaderSearch.cpp b/clang/lib/Frontend/InitHeaderSearch.cpp
index bc31445d6d08..abc3750edec0 100644
--- a/clang/lib/Lex/InitHeaderSearch.cpp
+++ b/clang/lib/Lex/InitHeaderSearch.cpp
@@ -117,7 +117,7 @@ static bool CanPrefixSysroot(StringRef Path) {
#if defined(_WIN32)
return !Path.empty() && llvm::sys::path::is_separator(Path[0]);
#else
- return llvm::sys::path::is_absolute(Path);
+ return llvm::sys::path::is_absolute(Path) && Path.find("@@MACPORTS_GCC_INCLUDE_DIR@@")!=0;
#endif
}
--
2.21.1 (Apple Git-122.3)
@@ -0,0 +1,32 @@
From 42707294da2789a755eedcd1af1a7fe0bc419925 Mon Sep 17 00:00:00 2001
Date: Sun, 16 May 2021 12:13:00 -0700
Subject: [PATCH 06/24] Define EXC_MASK_CRASH and MACH_EXCEPTION_CODES if
they're not defined in the SDK
---
llvm/lib/Support/Unix/Signals.inc | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc
index 3d7b5d2fe5aa..7280003dacfb 100644
--- a/llvm/lib/Support/Unix/Signals.inc
+++ b/llvm/lib/Support/Unix/Signals.inc
@@ -642,6 +642,15 @@ void llvm::sys::PrintStackTraceOnErrorSignal(StringRef Argv0,
AddSignalHandler(PrintStackTraceSignalHandler, nullptr);
#if defined(__APPLE__) && ENABLE_CRASH_OVERRIDES
+
+/* These aren't defined in the 10.4 SDK, so provide them here */
+#ifndef EXC_MASK_CRASH
+#define EXC_MASK_CRASH 0x400
+#endif
+#ifndef MACH_EXCEPTION_CODES
+#define MACH_EXCEPTION_CODES 0x80000000
+#endif
+
// Environment variable to disable any kind of crash dialog.
if (DisableCrashReporting || getenv("LLVM_DISABLE_CRASH_REPORT")) {
mach_port_t self = mach_task_self();
--
2.21.1 (Apple Git-122.3)
@@ -0,0 +1,28 @@
From af4b8f8987248e442faaad339261332e05e254b8 Mon Sep 17 00:00:00 2001
Date: Sun, 16 May 2021 12:21:10 -0700
Subject: [PATCH 07/24] Threading: Only call pthread_setname_np() if we have it
---
llvm/lib/Support/Unix/Threading.inc | 2 ++
1 file changed, 2 insertions(+)
diff --git a/llvm/lib/Support/Unix/Threading.inc b/llvm/lib/Support/Unix/Threading.inc
index 667d023fc134..8162c60b2cdd 100644
--- a/llvm/lib/Support/Unix/Threading.inc
+++ b/llvm/lib/Support/Unix/Threading.inc
@@ -193,11 +193,15 @@
::pthread_setname_np(::pthread_self(), "%s",
const_cast<char *>(NameStr.data()));
#elif defined(__APPLE__)
+#if HAVE_PTHREAD_SETNAME_NP
::pthread_setname_np(NameStr.data());
+#endif
#else
+#if HAVE_PTHREAD_SETNAME_NP
::pthread_setname_np(::pthread_self(), NameStr.data());
#endif
#endif
+#endif
}
void llvm::get_thread_name(SmallVectorImpl<char> &Name) {
@@ -0,0 +1,22 @@
From 718ec394030ca2da3973e0135d073e000b366848 Mon Sep 17 00:00:00 2001
Date: Sun, 16 May 2021 12:22:44 -0700
Subject: [PATCH 08/24] Threading: Only call setpriority(PRIO_DARWIN_THREAD, 0,
PRIO_DARWIN_BG) if it is available
---
llvm/lib/Support/Unix/Threading.inc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/Support/Unix/Threading.inc b/llvm/lib/Support/Unix/Threading.inc
index 99f64b4f553d..ea40db932fc1 100644
--- a/llvm/lib/Support/Unix/Threading.inc
+++ b/llvm/lib/Support/Unix/Threading.inc
@@ -264,7 +264,7 @@ SetThreadPriorityResult llvm::set_thread_priority(ThreadPriority Priority) {
&priority)
? SetThreadPriorityResult::SUCCESS
: SetThreadPriorityResult::FAILURE;
-#elif defined(__APPLE__)
+#elif defined(__APPLE__) && defined(PRIO_DARWIN_THREAD) && defined(PRIO_DARWIN_BG)
// https://developer.apple.com/documentation/apple-silicon/tuning-your-code-s-performance-for-apple-silicon
//
// Background - Applies to work that isnt visible to the user and may take significant
@@ -0,0 +1,23 @@
From 22a94ab53fbde0a2c161d3cd07e35b0eb78160b9 Mon Sep 17 00:00:00 2001
Date: Sun, 16 May 2021 12:27:31 -0700
Subject: [PATCH 09/24] lib/Support/Unix/Path.inc: define COPYFILE_CLONE if
needed
---
llvm/lib/Support/Unix/Path.inc | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc
index a18650aadb6e..3fefd4e7ae91 100644
--- a/llvm/lib/Support/Unix/Path.inc
+++ b/llvm/lib/Support/Unix/Path.inc
@@ -37,6 +37,9 @@
#ifdef __APPLE__
#include <copyfile.h>
+#ifndef COPYFILE_CLONE
+#define COPYFILE_CLONE (1<<24)
+#endif
#include <mach-o/dyld.h>
#include <sys/attr.h>
#if __has_include(<sys/clonefile.h>)
@@ -0,0 +1,47 @@
From 469281c821580ff8c89db236b35ef0a7c651633c Mon Sep 17 00:00:00 2001
Date: Mon, 17 May 2021 17:29:16 -0700
Subject: [PATCH 12/24] compiler-rt: add some defs missing in older SDKs
---
compiler-rt/lib/fuzzer/FuzzerUtilDarwin.cpp | 8 ++++++++
compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp | 5 +++++
2 files changed, 13 insertions(+)
diff --git a/compiler-rt/lib/fuzzer/FuzzerUtilDarwin.cpp b/compiler-rt/lib/fuzzer/FuzzerUtilDarwin.cpp
index a5bed658a446..b853462df3d2 100644
--- a/compiler-rt/lib/fuzzer/FuzzerUtilDarwin.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerUtilDarwin.cpp
@@ -19,6 +19,14 @@
#include <sys/wait.h>
#include <unistd.h>
+// add definition missing on older systems
+#ifndef POSIX_SPAWN_SETSIGMASK
+#define POSIX_SPAWN_SETSIGMASK 0x0008
+#endif
+#ifndef POSIX_SPAWN_SETSIGDEF
+#define POSIX_SPAWN_SETSIGDEF 0x0004
+#endif
+
// There is no header for this on macOS so declare here
extern "C" char **environ;
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
index 2b53d7d730d7..6950f8757dd0 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
@@ -110,6 +110,11 @@ extern "C" int __munmap(void *, size_t) SANITIZER_WEAK_ATTRIBUTE;
#define VM_MEMORY_SANITIZER 99
#endif
+// From <sys/spawn.h> but not in some SDKs
+#ifndef POSIX_SPAWN_CLOEXEC_DEFAULT
+#define POSIX_SPAWN_CLOEXEC_DEFAULT 0x4000
+#endif
+
// XNU on Darwin provides a mmap flag that optimizes allocation/deallocation of
// giant memory regions (i.e. shadow memory regions).
#define kXnuFastMmapFd 0x4
--
2.21.1 (Apple Git-122.3)
@@ -0,0 +1,44 @@
From e7fe0d485d8b41d35410f3bec3683eba391a1917 Mon Sep 17 00:00:00 2001
Date: Mon, 17 May 2021 21:17:07 -0700
Subject: [PATCH 16/24] 10.10 and less: compiler-rt find macosx sdk
if there is no sdk that responds to "macosx" use the CMAKE passed in deployment target
---
.../cmake/Modules/CompilerRTDarwinUtils.cmake | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
index 456a8dcda59f..e9f6f577d626 100644
--- a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -69,15 +69,6 @@ function(find_darwin_sdk_version var sdk_name)
ERROR_FILE /dev/null
)
endif()
- if(NOT result_process EQUAL 0)
- message(FATAL_ERROR
- "Failed to determine SDK version for \"${sdk_name}\" SDK")
- endif()
- # Check reported version looks sane.
- if (NOT "${var_internal}" MATCHES "^[0-9]+\\.[0-9]+(\\.[0-9]+)?$")
- message(FATAL_ERROR
- "Reported SDK version \"${var_internal}\" does not look like a version")
- endif()
set(${var} ${var_internal} PARENT_SCOPE)
endfunction()
@@ -128,6 +119,11 @@ function(darwin_test_archs os valid_archs)
# binaries.
if ("${os}" STREQUAL "osx")
find_darwin_sdk_version(macosx_sdk_version "macosx")
+ # if there is no sdk that responds to "macosx" use the CMAKE passed in deployment target
+ if(NOT macosx_sdk_version)
+ message(WARNING "Could not determine MacOSX SDK Version, trying CMAKE_OSX_DEPLOYMENT_TARGET")
+ set(macosx_sdk_version CMAKE_OSX_DEPLOYMENT_TARGET)
+ endif()
if ("${macosx_sdk_version}" VERSION_GREATER 10.15 OR "${macosx_sdk_version}" VERSION_EQUAL 10.15)
message(STATUS "Disabling i386 slice for ${valid_archs}")
list(REMOVE_ITEM archs "i386")
--
2.21.1 (Apple Git-122.3)
@@ -0,0 +1,56 @@
From 63501ee748110f8bd9c54859992406b7c1089f83 Mon Sep 17 00:00:00 2001
Date: Sun, 16 May 2021 12:30:32 -0700
Subject: [PATCH 19/24] 10.6 and less: use emulated TLS before 10.7
enable TLS on 10.4 and up
ItaniumCXXABI.cpp: call correct c++ TLS exit function
on 10.7+, we use the system TLS and _tlv_atexit
on < 10.7, we use emulated TLS and __cxa_thread_atexit
---
clang/lib/Basic/Targets/OSTargets.h | 2 +-
clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 +-
llvm/include/llvm/ADT/Triple.h | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h
index 67fa1a537fea..2f2ce1ccafde 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -92,7 +92,7 @@ public:
this->TLSSupported = false;
if (Triple.isMacOSX())
- this->TLSSupported = !Triple.isMacOSXVersionLT(10, 7);
+ this->TLSSupported = !Triple.isMacOSXVersionLT(10, 4);
else if (Triple.isiOS()) {
// 64-bit iOS supported it from 8 onwards, 32-bit device from 9 onwards,
// 32-bit simulator from 10 onwards.
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 50fb30a95cbb..1df40230e8f1 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -2487,7 +2487,7 @@ static void emitGlobalDtorWithCXAAtExit(CodeGenFunction &CGF,
const char *Name = "__cxa_atexit";
if (TLS) {
const llvm::Triple &T = CGF.getTarget().getTriple();
- Name = T.isOSDarwin() ? "_tlv_atexit" : "__cxa_thread_atexit";
+ Name = (T.isOSDarwin() && !T.isMacOSXVersionLT(10, 7)) ? "_tlv_atexit" : "__cxa_thread_atexit";
}
// We're assuming that the destructor function is something we can
diff --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h
index eed315c929ad..649b35f94307 100644
--- a/llvm/include/llvm/TargetParser/Triple.h 2022-12-20 15:29:16
+++ b/llvm/include/llvm/TargetParser/Triple.h 2022-12-30 13:17:19
@@ -1009,7 +1009,7 @@
/// Note: Android API level 29 (10) introduced ELF TLS.
bool hasDefaultEmulatedTLS() const {
return (isAndroid() && isAndroidVersionLT(29)) || isOSOpenBSD() ||
- isWindowsCygwinEnvironment() || isOHOSFamily();
+ isWindowsCygwinEnvironment() || isOHOSFamily() || isMacOSXVersionLT(10, 7);
}
/// Tests whether the target uses -data-sections as default.
@@ -0,0 +1,55 @@
From 745ebd5a9db4956328f42cf5a6d793cd28213a56 Mon Sep 17 00:00:00 2001
Date: Sat, 5 Jun 2021 11:57:45 -0700
Subject: [PATCH 25/25] lldb: add defines needed for older SDKs
fixes build of lldb back to at least 10.12
---
lldb/tools/debugserver/source/DNB.h | 4 ++++
.../debugserver/source/MacOSX/MachProcess.mm | 16 ++++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/lldb/tools/debugserver/source/DNB.h b/lldb/tools/debugserver/source/DNB.h
index 069c62dc41d8..edfd55dd8422 100644
--- a/lldb/tools/debugserver/source/DNB.h
+++ b/lldb/tools/debugserver/source/DNB.h
@@ -34,6 +34,10 @@
#define CPU_TYPE_ARM64_32 ((cpu_type_t)12 | 0x02000000)
#endif
+#ifndef CPU_SUBTYPE_ARM64E
+#define CPU_SUBTYPE_ARM64E ((cpu_subtype_t) 2)
+#endif
+
typedef bool (*DNBShouldCancelCallback)(void *);
void DNBInitialize();
diff --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
index 1b962da8d02b..6c27212c6e49 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
+++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
@@ -47,6 +47,22 @@
#include "CFBundle.h"
#include "CFString.h"
+#ifndef PLATFORM_MACOS
+#define PLATFORM_MACOS 1
+#endif
+
+#ifndef PLATFORM_IOS
+#define PLATFORM_IOS 2
+#endif
+
+#ifndef PLATFORM_TVOS
+#define PLATFORM_TVOS 3
+#endif
+
+#ifndef PLATFORM_WATCHOS
+#define PLATFORM_WATCHOS 4
+#endif
+
#ifndef PLATFORM_BRIDGEOS
#define PLATFORM_BRIDGEOS 5
#endif
--
2.21.1 (Apple Git-122.3)
@@ -0,0 +1,13 @@
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc
index 788460d..c52dc72 100644
--- a/llvm/lib/Support/Unix/Path.inc
+++ b/llvm/lib/Support/Unix/Path.inc
@@ -1462,7 +1462,7 @@ namespace fs {
std::error_code copy_file(const Twine &From, const Twine &To) {
std::string FromS = From.str();
std::string ToS = To.str();
-#if __has_builtin(__builtin_available)
+#if 0
if (__builtin_available(macos 10.12, *)) {
// Optimistically try to use clonefile() and handle errors, rather than
// calling stat() to see if it'll work.
@@ -0,0 +1,16 @@
diff --git a/flang/include/flang/Support/Fortran-features.h b/flang/include/flang/Support/Fortran-features.h
index 743abf606ab5..db91a3caa74e 100644
--- a/flang/include/flang/Support/Fortran-features.h
+++ b/flang/include/flang/Support/Fortran-features.h
@@ -13,6 +13,11 @@
#include "flang/Common/enum-set.h"
#include <string_view>
#include <vector>
+#include <unordered_map>
+#include <array>
+#include <variant>
+#include <optional>
+#include <string>
namespace Fortran::common {
@@ -0,0 +1,36 @@
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index 0aae13e30f2a..aba28e40d9a2 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -266,10 +266,10 @@ set(BACKTRACE_HEADER ${Backtrace_HEADER})
# Prevent check_symbol_exists from using API that is not supported for a given
# deployment target.
-check_c_compiler_flag("-Werror=unguarded-availability-new" "C_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW")
-if(C_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW)
- set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror=unguarded-availability-new")
-endif()
+#check_c_compiler_flag("-Werror=unguarded-availability-new" "C_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW")
+#if(C_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW)
+# set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror=unguarded-availability-new")
+#endif()
# Determine whether we can register EH tables.
check_symbol_exists(__register_frame "${CMAKE_CURRENT_LIST_DIR}/unwind.h" HAVE_REGISTER_FRAME)
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 5ca580fbb59c..ea0e026e5d31 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -668,9 +668,9 @@ if ( LLVM_COMPILER_IS_GCC_COMPATIBLE OR CMAKE_CXX_COMPILER_ID MATCHES "XL" )
append("-Werror=date-time" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif( LLVM_COMPILER_IS_GCC_COMPATIBLE OR CMAKE_CXX_COMPILER_ID MATCHES "XL" )
-if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
- append("-Werror=unguarded-availability-new" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
-endif()
+#if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+# append("-Werror=unguarded-availability-new" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+#endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# LLVM data structures like llvm::User and llvm::MDNode rely on
@@ -0,0 +1,14 @@
diff --git a/libcxx/include/__mbstate_t.h b/libcxx/include/__mbstate_t.h
index e013384454b4..fd85579de3b3 100644
--- a/libcxx/include/__mbstate_t.h
+++ b/libcxx/include/__mbstate_t.h
@@ -42,6 +42,9 @@
#elif __has_include(<bits/types/mbstate_t.h>)
# include <bits/types/mbstate_t.h> // works on most Unixes
#elif __has_include(<sys/_types/_mbstate_t.h>)
+# if __has_include(<machine/_types.h>)
+# include <machine/_types.h>
+# endif
# include <sys/_types/_mbstate_t.h> // works on Darwin
#elif _LIBCPP_HAS_WIDE_CHARACTERS && __has_include_next(<wchar.h>)
# include_next <wchar.h> // fall back to the C standard provider of mbstate_t
@@ -0,0 +1,13 @@
--- a/clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp 2021-10-26 12:21:35.000000000 +0100
+++ b/clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp 2021-10-26 12:25:47.000000000 +0100
@@ -19,6 +19,10 @@
using namespace llvm;
using namespace clang;
+#ifndef TARGET_OS_OSX
+# define TARGET_OS_OSX 1
+#endif
+
#if TARGET_OS_OSX
static void stopFSEventStream(FSEventStreamRef);
@@ -0,0 +1,32 @@
diff --git a/llvm/lib/Support/Unix/Threading.inc b/llvm/lib/Support/Unix/Threading.inc
index 99f64b4f553d..5de1cf071ba9 100644
--- a/llvm/lib/Support/Unix/Threading.inc
+++ b/llvm/lib/Support/Unix/Threading.inc
@@ -22,7 +22,6 @@
#if defined(__APPLE__)
#include <mach/mach_init.h>
#include <mach/mach_port.h>
-#include <pthread/qos.h>
#include <sys/sysctl.h>
#include <sys/types.h>
#endif
@@ -278,17 +277,8 @@
// minutes to complete. Examples include downloading a document or importing
// data. This class offers a balance between responsiveness, performance, and
// energy efficiency.
- const auto qosClass = [&]() {
- switch (Priority) {
- case ThreadPriority::Background:
- return QOS_CLASS_BACKGROUND;
- case ThreadPriority::Low:
- return QOS_CLASS_UTILITY;
- case ThreadPriority::Default:
- return QOS_CLASS_DEFAULT;
- }
- }();
- return !pthread_set_qos_class_self_np(qosClass, 0)
+ return !setpriority(PRIO_DARWIN_THREAD, 0,
+ Priority == ThreadPriority::Default ? 0 : PRIO_DARWIN_BG)
? SetThreadPriorityResult::SUCCESS
: SetThreadPriorityResult::FAILURE;
#endif

Some files were not shown because too many files have changed in this diff Show More