Skip to content

Commit 42c910a

Browse files
committed
merge bitcoin#21851: support cross-compiling for arm64-apple-darwin
1 parent b1243dc commit 42c910a

File tree

16 files changed

+63
-49
lines changed

16 files changed

+63
-49
lines changed

.github/workflows/guix-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
export ADDITIONAL_GUIX_COMMON_FLAGS='--max-jobs=32' && \
4646
mkdir -p depends/SDKs && \
4747
mkdir -p /tmp/guix-store && \
48-
curl -L https://bitcoincore.org/depends-sources/sdks/Xcode-12.1-12A7403-extracted-SDK-with-libcxx-headers.tar.gz | tar -xz -C depends/SDKs && \
48+
curl -L https://bitcoincore.org/depends-sources/sdks/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers.tar.gz | tar -xz -C depends/SDKs && \
4949
docker run --privileged -d --name guix-daemon --rm -v ${{ github.workspace }}:/dash -w /dash alpine-guix:latest && \
5050
docker exec guix-daemon bash -c "\
5151
chmod 777 /dash/depends && \

.gitlab-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ builder-image:
4242
image: $CI_REGISTRY_IMAGE:builder-$CI_COMMIT_REF_SLUG
4343
variables:
4444
SDK_URL: https://bitcoincore.org/depends-sources/sdks
45-
XCODE_VERSION: "12.1"
46-
XCODE_BUILD_ID: 12A7403
45+
XCODE_VERSION: "12.2"
46+
XCODE_BUILD_ID: 12B45b
4747
MAKEJOBS: -j4
4848
before_script:
4949
- echo HOST=$HOST

ci/test/00_setup_env_mac.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ export LC_ALL=C.UTF-8
99
export CONTAINER_NAME=ci_macos_cross
1010
export HOST=x86_64-apple-darwin
1111
export PACKAGES="cmake libcap-dev libz-dev libbz2-dev python3-dev python3-setuptools"
12-
export XCODE_VERSION=12.1
13-
export XCODE_BUILD_ID=12A7403
12+
export XCODE_VERSION=12.2
13+
export XCODE_BUILD_ID=12B45b
1414
export RUN_UNIT_TESTS=false
1515
export RUN_INTEGRATION_TESTS=false
1616
export GOAL="all deploy"

contrib/devtools/security-check.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,9 @@ def check_MACHO_control_flow(binary) -> bool:
206206
]
207207

208208
BASE_MACHO = [
209-
('PIE', check_PIE),
210209
('NOUNDEFS', check_MACHO_NOUNDEFS),
211-
('NX', check_NX),
212210
('LAZY_BINDINGS', check_MACHO_LAZY_BINDINGS),
213211
('Canary', check_MACHO_Canary),
214-
('CONTROL_FLOW', check_MACHO_control_flow),
215212
]
216213

217214
CHECKS = {
@@ -226,7 +223,10 @@ def check_MACHO_control_flow(binary) -> bool:
226223
lief.ARCHITECTURES.X86: BASE_PE,
227224
},
228225
lief.EXE_FORMATS.MACHO: {
229-
lief.ARCHITECTURES.X86: BASE_MACHO,
226+
lief.ARCHITECTURES.X86: BASE_MACHO + [('PIE', check_PIE),
227+
('NX', check_NX),
228+
('CONTROL_FLOW', check_MACHO_control_flow)],
229+
lief.ARCHITECTURES.ARM64: BASE_MACHO,
230230
}
231231
}
232232

contrib/devtools/symbol-check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def check_MACHO_min_os(binary) -> bool:
217217
return False
218218

219219
def check_MACHO_sdk(binary) -> bool:
220-
if binary.build_version.sdk == [10, 15, 6]:
220+
if binary.build_version.sdk == [11, 0, 0]:
221221
return True
222222
return False
223223

contrib/devtools/test-security-check.py

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -116,21 +116,34 @@ def test_MACHO(self):
116116
executable = 'test1'
117117
cc = determine_wellknown_cmd('CC', 'clang')
118118
write_testcode(source)
119+
arch = get_arch(cc, source, executable)
120+
121+
if arch == lief.ARCHITECTURES.X86:
122+
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'))
124+
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'))
126+
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'))
128+
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie','-fstack-protector-all']),
129+
(1, executable+': failed LAZY_BINDINGS PIE CONTROL_FLOW'))
130+
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie','-Wl,-bind_at_load','-fstack-protector-all']),
131+
(1, executable+': failed PIE CONTROL_FLOW'))
132+
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie','-Wl,-bind_at_load','-fstack-protector-all', '-fcf-protection=full']),
133+
(1, executable+': failed PIE'))
134+
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-pie','-Wl,-bind_at_load','-fstack-protector-all', '-fcf-protection=full']),
135+
(0, ''))
136+
else:
137+
# arm64 darwin doesn't support non-PIE binaries, control flow or executable stacks
138+
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-flat_namespace','-fno-stack-protector']),
139+
(1, executable+': failed NOUNDEFS LAZY_BINDINGS Canary'))
140+
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'))
144+
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-bind_at_load','-fstack-protector-all']),
145+
(0, ''))
119146

