Skip to content

Commit 35b01e8

Browse files
committed
Merge bitcoin/bitcoin#27676: macOS: Bump minimum required runtime version and prepare for building with upstream LLVM
3df6070 contrib: remove macOS lazy_bind check (fanquake) 9bc357e build: explicitly opt-in to new fixup_chains functionality for darwin (Cory Fields) fb61bc0 depends: Bump MacOS minimum runtime requirement to 11.0 (Cory Fields) c2cd472 depends: bump darwin clang to 11.1 (Cory Fields) Pull request description: This (I believe) resolves the last of the blockers for [switching us away from cctools and instead using out-of-the-box llvm and lld](bitcoin/bitcoin#21778) for building Darwin binaries. For now, we continue building with a pre-packaged llvm and cctools, but after this PR the clang+lld combo should just work for anyone trying it. Additionally after this PR, the new runtime `fixup_chains` behavior will be in-use, as ld64 uses it as well. The commits may seem unrelated, so in detail: lld (llvm's linker) has been a work-in-progress for Darwin for years. Recently though, it has gained nearly all of the features we require. The last missing feature from ld64, `-Wl,-bind_at_load`, is not implemented in lld; as far as I can tell [lazy loading has conceptually been replaced by fixup chains](https://www.emergetools.com/blog/posts/iOS15LaunchTime). So that means we don't need ld64's `bind_at_load` as long as lld can handle `-Wl,-fixup_chains` (which it can). I've added it to our configure as a linker option mostly so that we can see it in the logs; it's default-on as long as the minimum version is >11.0. About that: the runtime functionality required for `-Wl,-fixup_chains` [requires macOS >=11.0](https://github.com/llvm/llvm-project/blob/release/16.x/lld/MachO/Driver.cpp#L1021). Hence the commit that bumps the minimum version. Our current min runtime of `10.15` has been unsupported since September 2022, so I don't expect this bump to be controversial. Lastly, with the minimum runtime version bumped to 11.0, our current version of pre-compiled clang we use for macOS is too old to understand `-mmacosx-version-min=11.0` because it expects `=10.x`. So I've made the smallest possible bump (from 10.0.1 to 11.1.0) to a version that understands. This bump is arbitrary and unfortunate, but likely to be short-lived as we may end up replacing it with llvm+lld for v26 anyway. I've held off on bumping the SDK as I think that makes sense to do as part of the lld switch instead. ACKs for top commit: hebasto: ACK 3df6070 gruve-p: ACK bitcoin/bitcoin@3df6070 fanquake: ACK 3df6070 TheCharlatan: ACK 3df6070 Tree-SHA512: 0200ec4a3b88df33877ae82c15b5c04d745852550923f491a354b391cac65f88e4df116a40055c23a8cbcfcdfb9a376c6ae8fdd0e898e7b966bc213dcb5857cf
2 parents 679f825 + 3df6070 commit 35b01e8

11 files changed

+17
-26
lines changed

.cirrus.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ task:
314314
<< : *CIRRUS_EPHEMERAL_WORKER_TEMPLATE_ENV
315315

316316
task:
317-
name: 'macOS 10.15 [gui, no tests] [jammy]'
317+
name: 'macOS 11.0 [gui, no tests] [jammy]'
318318
<< : *CONTAINER_DEPENDS_TEMPLATE
319319
container:
320320
docker_arguments:

configure.ac

+1
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,7 @@ if test "$TARGET_OS" = "darwin"; then
10081008
AX_CHECK_LINK_FLAG([-Wl,-dead_strip], [CORE_LDFLAGS="$CORE_LDFLAGS -Wl,-dead_strip"], [], [$LDFLAG_WERROR])
10091009
AX_CHECK_LINK_FLAG([-Wl,-dead_strip_dylibs], [CORE_LDFLAGS="$CORE_LDFLAGS -Wl,-dead_strip_dylibs"], [], [$LDFLAG_WERROR])
10101010
AX_CHECK_LINK_FLAG([-Wl,-bind_at_load], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-bind_at_load"], [], [$LDFLAG_WERROR])
1011+
AX_CHECK_LINK_FLAG([-Wl,-fixup_chains], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-fixup_chains"], [], [$LDFLAG_WERROR])
10111012
fi
10121013

10131014
AC_CHECK_HEADERS([endian.h sys/endian.h byteswap.h sys/select.h sys/prctl.h sys/sysctl.h vm/vm_param.h sys/vmmeter.h sys/resources.h])

contrib/devtools/security-check.py

-8
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,6 @@ def check_MACHO_NOUNDEFS(binary) -> bool:
158158
'''
159159
return binary.header.has(lief.MachO.HEADER_FLAGS.NOUNDEFS)
160160

161-
def check_MACHO_LAZY_BINDINGS(binary) -> bool:
162-
'''
163-
Check for no lazy bindings.
164-
We don't use or check for MH_BINDATLOAD. See #18295.
165-
'''
166-
return binary.dyld_info.lazy_bind == (0,0)
167-
168161
def check_MACHO_Canary(binary) -> bool:
169162
'''
170163
Check for use of stack canary
@@ -214,7 +207,6 @@ def check_MACHO_control_flow(binary) -> bool:
214207

215208
BASE_MACHO = [
216209
('NOUNDEFS', check_MACHO_NOUNDEFS),
217-
('LAZY_BINDINGS', check_MACHO_LAZY_BINDINGS),
218210
('Canary', check_MACHO_Canary),
219211
]
220212

contrib/devtools/symbol-check.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def check_MACHO_libraries(binary) -> bool:
232232
return ok
233233

234234
def check_MACHO_min_os(binary) -> bool:
235-
if binary.build_version.minos == [10,15,0]:
235+
if binary.build_version.minos == [11,0,0]:
236236
return True
237237
return False
238238

contrib/devtools/test-security-check.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@ def test_MACHO(self):
120120

121121
if arch == lief.ARCHITECTURES.X86:
122122
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie','-Wl,-flat_namespace','-Wl,-allow_stack_execute','-fno-stack-protector']),
123-
(1, executable+': failed NOUNDEFS LAZY_BINDINGS Canary PIE NX CONTROL_FLOW'))
123+
(1, executable+': failed NOUNDEFS Canary PIE NX CONTROL_FLOW'))
124124
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie','-Wl,-flat_namespace','-Wl,-allow_stack_execute','-fstack-protector-all']),
125-
(1, executable+': failed NOUNDEFS LAZY_BINDINGS PIE NX CONTROL_FLOW'))
125+
(1, executable+': failed NOUNDEFS PIE NX CONTROL_FLOW'))
126126
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie','-Wl,-flat_namespace','-fstack-protector-all']),
127-
(1, executable+': failed NOUNDEFS LAZY_BINDINGS PIE CONTROL_FLOW'))
127+
(1, executable+': failed NOUNDEFS PIE CONTROL_FLOW'))
128128
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie','-fstack-protector-all']),
129-
(1, executable+': failed LAZY_BINDINGS PIE CONTROL_FLOW'))
129+
(1, executable+': failed PIE CONTROL_FLOW'))
130130
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie','-Wl,-bind_at_load','-fstack-protector-all']),
131131
(1, executable+': failed PIE CONTROL_FLOW'))
132132
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie','-Wl,-bind_at_load','-fstack-protector-all', '-fcf-protection=full']),
@@ -136,11 +136,9 @@ def test_MACHO(self):
136136
else:
137137
# arm64 darwin doesn't support non-PIE binaries, control flow or executable stacks
138138
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-flat_namespace','-fno-stack-protector']),
139-
(1, executable+': failed NOUNDEFS LAZY_BINDINGS Canary'))
139+
(1, executable+': failed NOUNDEFS Canary'))
140140
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-flat_namespace','-fstack-protector-all']),
141-
(1, executable+': failed NOUNDEFS LAZY_BINDINGS'))
142-
self.assertEqual(call_security_check(cc, source, executable, ['-fstack-protector-all']),
143-
(1, executable+': failed LAZY_BINDINGS'))
141+
(1, executable+': failed NOUNDEFS'))
144142
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-bind_at_load','-fstack-protector-all']),
145143
(0, ''))
146144

