diff options
author | Brad King <brad.king@kitware.com> | 2020-07-10 14:19:21 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-07-13 12:31:59 (GMT) |
commit | c51400033ce77b100f222b309cf893bd814ffc37 (patch) | |
tree | de2b71d460eab8b534928511a20a7887660d288e /Source/cmBinUtilsMacOSMachOLinker.cxx | |
parent | 6ab08c4e99469439900c1cdc02fd2452ab268a87 (diff) | |
download | CMake-c51400033ce77b100f222b309cf893bd814ffc37.zip CMake-c51400033ce77b100f222b309cf893bd814ffc37.tar.gz CMake-c51400033ce77b100f222b309cf893bd814ffc37.tar.bz2 |
file: Update GET_RUNTIME_DEPENDENCIES for macOS 11 dylib cache
Starting on macOS 11, the dynamic loader has a builtin cache of
system-provided dylib files. They do not actually exist on the
filesystem. However, runtime dependencies recorded in Mach-O binaries
can still have `LC_LOAD_DYLIB` entries referring to such dylib files by
absolute path. The dynamic loader simply resolves the paths from its
cache. Teach `file(GET_RUNTIME_DEPENDENCIES)` to skip dependencies on
such dylib paths. For practical software distribution purposes they do
not exist, or at least can be assumed available on all deployments.
Issue: #20863
Diffstat (limited to 'Source/cmBinUtilsMacOSMachOLinker.cxx')
-rw-r--r-- | Source/cmBinUtilsMacOSMachOLinker.cxx | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Source/cmBinUtilsMacOSMachOLinker.cxx b/Source/cmBinUtilsMacOSMachOLinker.cxx index 98250b1..0f47146 100644 --- a/Source/cmBinUtilsMacOSMachOLinker.cxx +++ b/Source/cmBinUtilsMacOSMachOLinker.cxx @@ -14,6 +14,18 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" +namespace { +bool IsMissingSystemDylib(std::string const& path) +{ + // Starting on macOS 11, the dynamic loader has a builtin cache of + // system-provided dylib files that do not exist on the filesystem. + // Tell our caller that these are expected to be missing. + return ((cmHasLiteralPrefix(path, "/System/Library/") || + cmHasLiteralPrefix(path, "/usr/lib/")) && + !cmSystemTools::PathExists(path)); +} +} + cmBinUtilsMacOSMachOLinker::cmBinUtilsMacOSMachOLinker( cmRuntimeDependencyArchive* archive) : cmBinUtilsLinker(archive) @@ -82,7 +94,8 @@ bool cmBinUtilsMacOSMachOLinker::GetFileDependencies( return false; } if (resolved) { - if (!this->Archive->IsPostExcluded(path)) { + if (!this->Archive->IsPostExcluded(path) && + !IsMissingSystemDylib(path)) { auto filename = cmSystemTools::GetFilenameName(path); bool unique; this->Archive->AddResolvedPath(filename, path, unique); |