Skip to content

Commit 2aea637

Browse files
DougGregormikeash
authored andcommitted
Rewrite install_name for macOS 10.14 only with the Xcode default toolchain.
The install_name trick we are using to make sure that an application built with a deployment target new enough to *guarantee* that Swift will be available in the OS (and therefore don't need dylibs bundled) link directly to /usr/lib/swift/*.dylib, but rewrites the the library paths to be rpath-relative for older OS's (e.g., @rpath/lib/swift/libswiftCore.dylib) doesn't work for sub-minor version numbers, e.g., the tools can't distinguish between 10.14.4 and 10.14. Therefore, macOS 10.14 is both an "older OS" and a "newer OS". Hack around the primary problem caused by this---the inability of first-party Swift programs to launch on macOS 10.14.4---by treating macOS 10.14 as an "older OS" when building for the Xcode toolchain (which is used by anyone who will deploy back to an older OS, e.g., 3rd party applications) but treat it as a "newer OS" when building for the OS toolchains (which is used when building the OS itself). Fixes rdar://problem/47007519.
1 parent 4fb9999 commit 2aea637

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

stdlib/linker-support/magic-symbols-for-install-name.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#if defined(__APPLE__) && defined(__MACH__)
2121

22+
#include <Availability.h>
2223
#include <TargetConditionals.h>
2324
#include "../public/SwiftShims/Visibility.h"
2425

@@ -77,7 +78,13 @@
7778
RPATH_INSTALL_NAME_DIRECTIVE(10, 11)
7879
RPATH_INSTALL_NAME_DIRECTIVE(10, 12)
7980
RPATH_INSTALL_NAME_DIRECTIVE(10, 13)
81+
82+
// When building with a deployment target of < macOS 10.14,
83+
// treat macOS 10.14 as an "older OS."
84+
#if __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_14
8085
RPATH_INSTALL_NAME_DIRECTIVE(10, 14)
86+
#endif
87+
8188
#else
8289
#error Unknown target.
8390
#endif

0 commit comments

Comments
 (0)