Skip to content

Commit da69d99

Browse files
committed
Merge bitcoin/bitcoin#21871: scripts: add checks for minimum required OS versions
aa80b57 scripts: check macOS SDK version is set (fanquake) c972345 scripts: check minimum required Windows version is set (fanquake) 29615ae scripts: check minimum required macOS vesion is set (fanquake) 8732f7b scripts: LIEF 0.11.5 (fanquake) Pull request description: macOS: We use a compile flag ([-mmacosx-version-min=10.14](https://github.com/bitcoin/bitcoin/blob/master/depends/hosts/darwin.mk#L96)) to set the minimum required version of macOS needed to run our binaries. This adds a sanity check that the version is being set as expected. Clangs Darwin driver should infer the SDK version used during compilation, and forward that through to the linker. Add a check that this has been done, and the expected SDK version is set. Should help prevent issues like #21771 in future. Windows: We use linker flags ([-Wl,--major/minor-subsystem-version](https://github.com/bitcoin/bitcoin/blob/master/configure.ac#L683)) to set the minimum required version of Windows needed to run our binaries. This adds a sanity check that the version is being set as expected. Gitian builds: ```bash # macOS: 8b6fcd61d75001c37b2af3fceb5ae09f5d2fe85e97d361f684214bd91c27954a bitcoin-f015e1c2cac9-osx-unsigned.dmg 3c1e412bc7f5a7a5d0f78e2cd84b7096831414e1304c1307211aa3e135d89bbf bitcoin-f015e1c2cac9-osx-unsigned.tar.gz 50b7b2804e8481f63c69c78e3e8a71c0d811bf2db8895dd6d3edae9c46a738ae bitcoin-f015e1c2cac9-osx64.tar.gz fe6b5c0a550096b76b6727efee30e85b60163a41c83f21868c849fdd9876b675 src/bitcoin-f015e1c2cac9.tar.gz 8a20f21b20673dfc8c23e22b20ae0839bcaf65bf0e02f62381cdf5e7922936f0 bitcoin-core-osx-22-res.yml # Windows: b01fcdc2a5673387050d6c6c4f96f1d350976a121155fde3f76c2af309111f9d bitcoin-f015e1c2cac9-win-unsigned.tar.gz b95bdcbef638804030671d2332d58011f8c4ed4c1db87d6ffd211515c32c9d02 bitcoin-f015e1c2cac9-win64-debug.zip 350bf180252d24a3d40f05e22398fec7bb00e06d812204eb5a421100a8e10638 bitcoin-f015e1c2cac9-win64-setup-unsigned.exe 2730ddabe246d99913c9a779e97edcadb2d55309933d46f1dffd0d23ecf9aae5 bitcoin-f015e1c2cac9-win64.zip fe6b5c0a550096b76b6727efee30e85b60163a41c83f21868c849fdd9876b675 src/bitcoin-f015e1c2cac9.tar.gz aa60d7a753e8cb2d4323cfbbf4d964ad3645e74c918cccd66862888f8646d80f bitcoin-core-win-22-res.yml ``` ACKs for top commit: hebasto: ACK aa80b57, tested by breaking tests: Tree-SHA512: 10150219910e8131715fbfe20edaa15778387616ef3bfe1a5152c7acd3958fe8f88c74961c3d3641074eb72824680c22764bb1dc01a19e92e946c2d4962a8d2c
2 parents ad0c8f3 + aa80b57 commit da69d99

File tree

6 files changed

+61
-11
lines changed

6 files changed

+61
-11
lines changed

contrib/devtools/symbol-check.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,18 @@ def check_MACHO_libraries(filename) -> bool:
212212
ok = False
213213
return ok
214214

215+
def check_MACHO_min_os(filename) -> bool:
216+
binary = lief.parse(filename)
217+
if binary.build_version.minos == [10,14,0]:
218+
return True
219+
return False
220+
221+
def check_MACHO_sdk(filename) -> bool:
222+
binary = lief.parse(filename)
223+
if binary.build_version.sdk == [10, 15, 6]:
224+
return True
225+
return False
226+
215227
def check_PE_libraries(filename) -> bool:
216228
ok: bool = True
217229
binary = lief.parse(filename)
@@ -221,17 +233,28 @@ def check_PE_libraries(filename) -> bool:
221233
ok = False
222234
return ok
223235

236+
def check_PE_subsystem_version(filename) -> bool:
237+
binary = lief.parse(filename)
238+
major: int = binary.optional_header.major_subsystem_version
239+
minor: int = binary.optional_header.minor_subsystem_version
240+
if major == 6 and minor == 1:
241+
return True
242+
return False
243+
224244
CHECKS = {
225245
'ELF': [
226246
('IMPORTED_SYMBOLS', check_imported_symbols),
227247
('EXPORTED_SYMBOLS', check_exported_symbols),
228248
('LIBRARY_DEPENDENCIES', check_ELF_libraries)
229249
],
230250
'MACHO': [
231-
('DYNAMIC_LIBRARIES', check_MACHO_libraries)
251+
('DYNAMIC_LIBRARIES', check_MACHO_libraries),
252+
('MIN_OS', check_MACHO_min_os),
253+
('SDK', check_MACHO_sdk),
232254
],
233255
'PE' : [
234-
('DYNAMIC_LIBRARIES', check_PE_libraries)
256+
('DYNAMIC_LIBRARIES', check_PE_libraries),
257+
('SUBSYSTEM_VERSION', check_PE_subsystem_version),
235258
]
236259
}
237260

contrib/devtools/test-symbol-check.py

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def test_MACHO(self):
9898

9999
self.assertEqual(call_symbol_check(cc, source, executable, ['-lexpat']),
100100
(1, 'libexpat.1.dylib is not in ALLOWED_LIBRARIES!\n' +
101-
executable + ': failed DYNAMIC_LIBRARIES'))
101+
f'{executable}: failed DYNAMIC_LIBRARIES MIN_OS SDK'))
102102