contrib/devtools/test-symbol-check.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def test_MACHO(self):
121121
}
122122
''')
123123

124-
self.assertEqual(call_symbol_check(cc, source, executable, ['-Wl,-platform_version','-Wl,macos', '-Wl,10.15', '-Wl,11.4']),
124+
self.assertEqual(call_symbol_check(cc, source, executable, ['-Wl,-platform_version','-Wl,macos', '-Wl,11.0', '-Wl,11.4']),
125125
(1, f'{executable}: failed SDK'))
126126

127127
def test_PE(self):

contrib/guix/manifest.scm

+1-1
Original file line numberDiff line numberDiff line change
@@ -608,5 +608,5 @@ inspecting signatures in Mach-O binaries.")
608608
((string-contains target "-linux-")
609609
(list (make-bitcoin-cross-toolchain target)))
610610
((string-contains target "darwin")
611-
(list clang-toolchain-10 binutils cmake-minimal xorriso python-signapple))
611+
(list clang-toolchain-11 binutils cmake-minimal xorriso python-signapple))
612612
(else '())))))

depends/hosts/darwin.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
OSX_MIN_VERSION=10.15
1+
OSX_MIN_VERSION=11.0
22
OSX_SDK_VERSION=11.0
33
XCODE_VERSION=12.2
44
XCODE_BUILD_ID=12B45b

depends/packages/native_clang.mk

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package=native_clang
2-
$(package)_version=10.0.1
2+
$(package)_version=11.1.0
33
$(package)_download_path=https://github.com/llvm/llvm-project/releases/download/llvmorg-$($(package)_version)
44
ifneq (,$(findstring aarch64,$(BUILD)))
55
$(package)_file_name=clang+llvm-$($(package)_version)-aarch64-linux-gnu.tar.xz
6-
$(package)_sha256_hash=90dc69a4758ca15cd0ffa45d07fbf5bf4309d47d2c7745a9f0735ecffde9c31f
6+
$(package)_sha256_hash=18df38247af3fba0e0e2991fb00d7e3cf3560b4d3509233a14af699ef0039e1c
77
else
88
$(package)_file_name=clang+llvm-$($(package)_version)-x86_64-linux-gnu-ubuntu-16.04.tar.xz
9-
$(package)_sha256_hash=48b83ef827ac2c213d5b64f5ad7ed082c8bcb712b46644e0dc5045c6f462c231
9+
$(package)_sha256_hash=c691a558967fb7709fb81e0ed80d1f775f4502810236aa968b4406526b43bee1
1010
endif
1111

1212
define $(package)_stage_cmds

doc/release-notes-empty-template.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Compatibility
3636
==============
3737

3838
Bitcoin Core is supported and extensively tested on operating systems
39-
using the Linux kernel, macOS 10.15+, and Windows 7 and newer. Bitcoin
39+
using the Linux kernel, macOS 11.0+, and Windows 7 and newer. Bitcoin
4040
Core should also work on most other Unix-like systems but is not as
4141
frequently tested on them. It is not recommended to use Bitcoin Core on
4242
unsupported systems.

share/qt/Info.plist.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<plist version="0.9">
44
<dict>
55
<key>LSMinimumSystemVersion</key>
6-
<string>10.15.0</string>
6+
<string>11</string>
77

88
<key>LSArchitecturePriority</key>
99
<array>

0 commit comments

Comments
 (0)