Skip to content

Commit aa80b57

Browse files
committed
scripts: check macOS SDK version is set
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.
1 parent c972345 commit aa80b57

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

contrib/devtools/symbol-check.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,12 @@ def check_MACHO_min_os(filename) -> bool:
218218
return True
219219
return False
220220

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+
221227
def check_PE_libraries(filename) -> bool:
222228
ok: bool = True
223229
binary = lief.parse(filename)
@@ -244,6 +250,7 @@ def check_PE_subsystem_version(filename) -> bool:
244250
'MACHO': [
245251
('DYNAMIC_LIBRARIES', check_MACHO_libraries),
246252
('MIN_OS', check_MACHO_min_os),
253+
('SDK', check_MACHO_sdk),
247254
],
248255
'PE' : [
249256
('DYNAMIC_LIBRARIES', check_PE_libraries),

contrib/devtools/test-symbol-check.py

Lines changed: 3 additions & 3 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 MIN_OS'))
101+
f'{executable}: failed DYNAMIC_LIBRARIES MIN_OS SDK'))
102102

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

116116
self.assertEqual(call_symbol_check(cc, source, executable, ['-framework', 'CoreGraphics']),
117-
(1, executable + ': failed MIN_OS'))
117+
(1, f'{executable}: failed MIN_OS SDK'))
118118

119119
source = 'test3.c'
120120
executable = 'test3'
@@ -127,7 +127,7 @@ def test_MACHO(self):
127127
''')
128128

129129
self.assertEqual(call_symbol_check(cc, source, executable, ['-mmacosx-version-min=10.14']),
130-
(0, ''))
130+
(1, f'{executable}: failed SDK'))
131131

132132
def test_PE(self):
133133
source = 'test1.c'

0 commit comments

Comments
 (0)