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