dev-lang/swift: add swift-5.10.1-r4, swift-6.0.3-r1

Swift is now set up to properly respect CFLAGS, CXXFLAGS, and LDFLAGS
from the environment by not overriding those values in the build system.
Swift 6 now also picks up on `SWIFT_EXTRA_BUILD_FLAGS` from the
environment and passes those to its build system as well.

Closes: https://bugs.gentoo.org/939764
Closes: https://bugs.gentoo.org/939766
Signed-off-by: Itai Ferber <itai@itaiferber.net>
This commit is contained in:
Itai Ferber
2025-03-26 11:21:03 -04:00
parent 06e0d10544
commit 6c6dc8ce59
17 changed files with 770 additions and 0 deletions

View File

@@ -0,0 +1 @@
../swift-5.10.1-r3/backport-swift-75662.patch

View File

@@ -0,0 +1 @@
../swift-5.10.1-r3/backtracing-noexecstack.patch

View File

@@ -0,0 +1 @@
../swift-5.10.1-r3/clang-indexstore-exports.patch

View File

@@ -0,0 +1 @@
../swift-5.10.1-r3/disable-libdispatch-werror.patch

View File

@@ -0,0 +1 @@
../swift-5.10.1-r3/link-ncurses-tinfo.patch

View File

@@ -0,0 +1 @@
../swift-5.10.1-r3/link-with-lld.patch

View File

@@ -0,0 +1 @@
../swift-5.10.1-r3/lldb-cmake-minimum-version.patch

View File

