tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
libtapi: 1100.0.11 -> 1500.0.12.3
Randy Eckenrode
2 years ago
cdf968c6
baf3568f
+274
4 changed files
expand all
collapse all
unified
split
pkgs
by-name
li
libtapi
0001-Check-for-no_exported_symbols-linker-support.patch
0002-Pass-fileType-to-writeToStream.patch
0003-Match-designator-order-with-declaration-order.patch
package.nix
+37
pkgs/by-name/li/libtapi/0001-Check-for-no_exported_symbols-linker-support.patch
···
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
···
1
+
From e954aacbc075355419f5fc99db61f68aca1fcfe4 Mon Sep 17 00:00:00 2001
2
+
From: Randy Eckenrode <randy@largeandhighquality.com>
3
+
Date: Fri, 5 Apr 2024 14:16:40 -0400
4
+
Subject: [PATCH 1/3] Check for -no_exported_symbols linker support
5
+
6
+
---
7
+
CMakeLists.txt | 7 ++++++-
8
+
1 file changed, 6 insertions(+), 1 deletion(-)
9
+
10
+
diff --git a/tapi/CMakeLists.txt b/tapi/CMakeLists.txt
11
+
index 62affdf..82426de 100644
12
+
--- a/tapi/CMakeLists.txt
13
+
+++ b/tapi/CMakeLists.txt
14
+
@@ -73,6 +73,9 @@ llvm_check_linker_flag(CXX "-Wl,-no_inits" LINKER_SUPPORTS_NO_INITS)
15
+
llvm_check_linker_flag(CXX "-Wl,-iosmac_version_min,13.0" LINKER_SUPPORTS_IOSMAC)
16
+
# MARZIPAN RENAME
17
+
18
+
+# Older versions of ld64 (e.g., in the Darwin bootstrap) do not support this flag.
19
+
+llvm_check_linker_flag(CXX "-Wl,-no_exported_symbols" LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
20
+
+
21
+
# Check if i386 is supported.
22
+
SET(CMAKE_OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
23
+
SET(CMAKE_OLD_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
24
+
@@ -160,7 +163,9 @@ endmacro(add_tapi_library)
25
+
macro(add_tapi_executable name)
26
+
add_llvm_executable(${name} ${ARGN})
27
+
set_target_properties(${name} PROPERTIES FOLDER "Tapi executables")
28
+
- target_link_options(${name} PRIVATE "-Wl,-no_exported_symbols")
29
+
+ if(LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
30
+
+ target_link_options(${name} PRIVATE "-Wl,-no_exported_symbols")
31
+
+ endif()
32
+
endmacro(add_tapi_executable)
33
+
34
+
function(tapi_clang_tablegen)
35
+
--
36
+
2.42.0
37
+
+25
pkgs/by-name/li/libtapi/0002-Pass-fileType-to-writeToStream.patch
···
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
···
1
+
From 77ca537cfc61765f2109c626757f2da8de602ce0 Mon Sep 17 00:00:00 2001
2
+
From: Randy Eckenrode <randy@largeandhighquality.com>
3
+
Date: Fri, 5 Apr 2024 23:20:32 -0400
4
+
Subject: [PATCH 2/3] Pass fileType to writeToStream
5
+
6
+
---
7
+
lib/Core/JSONReaderWriter.cpp | 2 +-
8
+
1 file changed, 1 insertion(+), 1 deletion(-)
9
+
10
+
diff --git a/tapi/lib/Core/JSONReaderWriter.cpp b/tapi/lib/Core/JSONReaderWriter.cpp
11
+
index c040670..c1be85f 100644
12
+
--- a/tapi/lib/Core/JSONReaderWriter.cpp
13
+
+++ b/tapi/lib/Core/JSONReaderWriter.cpp
14
+
@@ -57,7 +57,7 @@ Error JSONWriter::writeFile(raw_ostream &os, const InterfaceFile *file,
15
+
if (file == nullptr)
16
+
return errorCodeToError(std::make_error_code(std::errc::invalid_argument));
17
+
18
+
- return TextAPIWriter::writeToStream(os, *file, /*Compact=*/false);
19
+
+ return TextAPIWriter::writeToStream(os, *file, fileType, /*Compact=*/false);
20
+
}
21
+
22
+
TAPI_NAMESPACE_INTERNAL_END
23
+
--
24
+
2.42.0
25
+
+28
pkgs/by-name/li/libtapi/0003-Match-designator-order-with-declaration-order.patch
···
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
···
1
+
From b69038edb2e0ace9128407ab3ee7bc1001ffd751 Mon Sep 17 00:00:00 2001
2
+
From: Randy Eckenrode <randy@largeandhighquality.com>
3
+
Date: Sun, 7 Apr 2024 19:23:24 -0400
4
+
Subject: [PATCH 3/3] Match designator order with declaration order
5
+
6
+
---
7
+
lib/Core/Demangler.cpp | 3 ++-
8
+
1 file changed, 2 insertions(+), 1 deletion(-)
9
+
10
+
diff --git a/tapi/lib/Core/Demangler.cpp b/tapi/lib/Core/Demangler.cpp
11
+
index d85899a..f5c485a 100644
12
+
--- a/tapi/lib/Core/Demangler.cpp
13
+
+++ b/tapi/lib/Core/Demangler.cpp
14
+
@@ -30,9 +30,10 @@ bool Demangler::isItaniumEncoding(StringRef mangledName) {
15
+
return mangledName.startswith("_Z") || mangledName.startswith("___Z");
16
+
}
17
+
18
+
+
19
+
DemangledName Demangler::demangle(StringRef mangledName) {
20
+
DemangledName result{
21
+
- .str = mangledName.str(), .isSwift = false, .isItanium = false};
22
+
+ .str = mangledName.str(), .isItanium = false, .isSwift = false};
23
+
char *demangled = nullptr;
24
+
25
+
if (isItaniumEncoding(mangledName)) {
26
+
--
27
+
2.42.0
28
+
+184
pkgs/by-name/li/libtapi/package.nix
···
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
···
1
+
{
2
+
lib,
3
+
stdenv,
4
+
fetchFromGitHub,
5
+
fetchpatch,
6
+
cmake,
7
+
ninja,
8
+
python3,
9
+
zlib,
10
+
}:
11
+
12
+
let
13
+
# libtapi is only supported building against Apple’s LLVM fork pinned to a specific revision.
14
+
# It can’t be built against upstream LLVM because it uses APIs that are specific to Apple’s fork.
15
+
# See: https://github.com/apple-oss-distributions/tapi/blob/main/Readme.md
16
+
17
+
# Apple’s LLVM fork uses its own versioning scheme.
18
+
# See: https://en.wikipedia.org/wiki/Xcode#Toolchain_versions
19
+
# Note: Can’t use a sparse checkout because the Darwin stdenv bootstrap can’t depend on fetchgit.
20
+
appleLlvm = {
21
+
version = "15.0.0"; # As reported by upstream’s `tapi --version`.
22
+
rev = "2b5ff47e44b059c03de5779479d01a133ab4d581"; # Per the TAPI repo.
23
+
hash = "sha256-X37zBbpSEWmqtdTXsd1t++gp+0ggA8YtB73fGKNaiR0=";
24
+
};
25
+
in
26
+
stdenv.mkDerivation (finalAttrs: {
27
+
pname = "libtapi";
28
+
version = "1500.0.12.3";
29
+
30
+
outputs = [
31
+
"out"
32
+
"bin"
33
+
"dev"
34
+
];
35
+
36
+
srcs = [
37
+
(fetchFromGitHub {
38
+
name = "tapi-src";
39
+
owner = "apple-oss-distributions";
40
+
repo = "tapi";
41
+
rev = "tapi-${finalAttrs.version}";
42
+
hash = "sha256-YeaA2OeSY1fXYJHPJJ0TrVC1brspSvutBtPMPGX6Y1o=";
43
+
})
44
+
# libtapi can’t avoid pulling the whole repo even though it needs only a couple of folders because
45
+
# `fetchgit` can’t be used in the Darwin bootstrap.
46
+
(fetchFromGitHub {
47
+
name = "apple-llvm-src";
48
+
owner = "apple";
49
+
repo = "llvm-project";
50
+
inherit (appleLlvm) rev hash;
51
+
})
52
+
];
53
+
54
+
patches = [
55
+
# Older versions of ld64 may not support `-no_exported_symbols`, so use it only
56
+
# when the linker supports it.
57
+
# Note: This can be dropped once the bootstrap tools are updated after the ld64 update.
58
+
./0001-Check-for-no_exported_symbols-linker-support.patch
59
+
# The recommended upstream revision of Apple’s LLVM fork needs this patch, or
60
+
# `tapi stubify` will crash when generating stubs.
61
+
(fetchpatch {
62
+
url = "https://github.com/apple/llvm-project/commit/455bf3d1ccd6a52df5e38103532c1b8f49924edc.patch";
63
+
hash = "sha256-ujZcfdAls20JPIvjvO2Xv8st8cNTY/XTEQusICKBKSA";
64
+
})
65
+
# Updates `JSONReaderWriter` to work with the API change in the above patch.
66
+
./0002-Pass-fileType-to-writeToStream.patch
67
+
# Fix build on Linux. GCC is more picky than clang about the field order.
68
+
./0003-Match-designator-order-with-declaration-order.patch
69
+
];
70
+
71
+
postPatch =
72
+
''
73
+
# Enable building on non-Darwin platforms
74
+
substituteInPlace tapi/CMakeLists.txt \
75
+
--replace-fail 'message(FATAL_ERROR "Unsupported configuration.")' ""
76
+
77
+
# Remove the client limitation on linking to libtapi.dylib.
78
+
substituteInPlace tapi/tools/libtapi/CMakeLists.txt \
79
+
--replace-fail '-allowable_client ld' ""
80
+
# Replace hard-coded installation paths with standard ones.
81
+
declare -A installdirs=(
82
+
[bin]=BINDIR
83
+
[include]=INCLUDEDIR
84
+
[lib]=LIBDIR
85
+
[local/bin]=BINDIR
86
+
[local/share/man]=MANDIR
87
+
[share/man]=MANDIR
88
+
)
89
+
for dir in "''${!installdirs[@]}"; do
90
+
cmakevar=CMAKE_INSTALL_''${installdirs[$dir]}
91
+
for cmakelist in $(grep -rl "DESTINATION $dir" tapi); do
92
+
substituteInPlace "$cmakelist" \
93
+
--replace-fail "DESTINATION $dir" "DESTINATION \''${$cmakevar}"
94
+
done
95
+
done
96
+
# Doesn’t seem to exist publically.
97
+
substituteInPlace tapi/test/CMakeLists.txt \
98
+
--replace-fail tapi-configs ""
99
+
''
100
+
+ lib.optionalString stdenv.isLinux ''
101
+
# Remove Darwin-specific versioning flags.
102
+
substituteInPlace tapi/tools/libtapi/CMakeLists.txt \
103
+
--replace-fail '-current_version ''${DYLIB_VERSION} -compatibility_version 1' ""
104
+
'';
105
+
106
+
preUnpack = ''
107
+
mkdir source
108
+
'';
109
+
110
+
sourceRoot = "source";
111
+
112
+
postUnpack = ''
113
+
chmod -R u+w apple-llvm-src tapi-src
114
+
mv apple-llvm-src/{clang,cmake,llvm,utils} source
115
+
mv tapi-src source/tapi
116
+
'';
117
+
118
+
strictDeps = true;
119
+
120
+
buildInputs = [ zlib ]; # Upstream links against zlib in their distribution.
121
+
122
+
nativeBuildInputs = [
123
+
cmake
124
+
ninja
125
+
python3
126
+
];
127
+
128
+
cmakeDir = "../llvm";
129
+
130
+
cmakeFlags = [
131
+
(lib.cmakeFeature "LLVM_ENABLE_PROJECTS" "clang;tapi")
132
+
(lib.cmakeFeature "LLVM_EXTERNAL_PROJECTS" "tapi")
133
+
(lib.cmakeBool "TAPI_INCLUDE_DOCS" true)
134
+
# Matches the version string format reported by upstream `tapi`.
135
+
(lib.cmakeFeature "TAPI_REPOSITORY_STRING" "tapi-${finalAttrs.version}")
136
+
(lib.cmakeFeature "TAPI_FULL_VERSION" appleLlvm.version)
137
+
# Match the versioning used by Apple’s LLVM fork (primarily used for .so versioning).
138
+
(lib.cmakeFeature "LLVM_VERSION_MAJOR" (lib.versions.major appleLlvm.version))
139
+
(lib.cmakeFeature "LLVM_VERSION_MINOR" (lib.versions.minor appleLlvm.version))
140
+
(lib.cmakeFeature "LLVM_VERSION_PATCH" (lib.versions.patch appleLlvm.version))
141
+
(lib.cmakeFeature "LLVM_VERSION_SUFFIX" "")
142
+
# Upstream `tapi` does not link against ncurses. Disable it explicitly to make sure
143
+
# it is not detected incorrectly from the bootstrap tools tarball.
144
+
(lib.cmakeBool "LLVM_ENABLE_TERMINFO" false)
145
+
# Disabling the benchmarks avoids a failure during the configure phase because
146
+
# the sparse checkout does not include the benchmarks.
147
+
(lib.cmakeBool "LLVM_INCLUDE_BENCHMARKS" false)
148
+
# tapi’s tests expect to target macOS 13.0 and build both x86_64 and universal
149
+
# binaries regardless of the host platform.
150
+
(lib.cmakeBool "LLVM_INCLUDE_TESTS" false)
151
+
(lib.cmakeBool "TAPI_INCLUDE_TESTS" false)
152
+
];
153
+
154
+
ninjaFlags = [
155
+
"libtapi"
156
+
"tapi-sdkdb"
157
+
"tapi"
158
+
];
159
+
160
+
installTargets = [
161
+
"install-libtapi"
162
+
"install-tapi-docs"
163
+
"install-tapi-headers"
164
+
"install-tapi-sdkdb"
165
+
"install-tapi"
166
+
];
167
+
168
+
postInstall = ''
169
+
# The man page is installed for these, but they’re not included in the source release.
170
+
rm $bin/share/man/man1/tapi-analyze.1 $bin/share/man/man1/tapi-api-verify.1
171
+
'';
172
+
173
+
meta = {
174
+
description = "Replaces the Mach-O Dynamic Library Stub files in Apple's SDKs to reduce the size";
175
+
homepage = "https://github.com/apple-oss-distributions/tapi/";
176
+
license = lib.licenses.ncsa;
177
+
mainProgram = "tapi";
178
+
maintainers = with lib.maintainers; [
179
+
matthewbauer
180
+
reckenrode
181
+
];
182
+
platforms = lib.platforms.unix;
183
+
};
184
+
})