Skip to content

Commit 4a0536c

Browse files
committed
build: switch to using lld for macOS builds
Adjust the security check for: ld64.lld: warning: Option `-allow_stack_execute' is not yet implemented. ld64.lld: error: -fixup_chains is incompatible with -no_pie and to account for the embedding of LLVMs version number.
1 parent c6a6b2d commit 4a0536c

File tree

4 files changed

+12
-17
lines changed

4 files changed

+12
-17
lines changed

contrib/devtools/symbol-check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def check_MACHO_sdk(binary) -> bool:
240240
return False
241241

242242
def check_MACHO_ld64(binary) -> bool:
243-
if binary.build_version.tools[0].version == [711, 0, 0]:
243+
if binary.build_version.tools[0].version == [17, 0, 6]:
244244
return True
245245
return False
246246

contrib/devtools/test-security-check.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -120,21 +120,15 @@ def test_MACHO(self):
120120
arch = get_arch(cc, source, executable)
121121

122122
if arch == lief.ARCHITECTURES.X86:
123-
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie','-Wl,-flat_namespace','-Wl,-allow_stack_execute','-fno-stack-protector', '-Wl,-no_fixup_chains']),
124-
(1, executable+': failed NOUNDEFS Canary FIXUP_CHAINS PIE NX CONTROL_FLOW'))
125-
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie','-Wl,-flat_namespace','-Wl,-allow_stack_execute','-fno-stack-protector', '-Wl,-fixup_chains']),
126-
(1, executable+': failed NOUNDEFS Canary PIE NX CONTROL_FLOW'))
127-
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie','-Wl,-flat_namespace','-Wl,-allow_stack_execute','-fstack-protector-all', '-Wl,-fixup_chains']),
128-
(1, executable+': failed NOUNDEFS PIE NX CONTROL_FLOW'))
129-
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie','-Wl,-flat_namespace','-fstack-protector-all', '-Wl,-fixup_chains']),
130-
(1, executable+': failed NOUNDEFS PIE CONTROL_FLOW'))
131-
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie','-fstack-protector-all', '-Wl,-fixup_chains']),
132-
(1, executable+': failed PIE CONTROL_FLOW'))
133-
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie','-fstack-protector-all', '-Wl,-fixup_chains']),
134-
(1, executable+': failed PIE CONTROL_FLOW'))
135-
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie','-fstack-protector-all', '-fcf-protection=full', '-Wl,-fixup_chains']),
136-
(1, executable+': failed PIE'))
137-
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-pie','-fstack-protector-all', '-fcf-protection=full', '-Wl,-fixup_chains']),
123+
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie','-Wl,-flat_namespace','-fno-stack-protector', '-Wl,-no_fixup_chains']),
124+
(1, executable+': failed NOUNDEFS Canary FIXUP_CHAINS PIE CONTROL_FLOW'))
125+
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-flat_namespace','-fno-stack-protector', '-Wl,-fixup_chains']),
126+
(1, executable+': failed NOUNDEFS Canary CONTROL_FLOW'))
127+
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-flat_namespace','-fstack-protector-all', '-Wl,-fixup_chains']),
128+
(1, executable+': failed NOUNDEFS CONTROL_FLOW'))
129+
self.assertEqual(call_security_check(cc, source, executable, ['-fstack-protector-all', '-Wl,-fixup_chains']),
130+
(1, executable+': failed CONTROL_FLOW'))
131+
self.assertEqual(call_security_check(cc, source, executable, ['-fstack-protector-all', '-fcf-protection=full', '-Wl,-fixup_chains']),
138132
(0, ''))
139133
else:
140134
# arm64 darwin doesn't support non-PIE binaries, control flow or executable stacks

depends/hosts/darwin.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ darwin_LDFLAGS=-Wl,-platform_version,macos,$(OSX_MIN_VERSION),$(OSX_SDK_VERSION)
115115
ifneq ($(build_os),darwin)
116116
darwin_CFLAGS += -mlinker-version=$(LD64_VERSION)
117117
darwin_CXXFLAGS += -mlinker-version=$(LD64_VERSION)
118-
darwin_LDFLAGS += -Wl,-no_adhoc_codesign
118+
darwin_LDFLAGS += -Wl,-no_adhoc_codesign -fuse-ld=lld
119119
endif
120120

121121
darwin_release_CFLAGS=-O2

depends/patches/qt/mac-qmake.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ QMAKE_MAC_SDK.macosx.Path = $${MAC_SDK_PATH}
1313
QMAKE_MAC_SDK.macosx.platform_name = macosx
1414
QMAKE_MAC_SDK.macosx.SDKVersion = $${MAC_SDK_VERSION}
1515
QMAKE_MAC_SDK.macosx.PlatformPath = /phony
16+
QMAKE_CXXFLAGS += -fuse-ld=lld
1617
!host_build: QMAKE_CFLAGS += -target $${MAC_TARGET}
1718
!host_build: QMAKE_OBJECTIVE_CFLAGS += $$QMAKE_CFLAGS
1819
!host_build: QMAKE_CXXFLAGS += -target $${MAC_TARGET}

0 commit comments

Comments
 (0)