@@ -0,0 +1,64 @@
# CMake automatically reads `CFLAGS`, `CXXFLAGS`, `LDFLAGS`, etc. from the
# environment and uses them to populate its default flag variables -- but the
# Swift build system blows away `CMAKE_C{XX}_FLAGS` without picking up the
# environment. These need to be picked up again to not be ignored.
--- a/swift/utils/build-script-impl
+++ b/swift/utils/build-script-impl
@@ -1820,10 +1820,10 @@ for host in "${ALL_HOSTS[@]}"; do
cmake_options=(
"${cmake_options[@]}"
- -DCMAKE_C_FLAGS="$(swift_c_flags ${host})"
- -DCMAKE_CXX_FLAGS="$(swift_c_flags ${host})"
- -DCMAKE_C_FLAGS_RELWITHDEBINFO="-O2 -DNDEBUG"
- -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2 -DNDEBUG"
+ -DCMAKE_C_FLAGS="${CFLAGS} $(swift_c_flags ${host})"
+ -DCMAKE_CXX_FLAGS="${CXXFLAGS} $(swift_c_flags ${host})"
+ -DCMAKE_C_FLAGS_RELWITHDEBINFO="${CFLAGS} -O2 -DNDEBUG"
+ -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="${CXXFLAGS} -O2 -DNDEBUG"
-DCMAKE_BUILD_TYPE:STRING="${SWIFT_BUILD_TYPE}"
-DLLVM_ENABLE_ASSERTIONS:BOOL=$(true_false "${SWIFT_ENABLE_ASSERTIONS}")
-DBOOTSTRAPPING_MODE:STRING=$(to_bootstrapping_mode "${BOOTSTRAPPING}")
@@ -2215,8 +2215,8 @@ for host in "${ALL_HOSTS[@]}"; do
cmake_options=(
"${cmake_options[@]}"
-C${LLDB_SOURCE_DIR}/cmake/caches/${cmake_cache}
- -DCMAKE_C_FLAGS="$(llvm_c_flags ${host})"
- -DCMAKE_CXX_FLAGS="$(llvm_c_flags ${host})"
+ -DCMAKE_C_FLAGS="${CFLAGS} $(llvm_c_flags ${host})"
+ -DCMAKE_CXX_FLAGS="${CXXFLAGS} $(llvm_c_flags ${host})"
-DCMAKE_BUILD_TYPE:STRING="${LLDB_BUILD_TYPE}"
-DLLDB_SWIFTC:PATH=${SWIFTC_BIN}
-DLLDB_SWIFT_LIBS:PATH="$(build_directory ${LOCAL_HOST} swift)/lib/swift"
--- a/swift/utils/swift_build_support/swift_build_support/products/llvm.py
+++ b/swift/utils/swift_build_support/swift_build_support/products/llvm.py
@@ -261,10 +261,10 @@ class LLVM(cmake_product.CMakeProduct):
# llvm/tools, e.g. to build LLDB.
llvm_c_flags = ' '.join(self.llvm_c_flags(platform, arch))
- llvm_cmake_options.define('CMAKE_C_FLAGS', llvm_c_flags)
- llvm_cmake_options.define('CMAKE_CXX_FLAGS', llvm_c_flags)
- llvm_cmake_options.define('CMAKE_C_FLAGS_RELWITHDEBINFO', '-O2 -DNDEBUG')
- llvm_cmake_options.define('CMAKE_CXX_FLAGS_RELWITHDEBINFO', '-O2 -DNDEBUG')
+ llvm_cmake_options.define('CMAKE_C_FLAGS', ' '.join([os.environ.get('CFLAGS', ''), llvm_c_flags]))
+ llvm_cmake_options.define('CMAKE_CXX_FLAGS', ' '.join([os.environ.get('CXXFLAGS', ''), llvm_c_flags]))
+ llvm_cmake_options.define('CMAKE_C_FLAGS_RELWITHDEBINFO', ' '.join([os.environ.get('CFLAGS', ''), '-O2 -DNDEBUG']))
+ llvm_cmake_options.define('CMAKE_CXX_FLAGS_RELWITHDEBINFO', ' '.join([os.environ.get('CXXFLAGS', ''), '-O2 -DNDEBUG']))
llvm_cmake_options.define('CMAKE_BUILD_TYPE:STRING',
self.args.llvm_build_variant)
llvm_cmake_options.define('LLVM_TOOL_SWIFT_BUILD:BOOL', 'FALSE')
--- a/swift/utils/swift_build_support/swift_build_support/products/product.py
+++ b/swift/utils/swift_build_support/swift_build_support/products/product.py
@@ -440,8 +440,8 @@ class Product(object):
(platform, arch) = host_target.split('-')
common_c_flags = ' '.join(self.common_cross_c_flags(platform, arch))
- self.cmake_options.define('CMAKE_C_FLAGS', common_c_flags)
- self.cmake_options.define('CMAKE_CXX_FLAGS', common_c_flags)
+ self.cmake_options.define('CMAKE_C_FLAGS', ' '.join([os.environ.get('CFLAGS', ''), common_c_flags]))
+ self.cmake_options.define('CMAKE_CXX_FLAGS', ' '.join([os.environ.get('CXXFLAGS', ''), common_c_flags]))
toolchain_file = None
if self.is_darwin_host(host_target):

View File

@@ -0,0 +1 @@
../swift-6.0.3/backtracing-noexecstack.patch

View File

@@ -0,0 +1 @@
../swift-6.0.3/disable-libdispatch-werror.patch

View File

@@ -0,0 +1,43 @@
# Individual preset options:
#
# 1. mixin-preset: building for Linux, without compiler assertions, and with
# most tests disabled
# 2. build-ninja=0, skip-build-curl, skip-build-zlib: we'd prefer to pick these
# up from the system
# 3. extra-cmake-options:
# * -DLLVM_USE_LINKER, -DCLANG_DEFAULT_LINKER: build LLVM, clang, Swift, et.
# al. to link using lld, and ensure Clang uses it as its default
# * -DBUILD_TESTING, -DSWIFT_INCLUDE_TESTS, -DSWIFT_INCLUDE_TEST_BINARIES:
# the `no_test` preset disables building most, but not all tests; we don't
# need to build any of them
# * -DCOMPILER_RT_BUILD_ORC: the `compiler-rt` library defaults to building
# the ORC LLVM JIT library, which we don't require; we disable it because
# it builds with executable stacks, which trip up warnings on installation
# * -DPython3_FIND_UNVERSIONED_NAMES: LLDB ships with Python bindings, and
# uses CMake to search for Python. By default, CMake tries to find the
# latest version installed on disk (currently, `python3.13`, then
# `python3.12`, then...). This might not be the version of Python specified
# by `PYTHON_SINGLE_TARGET`, which we want to respect. We use
# `python_setup` to place `${EPYTHON}` at the front of `PATH` as the
# unversioned `python3`, so we want CMake to discover and use this binary
# first before falling back to its search
# 5. llvm-targets-to-build: we don't currently support architectures other than
# amd64, so there's no point in building LLVM for multiple architectures; if
# this changes (or we start supporting cross-compilation), we'll need to
# build for more than just the host
[preset: gentoo]
mixin-preset=buildbot_linux,no_assertions,no_test
build-ninja=0
extra-cmake-options=
-DLLVM_USE_LINKER:STRING=lld
-DCLANG_DEFAULT_LINKER:STRING=lld
-DBUILD_TESTING:BOOL=NO
-DSWIFT_INCLUDE_TESTS:BOOL=NO
-DSWIFT_INCLUDE_TEST_BINARIES:BOOL=NO
-DCOMPILER_RT_BUILD_ORC:BOOL=NO
-DPython3_FIND_UNVERSIONED_NAMES:STRING=FIRST
llvm-targets-to-build=host
skip-build-curl
skip-build-zlib

View File

@@ -0,0 +1,19 @@
# Prior to C23, the C standard restricts enum values to the range of `int`;
# relaxing this is a GNU extension that Clang follows. On LLVM-profile systems,
# though, this appears to not be enabled by default, causing Clang to complain
# that `1 << 63` is not a compile-time expression (since it overflows an `int`
# and can't be computed at compile-time). This can be suppressed by causing the
# enum to be interpreted explicitly as containing `unsigned long long` values
# instead.
--- a/indexstore-db/include/CIndexStoreDB/CIndexStoreDB.h
+++ b/indexstore-db/include/CIndexStoreDB/CIndexStoreDB.h
@@ -82,7 +82,7 @@ typedef enum {
INDEXSTOREDB_SYMBOL_ROLE_REL_IBTYPEOF = 1 << 17,
INDEXSTOREDB_SYMBOL_ROLE_REL_SPECIALIZATIONOF = 1 << 18,
- INDEXSTOREDB_SYMBOL_ROLE_CANONICAL = 1 << 63,
+ INDEXSTOREDB_SYMBOL_ROLE_CANONICAL = 1ULL << 63,
} indexstoredb_symbol_role_t;
typedef enum {

View File

@@ -0,0 +1 @@
../swift-6.0.3/link-ncurses-tinfo.patch

View File

@@ -0,0 +1 @@
../swift-6.0.3/link-with-lld.patch

View File

@@ -0,0 +1 @@
../swift-5.10.1-r4/respect-c-cxx-flags.patch