Skip to content

Commit 574c845

Browse files
committed
guix: use llvm 18 toolchain for darwin targets
1 parent 8e7af08 commit 574c845

File tree

10 files changed

+41
-102
lines changed

10 files changed

+41
-102
lines changed

.github/workflows/depends.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ jobs:
6060
- name: "Cross-Mac x86_64"
6161
host: "x86_64-apple-darwin"
6262
rust_host: "x86_64-apple-darwin"
63-
packages: "clang libtool"
63+
packages: "clang-18 lld-18"
6464
- name: "Cross-Mac aarch64"
6565
host: "arm64-apple-darwin"
6666
rust_host: "aarch64-apple-darwin"
67-
packages: "clang libtool"
67+
packages: "clang-18 lld-18"
6868
- name: "x86_64 Freebsd"
6969
host: "x86_64-unknown-freebsd"
7070
rust_host: "x86_64-unknown-freebsd"
@@ -120,6 +120,10 @@ jobs:
120120
run: |
121121
update-alternatives --set ${{ matrix.toolchain.host }}-g++ $(which ${{ matrix.toolchain.host }}-g++-posix)
122122
update-alternatives --set ${{ matrix.toolchain.host }}-gcc $(which ${{ matrix.toolchain.host }}-gcc-posix)
123+
- name: prepare apple-darwin
124+
if: ${{ matrix.toolchain.host == 'x86_64-apple-darwin' || matrix.toolchain.host == 'arm64-apple-darwin' }}
125+
run: |
126+
echo "/usr/lib/llvm-18/bin/" >> $GITHUB_PATH
123127
- uses: ./.github/actions/set-make-job-count
124128
- name: build
125129
run: |

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,9 +467,13 @@ You can also cross-compile static binaries on Linux for Windows and macOS with t
467467
update-alternatives --set x86_64-w64-mingw32-gcc $(which x86_64-w64-mingw32-gcc-posix)
468468
```
469469
* ```make depends target=x86_64-apple-darwin``` for Intel macOS binaries.
470-
* Requires: `clang`
470+
* Requires: `clang-18 lld-18`
471471
* ```make depends target=arm64-apple-darwin``` for Apple Silicon macOS binaries.
472-
* Requires: `clang`
472+
* Requires: `clang-18 lld-18`
473+
* You also need to run:
474+
```shell
475+
export PATH="/usr/lib/llvm-18/bin/:$PATH"
476+
```
473477
* ```make depends target=i686-linux-gnu``` for 32-bit linux binaries.
474478
* Requires: `g++-multilib bc`
475479
* ```make depends target=i686-w64-mingw32``` for 32-bit windows binaries.

contrib/depends/hosts/darwin.mk

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
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
5-
LD64_VERSION=609
5+
LD64_VERSION=711
66

77
OSX_SDK=$(host_prefix)/native/SDK
88

9-
darwin_native_toolchain=darwin_sdk native_cctools
9+
darwin_native_toolchain=darwin_sdk
1010

11-
clang_prog=$(shell $(SHELL) $(.SHELLFLAGS) "command -v clang")
12-
clangxx_prog=$(shell $(SHELL) $(.SHELLFLAGS) "command -v clang++")
11+
clang_prog=clang
12+
clangxx_prog=clang++
13+
14+
darwin_AR=llvm-ar
15+
darwin_DSYMUTIL=dsymutil
16+
darwin_NM=llvm-nm
17+
darwin_OBJDUMP=llvm-objdump
18+
darwin_RANLIB=llvm-ranlib
19+
darwin_STRIP=llvm-strip
1320

1421
# Flag explanations:
1522
#
@@ -18,11 +25,6 @@ clangxx_prog=$(shell $(SHELL) $(.SHELLFLAGS) "command -v clang++")
1825
# Ensures that modern linker features are enabled. See here for more
1926
# details: https://github.com/bitcoin/bitcoin/pull/19407.
2027
#
21-
# -B$(build_prefix)/bin
22-
#
23-
# Explicitly point to our binaries (e.g. cctools) so that they are
24-
# ensured to be found and preferred over other possibilities.
25-
#
2628
# -isysroot$(OSX_SDK) -nostdlibinc
2729
#
2830
# Disable default include paths built into the compiler as well as
@@ -38,22 +40,22 @@ darwin_CC=env -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH \
3840
-u OBJC_INCLUDE_PATH -u OBJCPLUS_INCLUDE_PATH -u CPATH \
3941
-u LIBRARY_PATH \
4042
$(clang_prog) --target=$(host) -mmacosx-version-min=$(OSX_MIN_VERSION) \
41-
-B$(build_prefix)/bin -mlinker-version=$(LD64_VERSION) \
42-
-isysroot$(OSX_SDK) \
43+
-mlinker-version=$(LD64_VERSION) \
4344
-isysroot$(OSX_SDK) -nostdlibinc \
4445
-iwithsysroot/usr/include -iframeworkwithsysroot/System/Library/Frameworks
4546

4647
darwin_CXX=env -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH \
4748
-u OBJC_INCLUDE_PATH -u OBJCPLUS_INCLUDE_PATH -u CPATH \
4849
-u LIBRARY_PATH \
4950
$(clangxx_prog) --target=$(host) -mmacosx-version-min=$(OSX_MIN_VERSION) \
50-
-B$(build_prefix)/bin -mlinker-version=$(LD64_VERSION) \
51+
-mlinker-version=$(LD64_VERSION) \
5152
-isysroot$(OSX_SDK) -nostdlibinc \
5253
-iwithsysroot/usr/include/c++/v1 \
5354
-iwithsysroot/usr/include -iframeworkwithsysroot/System/Library/Frameworks
5455

5556
darwin_CFLAGS=-pipe
5657
darwin_CXXFLAGS=$(darwin_CFLAGS)
58+
darwin_LDFLAGS=-Wl,-platform_version,macos,$(OSX_MIN_VERSION),$(OSX_SDK_VERSION) -Wl,-no_adhoc_codesign -fuse-ld=lld
5759
darwin_ARFLAGS=cr
5860

5961
darwin_release_CFLAGS=-O2

contrib/depends/packages/boost.mk

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@ $(package)_config_opts+=--layout=system --user-config=user-config.jam
1111
$(package)_config_opts+=threading=multi link=static -sNO_BZIP2=1 -sNO_ZLIB=1
1212
$(package)_config_opts_linux=threadapi=pthread runtime-link=shared
1313
$(package)_config_opts_android=threadapi=pthread runtime-link=static target-os=android
14-
$(package)_config_opts_darwin=--toolset=darwin runtime-link=shared target-os=darwin
14+
$(package)_config_opts_darwin=runtime-link=shared target-os=darwin
1515
$(package)_config_opts_mingw32=binary-format=pe target-os=windows threadapi=win32 runtime-link=static
1616
$(package)_config_opts_x86_64_mingw32=address-model=64
1717
$(package)_config_opts_i686_mingw32=address-model=32
1818
$(package)_config_opts_i686_linux=address-model=32 architecture=x86
1919
$(package)_toolset_$(host_os)=gcc
2020
$(package)_archiver_$(host_os)=$($(package)_ar)
21-
$(package)_toolset_darwin=darwin
22-
$(package)_archiver_darwin=$($(package)_libtool)
2321
$(package)_config_libraries_$(host_os)="chrono,filesystem,program_options,system,thread,test,date_time,regex,serialization"
2422
$(package)_config_libraries_mingw32="chrono,filesystem,program_options,system,thread,test,date_time,regex,serialization,locale"
2523
$(package)_cxxflags=-std=c++17

contrib/depends/packages/native_cctools.mk

Lines changed: 0 additions & 34 deletions
This file was deleted.

contrib/depends/packages/native_libtapi.mk

Lines changed: 0 additions & 19 deletions
This file was deleted.

contrib/depends/packages/packages.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ freebsd_native_packages := freebsd_base
2222
freebsd_packages :=
2323

2424
ifneq ($(build_os),darwin)
25-
darwin_native_packages := darwin_sdk native_cctools native_libtapi
25+
darwin_native_packages := darwin_sdk
2626
endif
2727
darwin_packages :=
2828

contrib/depends/toolchain.cmake.in

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,24 +88,26 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
8888
split_program("@CC@" CC_DARWIN CC_DARWIN_ARGS)
8989
SET(CMAKE_C_COMPILER "${CC_DARWIN}" "${CC_DARWIN_ARGS}")
9090
SET(CMAKE_C_COMPILER_TARGET ${CLANG_TARGET})
91-
SET(CMAKE_C_FLAGS_INIT -B${_CMAKE_TOOLCHAIN_PREFIX})
9291
split_program("@CXX@" CXX_DARWIN CXX_DARWIN_ARGS)
9392
SET(CMAKE_CXX_COMPILER "${CXX_DARWIN}" "${CXX_DARWIN_ARGS}")
93+
SET(CMAKE_C_FLAGS "@CFLAGS@")
9494
SET(CMAKE_CXX_COMPILER_TARGET ${CLANG_TARGET})
95-
SET(CMAKE_CXX_FLAGS_INIT -B${_CMAKE_TOOLCHAIN_PREFIX})
95+
SET(CMAKE_CXX_FLAGS "@CXXFLAGS@")
96+
SET(CMAKE_EXE_LINKER_FLAGS "@LDFLAGS@")
97+
SET(CMAKE_MODULE_LINKER_FLAGS "@LDFLAGS@")
98+
SET(CMAKE_SHARED_LINKER_FLAGS "@LDFLAGS@")
99+
SET(CMAKE_INSTALL_NAME_TOOL llvm-install-name-tool)
96100
SET(CMAKE_ASM_COMPILER clang)
97-
SET(CMAKE_ASM-ATT_COMPILER as)
101+
SET(CMAKE_ASM-ATT_COMPILER llvm-as)
98102
SET(CMAKE_ASM_COMPILER_TARGET ${CLANG_TARGET})
99103
SET(CMAKE_ASM-ATT_COMPILER_TARGET ${CLANG_TARGET})
100104
SET(APPLE True)
101105
SET(BUILD_64 ON)
102106
SET(BREW OFF)
103107
SET(PORT OFF)
104108
SET(CMAKE_OSX_SYSROOT "@prefix@/native/SDK/")
105-
SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.15")
109+
SET(CMAKE_OSX_DEPLOYMENT_TARGET "11.0")
106110
SET(CMAKE_CXX_STANDARD 17)
107-
SET(LLVM_ENABLE_PIC OFF)
108-
SET(LLVM_ENABLE_PIE OFF)
109111
elseif(TARGET_OS STREQUAL "android")
110112
SET(ANDROID TRUE)
111113

contrib/guix/libexec/build.sh

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,6 @@ done
165165

166166
# Disable Guix ld auto-rpath behavior
167167
case "$HOST" in
168-
*darwin*)
169-
# The auto-rpath behavior is necessary for darwin builds as some native
170-
# tools built by depends refer to and depend on Guix-built native
171-
# libraries
172-
#
173-
# After the native packages in depends are built, the ld wrapper should
174-
# no longer affect our build, as clang would instead reach for
175-
# x86_64-apple-darwin-ld from cctools
176-
;;
177168
*android*)
178169
;;
179170
*) export GUIX_LD_WRAPPER_DISABLE_RPATH=yes ;;
@@ -219,16 +210,6 @@ export GLIBC_DYNAMIC_LINKER=${glibc_dynamic_linker}
219210
# Environment variables for determinism
220211
export TAR_OPTIONS="--owner=0 --group=0 --numeric-owner --mtime='@${SOURCE_DATE_EPOCH}' --sort=name"
221212
export TZ="UTC"
222-
case "$HOST" in
223-
*darwin*)
224-
# cctools AR, unlike GNU binutils AR, does not have a deterministic mode
225-
# or a configure flag to enable determinism by default, it only
226-
# understands if this env-var is set or not. See:
227-
#
228-
# https://github.com/tpoechtrager/cctools-port/blob/55562e4073dea0fbfd0b20e0bf69ffe6390c7f97/cctools/ar/archive.c#L334
229-
export ZERO_AR_DATE=yes
230-
;;
231-
esac
232213

233214
####################
234215
# Depends Building #

contrib/guix/manifest.scm

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ chain for " target " development."))
295295
(list
296296
libtool
297297
python-minimal ; required to build libtapi in depends
298-
gcc-toolchain-10
299-
clang-toolchain-11
300-
binutils))
298+
gcc-toolchain-12
299+
clang-toolchain-18
300+
lld-18
301+
(make-lld-wrapper lld-18 #:lld-as-ld? #t)))
301302
(else '())))))

0 commit comments

Comments
 (0)