Skip to content

Commit 4d4d8cc

Browse files
committed
guix: use llvm 18 toolchain for darwin targets
1 parent c572e1a commit 4d4d8cc

File tree

11 files changed

+66
-99
lines changed

11 files changed

+66
-99
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"
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"
67+
packages: "clang-18 lld-18"
6868
- name: "x86_64 Freebsd"
6969
host: "x86_64-unknown-freebsd"
7070
rust_host: "x86_64-unknown-freebsd"
@@ -118,6 +118,10 @@ jobs:
118118
run: |
119119
update-alternatives --set ${{ matrix.toolchain.host }}-g++ $(which ${{ matrix.toolchain.host }}-g++-posix)
120120
update-alternatives --set ${{ matrix.toolchain.host }}-gcc $(which ${{ matrix.toolchain.host }}-gcc-posix)
121+
- name: prepare apple-darwin
122+
if: ${{ matrix.toolchain.host == 'x86_64-apple-darwin' || matrix.toolchain.host == 'arm64-apple-darwin' }}
123+
run: |
124+
echo "/usr/lib/llvm-18/bin/" >> $GITHUB_PATH
121125
- uses: ./.github/actions/set-make-job-count
122126
- name: build
123127
run: |

contrib/depends/hosts/darwin.mk

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
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+
llvm_config_prog=llvm-config
14+
15+
llvm_lib_dir=$(shell $(llvm_config_prog) --libdir)
16+
17+
darwin_AR=llvm-ar
18+
darwin_DSYMUTIL=dsymutil
19+
darwin_NM=llvm-nm
20+
darwin_OBJDUMP=llvm-objdump
21+
darwin_RANLIB=llvm-ranlib
22+
darwin_STRIP=llvm-strip
1323

1424
# Flag explanations:
1525
#
@@ -37,23 +47,23 @@ clangxx_prog=$(shell $(SHELL) $(.SHELLFLAGS) "command -v clang++")
3747
darwin_CC=env -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH \
3848
-u OBJC_INCLUDE_PATH -u OBJCPLUS_INCLUDE_PATH -u CPATH \
3949
-u LIBRARY_PATH \
40-
$(clang_prog) --target=$(host) -mmacosx-version-min=$(OSX_MIN_VERSION) \
41-
-B$(build_prefix)/bin -mlinker-version=$(LD64_VERSION) \
42-
-isysroot$(OSX_SDK) \
50+
$(clang_prog) --target=$(host) \
51+
-B$(build_prefix)/bin \
4352
-isysroot$(OSX_SDK) -nostdlibinc \
4453
-iwithsysroot/usr/include -iframeworkwithsysroot/System/Library/Frameworks
4554

4655
darwin_CXX=env -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH \
4756
-u OBJC_INCLUDE_PATH -u OBJCPLUS_INCLUDE_PATH -u CPATH \
4857
-u LIBRARY_PATH \
49-
$(clangxx_prog) --target=$(host) -mmacosx-version-min=$(OSX_MIN_VERSION) \
50-
-B$(build_prefix)/bin -mlinker-version=$(LD64_VERSION) \
58+
$(clangxx_prog) --target=$(host) \
59+
-B$(build_prefix)/bin \
5160
-isysroot$(OSX_SDK) -nostdlibinc \
5261
-iwithsysroot/usr/include/c++/v1 \
5362
-iwithsysroot/usr/include -iframeworkwithsysroot/System/Library/Frameworks
5463

55-
darwin_CFLAGS=-pipe
56-
darwin_CXXFLAGS=$(darwin_CFLAGS)
64+
darwin_CFLAGS=-pipe -mmacosx-version-min=$(OSX_MIN_VERSION) -mlinker-version=$(LD64_VERSION)
65+
darwin_CXXFLAGS=-pipe -mmacosx-version-min=$(OSX_MIN_VERSION) -mlinker-version=$(LD64_VERSION)
66+
darwin_LDFLAGS=-Wl,-platform_version,macos,$(OSX_MIN_VERSION),$(OSX_SDK_VERSION) -Wl,-no_adhoc_codesign -fuse-ld=lld
5767
darwin_ARFLAGS=cr
5868

5969
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/libusb.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ $(package)_version=1.0.27
33
$(package)_download_path=https://github.com/libusb/libusb/releases/download/v$($(package)_version)
44
$(package)_file_name=$(package)-$($(package)_version).tar.bz2
55
$(package)_sha256_hash=ffaa41d741a8a3bee244ac8e54a72ea05bf2879663c098c82fc5757853441575
6+
$(package)_patches=fix-c11-check.patch
67

78
define $(package)_preprocess_cmds
9+
patch -p1 < $($(package)_patch_dir)/fix-c11-check.patch && \
810
cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub .
911
endef
1012

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
diff --git a/configure b/configure
2+
index 1f86520..f344241 100755
3+
--- a/configure
4+
+++ b/configure
5+
@@ -17235,7 +17235,7 @@ EXTRA_CPPFLAGS=
6+
EXTRA_CFLAGS=
7+
8+
saved_CFLAGS="${CFLAGS}"
9+
-CFLAGS="-std=gnu11"
10+
+CFLAGS="${saved_CFLAGS} -std=gnu11"
11+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC supports -std=gnu11" >&5
12+
printf %s "checking if $CC supports -std=gnu11... " >&6; }
13+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14+
@@ -17261,7 +17261,7 @@ printf "%s\n" "no" >&6; }
15+
fi
16+
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
17+
if test "x$c_dialect" != xgnu; then
18+
- CFLAGS="-std=c11"
19+
+ CFLAGS="${saved_CFLAGS} -std=c11"
20+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC supports -std=c11" >&5
21+
printf %s "checking if $CC supports -std=c11... " >&6; }
22+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext

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 ;;
@@ -220,16 +211,6 @@ export GLIBC_DYNAMIC_LINKER=${glibc_dynamic_linker}
220211
# Environment variables for determinism
221212
export TAR_OPTIONS="--owner=0 --group=0 --numeric-owner --mtime='@${SOURCE_DATE_EPOCH}' --sort=name"
222213
export TZ="UTC"
223-
case "$HOST" in
224-
*darwin*)
225-
# cctools AR, unlike GNU binutils AR, does not have a deterministic mode
226-
# or a configure flag to enable determinism by default, it only
227-
# understands if this env-var is set or not. See:
228-
#
229-
# https://github.com/tpoechtrager/cctools-port/blob/55562e4073dea0fbfd0b20e0bf69ffe6390c7f97/cctools/ar/archive.c#L334
230-
export ZERO_AR_DATE=yes
231-
;;
232-
esac
233214

234215
####################
235216
# Depends Building #

0 commit comments

Comments
 (0)