Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

guix: use llvm 17 toolchain for darwin targets #9455

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions contrib/depends/hosts/darwin.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,24 @@ OSX_MIN_VERSION=10.15
OSX_SDK_VERSION=11.0
XCODE_VERSION=12.2
XCODE_BUILD_ID=12B45b
LD64_VERSION=609
LD64_VERSION=711

OSX_SDK=$(host_prefix)/native/SDK

darwin_native_toolchain=darwin_sdk native_cctools
darwin_native_toolchain=darwin_sdk

clang_prog=$(shell $(SHELL) $(.SHELLFLAGS) "command -v clang")
clangxx_prog=$(shell $(SHELL) $(.SHELLFLAGS) "command -v clang++")
clang_prog=clang
clangxx_prog=clang++
llvm_config_prog=llvm-config

llvm_lib_dir=$(shell $(llvm_config_prog) --libdir)

darwin_AR=llvm-ar
darwin_DSYMUTIL=dsymutil
darwin_NM=llvm-nm
darwin_OBJDUMP=llvm-objdump
darwin_RANLIB=llvm-ranlib
darwin_STRIP=llvm-strip

# Flag explanations:
#
Expand Down Expand Up @@ -37,23 +47,23 @@ clangxx_prog=$(shell $(SHELL) $(.SHELLFLAGS) "command -v clang++")
darwin_CC=env -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH \
-u OBJC_INCLUDE_PATH -u OBJCPLUS_INCLUDE_PATH -u CPATH \
-u LIBRARY_PATH \
$(clang_prog) --target=$(host) -mmacosx-version-min=$(OSX_MIN_VERSION) \
-B$(build_prefix)/bin -mlinker-version=$(LD64_VERSION) \
-isysroot$(OSX_SDK) \
$(clang_prog) --target=$(host) \
-B$(build_prefix)/bin \
-isysroot$(OSX_SDK) -nostdlibinc \
-iwithsysroot/usr/include -iframeworkwithsysroot/System/Library/Frameworks

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

darwin_CFLAGS=-pipe
darwin_CXXFLAGS=$(darwin_CFLAGS)
darwin_CFLAGS=-pipe -mmacosx-version-min=$(OSX_MIN_VERSION) -mlinker-version=$(LD64_VERSION)
darwin_CXXFLAGS=-pipe -mmacosx-version-min=$(OSX_MIN_VERSION) -mlinker-version=$(LD64_VERSION)
darwin_LDFLAGS=-Wl,-platform_version,macos,$(OSX_MIN_VERSION),$(OSX_SDK_VERSION) -Wl,-no_adhoc_codesign -fuse-ld=lld
darwin_ARFLAGS=cr

darwin_release_CFLAGS=-O2
Expand Down
4 changes: 1 addition & 3 deletions contrib/depends/packages/boost.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ $(package)_config_opts+=--layout=system --user-config=user-config.jam
$(package)_config_opts+=threading=multi link=static -sNO_BZIP2=1 -sNO_ZLIB=1
$(package)_config_opts_linux=threadapi=pthread runtime-link=shared
$(package)_config_opts_android=threadapi=pthread runtime-link=static target-os=android
$(package)_config_opts_darwin=--toolset=darwin runtime-link=shared target-os=darwin
$(package)_config_opts_darwin=runtime-link=shared target-os=darwin
$(package)_config_opts_mingw32=binary-format=pe target-os=windows threadapi=win32 runtime-link=static
$(package)_config_opts_x86_64_mingw32=address-model=64
$(package)_config_opts_i686_mingw32=address-model=32
$(package)_config_opts_i686_linux=address-model=32 architecture=x86
$(package)_toolset_$(host_os)=gcc
$(package)_archiver_$(host_os)=$($(package)_ar)
$(package)_toolset_darwin=darwin
$(package)_archiver_darwin=$($(package)_libtool)
$(package)_config_libraries_$(host_os)="chrono,filesystem,program_options,system,thread,test,date_time,regex,serialization"
$(package)_config_libraries_mingw32="chrono,filesystem,program_options,system,thread,test,date_time,regex,serialization,locale"
$(package)_cxxflags=-std=c++17
Expand Down
2 changes: 2 additions & 0 deletions contrib/depends/packages/libusb.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ $(package)_version=1.0.27
$(package)_download_path=https://github.com/libusb/libusb/releases/download/v$($(package)_version)
$(package)_file_name=$(package)-$($(package)_version).tar.bz2
$(package)_sha256_hash=ffaa41d741a8a3bee244ac8e54a72ea05bf2879663c098c82fc5757853441575
$(package)_patches=fix-c11-check.patch

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

Expand Down
37 changes: 0 additions & 37 deletions contrib/depends/packages/native_cctools.mk

This file was deleted.

19 changes: 0 additions & 19 deletions contrib/depends/packages/native_libtapi.mk

This file was deleted.

2 changes: 1 addition & 1 deletion contrib/depends/packages/packages.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ freebsd_native_packages := freebsd_base
freebsd_packages :=

ifneq ($(build_os),darwin)
darwin_native_packages := darwin_sdk native_cctools native_libtapi
darwin_native_packages := darwin_sdk
endif
darwin_packages :=