120-
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie','-Wl,-flat_namespace','-Wl,-allow_stack_execute','-fno-stack-protector']),
121-
(1, executable+': failed PIE NOUNDEFS NX LAZY_BINDINGS Canary CONTROL_FLOW'))
122-
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie','-Wl,-flat_namespace','-Wl,-allow_stack_execute','-fstack-protector-all']),
123-
(1, executable+': failed PIE NOUNDEFS NX LAZY_BINDINGS CONTROL_FLOW'))
124-
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie','-Wl,-flat_namespace','-fstack-protector-all']),
125-
(1, executable+': failed PIE NOUNDEFS LAZY_BINDINGS CONTROL_FLOW'))
126-
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie','-fstack-protector-all']),
127-
(1, executable+': failed PIE LAZY_BINDINGS CONTROL_FLOW'))
128-
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie','-Wl,-bind_at_load','-fstack-protector-all']),
129-
(1, executable+': failed PIE CONTROL_FLOW'))
130-
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie','-Wl,-bind_at_load','-fstack-protector-all', '-fcf-protection=full']),
131-
(1, executable+': failed PIE'))
132-
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-pie','-Wl,-bind_at_load','-fstack-protector-all', '-fcf-protection=full']),
133-
(0, ''))
134147

135148
clean_files(source, executable)
136149

contrib/gitian-build.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ def build():
7474

7575
if args.macos:
7676
print('\nCompiling ' + args.version + ' MacOS')
77-
subprocess.check_call(['wget', '-N', '-P', 'inputs', 'https://bitcoincore.org/depends-sources/sdks/Xcode-12.1-12A7403-extracted-SDK-with-libcxx-headers.tar.gz'])
78-
subprocess.check_output(["echo 'be17f48fd0b08fb4dcd229f55a6ae48d9f781d210839b4ea313ef17dd12d6ea5 inputs/Xcode-12.1-12A7403-extracted-SDK-with-libcxx-headers.tar.gz' | sha256sum -c"], shell=True)
77+
subprocess.check_call(['wget', '-N', '-P', 'inputs', 'https://bitcoincore.org/depends-sources/sdks/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers.tar.gz'])
78+
subprocess.check_output(["echo 'df75d30ecafc429e905134333aeae56ac65fac67cb4182622398fd717df77619 inputs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers.tar.gz' | sha256sum -c"], shell=True)
7979
subprocess.check_call(['bin/gbuild', '--fetch-tags', '-j', args.jobs, '-m', args.memory, '--commit', 'dash='+args.commit, '--url', 'dash='+args.url, '../dash/contrib/gitian-descriptors/gitian-osx.yml'])
8080
subprocess.check_call(['bin/gsign', '-p', args.sign_prog, '--signer', args.signer, '--release', args.version+'-osx-unsigned', '--destination', '../gitian.sigs/', '../dash/contrib/gitian-descriptors/gitian-osx.yml'])
8181
subprocess.check_call('mv build/out/dashcore-*-osx-unsigned.tar.gz inputs/', shell=True)
@@ -218,7 +218,7 @@ def main():
218218
args.macos = 'm' in args.os
219219

220220
# Disable for MacOS if no SDK found
221-
if args.macos and not os.path.isfile('gitian-builder/inputs/Xcode-12.1-12A7403-extracted-SDK-with-libcxx-headers.tar.gz'):
221+
if args.macos and not os.path.isfile('gitian-builder/inputs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers.tar.gz'):
222222
print('Cannot build for MacOS, SDK does not exist. Will build for other OSes')
223223
args.macos = False
224224

contrib/gitian-descriptors/gitian-osx.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ remotes:
3333
- "url": "https://github.com/dashpay/dash.git"
3434
"dir": "dash"
3535
files:
36-
- "Xcode-12.1-12A7403-extracted-SDK-with-libcxx-headers.tar.gz"
36+
- "Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers.tar.gz"
3737
script: |
3838
set -e -o pipefail
3939
@@ -108,7 +108,7 @@ script: |
108108
BASEPREFIX="${PWD}/depends"
109109
110110
mkdir -p ${BASEPREFIX}/SDKs
111-
tar -C ${BASEPREFIX}/SDKs -xf ${BUILD_DIR}/Xcode-12.1-12A7403-extracted-SDK-with-libcxx-headers.tar.gz
111+
tar -C ${BASEPREFIX}/SDKs -xf ${BUILD_DIR}/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers.tar.gz
112112
113113
# Build dependencies for each host
114114
for i in $HOSTS; do

contrib/guix/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,5 @@ RUN mkdir base_cache sources SDKs
5959
WORKDIR /dash
6060

6161
RUN mkdir -p depends/SDKs && \
62-
curl -L https://bitcoincore.org/depends-sources/sdks/Xcode-12.1-12A7403-extracted-SDK-with-libcxx-headers.tar.gz | tar -xz -C depends/SDKs
62+
curl -L https://bitcoincore.org/depends-sources/sdks/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers.tar.gz | tar -xz -C depends/SDKs
6363

contrib/guix/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ details.
224224

225225
_(defaults to "x86\_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu
226226
powerpc64-linux-gnu powerpc64le-linux-gnu
227-
x86\_64-w64-mingw32 x86\_64-apple-darwin")_
227+
x86\_64-w64-mingw32 x86\_64-apple-darwin arm64-apple-darwin")_
228228

229229
* _**SOURCES_PATH**_
230230

@@ -249,7 +249,7 @@ details.
249249
Set the path where _extracted_ SDKs can be found. This is passed through to
250250
the depends tree. Note that this is should be set to the _parent_ directory of
251251
the actual SDK (e.g. `SDK_PATH=$HOME/Downloads/macOS-SDKs` instead of
252-
`$HOME/Downloads/macOS-SDKs/Xcode-12.1-12A7403-extracted-SDK-with-libcxx-headers`).
252+
`$HOME/Downloads/macOS-SDKs/Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers`).
253253

254254
The path that this environment variable points to **must be a directory**, and
255255
**NOT a symlink to a directory**.

0 commit comments

Comments
 (0)