103103
source = 'test2.c'
104104
executable = 'test2'
@@ -114,7 +114,20 @@ def test_MACHO(self):
114114
''')
115115

116116
self.assertEqual(call_symbol_check(cc, source, executable, ['-framework', 'CoreGraphics']),
117-
(0, ''))
117+
(1, f'{executable}: failed MIN_OS SDK'))
118+
119+
source = 'test3.c'
120+
executable = 'test3'
121+
with open(source, 'w', encoding="utf8") as f:
122+
f.write('''
123+
int main()
124+
{
125+
return 0;
126+
}
127+
''')
128+
129+
self.assertEqual(call_symbol_check(cc, source, executable, ['-mmacosx-version-min=10.14']),
130+
(1, f'{executable}: failed SDK'))
118131

119132
def test_PE(self):
120133
source = 'test1.c'
@@ -132,12 +145,26 @@ def test_PE(self):
132145
}
133146
''')
134147

135-
self.assertEqual(call_symbol_check(cc, source, executable, ['-lpdh']),
148+
self.assertEqual(call_symbol_check(cc, source, executable, ['-lpdh', '-Wl,--major-subsystem-version', '-Wl,6', '-Wl,--minor-subsystem-version', '-Wl,1']),
136149
(1, 'pdh.dll is not in ALLOWED_LIBRARIES!\n' +
137150
executable + ': failed DYNAMIC_LIBRARIES'))
138151

139152
source = 'test2.c'
140153
executable = 'test2.exe'
154+
155+
with open(source, 'w', encoding="utf8") as f:
156+
f.write('''
157+
int main()
158+
{
159+
return 0;
160+
}
161+
''')
162+
163+
self.assertEqual(call_symbol_check(cc, source, executable, ['-Wl,--major-subsystem-version', '-Wl,9', '-Wl,--minor-subsystem-version', '-Wl,9']),
164+
(1, executable + ': failed SUBSYSTEM_VERSION'))
165+
166+
source = 'test3.c'
167+
executable = 'test3.exe'
141168
with open(source, 'w', encoding="utf8") as f:
142169
f.write('''
143170
#include <windows.h>
@@ -149,7 +176,7 @@ def test_PE(self):
149176
}
150177
''')
151178

152-
self.assertEqual(call_symbol_check(cc, source, executable, ['-lole32']),
179+
self.assertEqual(call_symbol_check(cc, source, executable, ['-lole32', '-Wl,--major-subsystem-version', '-Wl,6', '-Wl,--minor-subsystem-version', '-Wl,1']),
153180
(0, ''))
154181

155182

contrib/gitian-descriptors/gitian-linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ script: |
9999
done
100100
}
101101
102-
pip3 install lief==0.11.4
102+
pip3 install lief==0.11.5
103103
104104
# Faketime for depends so intermediate results are comparable
105105
export PATH_orig=${PATH}

contrib/gitian-descriptors/gitian-osx.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ script: |
7878
done
7979
}
8080
81-
pip3 install lief==0.11.4
81+
pip3 install lief==0.11.5
8282
8383
# Faketime for depends so intermediate results are comparable
8484
export PATH_orig=${PATH}

contrib/gitian-descriptors/gitian-win.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ script: |
8686
done
8787
}
8888
89-
pip3 install lief==0.11.4
89+
pip3 install lief==0.11.5
9090
9191
# Faketime for depends so intermediate results are comparable
9292
export PATH_orig=${PATH}

contrib/guix/manifest.scm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ chain for " target " development."))
206206
(define-public lief
207207
(package
208208
(name "python-lief")
209-
(version "0.11.4")
209+
(version "0.11.5")
210210
(source
211211
(origin
212212
(method git-fetch)
@@ -216,7 +216,7 @@ chain for " target " development."))
216216
(file-name (git-file-name name version))
217217
(sha256
218218
(base32
219-
"0h4kcwr9z478almjqhmils8imfpflzk0r7d05g4xbkdyknn162qf"))))
219+
"0qahjfg1n0x76ps2mbyljvws1l3qhkqvmxqbahps4qgywl2hbdkj"))))
220220
(build-system python-build-system)
221221
(native-inputs
222222
`(("cmake" ,cmake)))

0 commit comments

Comments
 (0)