Expand Down
22 changes: 22 additions & 0 deletions contrib/depends/patches/libusb/fix-c11-check.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/configure.ac b/configure.ac
index 6dc7c698..eebe10a1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -46,7 +46,7 @@ dnl note that we don't just check if the compiler accepts '-std=x11'
dnl but also that it supports the _Thread_local keyword because some compilers
dnl (e.g. gcc 4.8) accept the command line option but do not implement TLS
saved_CFLAGS="${CFLAGS}"
-CFLAGS="-std=gnu11"
+CFLAGS="${saved_CFLAGS} -std=gnu11"
AC_MSG_CHECKING([if $CC supports -std=gnu11])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_Thread_local int x;], [x = 42;])],
[AC_MSG_RESULT([yes])
@@ -55,7 +55,7 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_Thread_local int x;], [x = 42;])],
c_dialect=])
if test "x$c_dialect" != xgnu; then
dnl fallback check for -std=c11 compiler support (required)
- CFLAGS="-std=c11"
+ CFLAGS="${saved_CFLAGS} -std=c11"
AC_MSG_CHECKING([if $CC supports -std=c11])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_Thread_local int x;], [x = 42;])],
[AC_MSG_RESULT([yes])],
12 changes: 7 additions & 5 deletions contrib/depends/toolchain.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,16 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
SET(_CMAKE_TOOLCHAIN_PREFIX @prefix@/native/bin/${CONF_TRIPLE}-)
SET(CMAKE_C_COMPILER @CC@)
SET(CMAKE_C_COMPILER_TARGET ${CLANG_TARGET})
SET(CMAKE_C_FLAGS_INIT -B${_CMAKE_TOOLCHAIN_PREFIX})
SET(CMAKE_C_FLAGS "@CFLAGS@")
SET(CMAKE_CXX_COMPILER @CXX@ -stdlib=libc++)
SET(CMAKE_CXX_COMPILER_TARGET ${CLANG_TARGET})
SET(CMAKE_CXX_FLAGS_INIT -B${_CMAKE_TOOLCHAIN_PREFIX})
SET(CMAKE_CXX_FLAGS "@CXXFLAGS@")
SET(CMAKE_EXE_LINKER_FLAGS "@LDFLAGS@")
SET(CMAKE_MODULE_LINKER_FLAGS "@LDFLAGS@")
SET(CMAKE_SHARED_LINKER_FLAGS "@LDFLAGS@")
SET(CMAKE_INSTALL_NAME_TOOL llvm-install-name-tool)
SET(CMAKE_ASM_COMPILER clang)
SET(CMAKE_ASM-ATT_COMPILER as)
SET(CMAKE_ASM-ATT_COMPILER llvm-as)
SET(CMAKE_ASM_COMPILER_TARGET ${CLANG_TARGET})
SET(CMAKE_ASM-ATT_COMPILER_TARGET ${CLANG_TARGET})
SET(APPLE True)
Expand All @@ -82,8 +86,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
SET(CMAKE_OSX_SYSROOT "@prefix@/native/SDK/")
SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.15")
SET(CMAKE_CXX_STANDARD 17)
SET(LLVM_ENABLE_PIC OFF)
SET(LLVM_ENABLE_PIE OFF)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
SET(ANDROID TRUE)
if(ARCHITECTURE STREQUAL "arm")
Expand Down
19 changes: 0 additions & 19 deletions contrib/guix/libexec/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,6 @@ done

# Disable Guix ld auto-rpath behavior
case "$HOST" in
*darwin*)
# The auto-rpath behavior is necessary for darwin builds as some native
# tools built by depends refer to and depend on Guix-built native
# libraries
#
# After the native packages in depends are built, the ld wrapper should
# no longer affect our build, as clang would instead reach for
# x86_64-apple-darwin-ld from cctools
;;
*android*)
;;
*) export GUIX_LD_WRAPPER_DISABLE_RPATH=yes ;;
Expand Down Expand Up @@ -220,16 +211,6 @@ export GLIBC_DYNAMIC_LINKER=${glibc_dynamic_linker}
# Environment variables for determinism
export TAR_OPTIONS="--owner=0 --group=0 --numeric-owner --mtime='@${SOURCE_DATE_EPOCH}' --sort=name"
export TZ="UTC"
case "$HOST" in
*darwin*)
# cctools AR, unlike GNU binutils AR, does not have a deterministic mode
# or a configure flag to enable determinism by default, it only
# understands if this env-var is set or not. See:
#
# https://github.com/tpoechtrager/cctools-port/blob/55562e4073dea0fbfd0b20e0bf69ffe6390c7f97/cctools/ar/archive.c#L334
export ZERO_AR_DATE=yes
;;
esac

####################
# Depends Building #
Expand Down
5 changes: 3 additions & 2 deletions contrib/guix/manifest.scm
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ chain for " target " development."))
((string-contains target "darwin")
(list
gcc-toolchain-10
clang-toolchain-11
binutils))
clang-toolchain-17
lld-17
(make-lld-wrapper lld-17 #:lld-as-ld? #t)))
(else '())))))
22 changes: 22 additions & 0 deletions contrib/guix/patches/fix-c11-check.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/configure.ac b/configure.ac
index 6dc7c698..eebe10a1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -46,7 +46,7 @@ dnl note that we don't just check if the compiler accepts '-std=x11'
dnl but also that it supports the _Thread_local keyword because some compilers
dnl (e.g. gcc 4.8) accept the command line option but do not implement TLS
saved_CFLAGS="${CFLAGS}"
-CFLAGS="-std=gnu11"
+CFLAGS="${saved_CFLAGS} -std=gnu11"
AC_MSG_CHECKING([if $CC supports -std=gnu11])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_Thread_local int x;], [x = 42;])],
[AC_MSG_RESULT([yes])
@@ -55,7 +55,7 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_Thread_local int x;], [x = 42;])],
c_dialect=])
if test "x$c_dialect" != xgnu; then
dnl fallback check for -std=c11 compiler support (required)
- CFLAGS="-std=c11"
+ CFLAGS="${saved_CFLAGS} -std=c11"
AC_MSG_CHECKING([if $CC supports -std=c11])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_Thread_local int x;], [x = 42;])],
[AC_MSG_RESULT([yes])],
Loading