mirror of
https://github.com/gentoo-mirror/guru.git
synced 2026-07-22 13:33:32 -04:00
dev-lang/swift: add 6.0.1
Signed-off-by: Itai Ferber <itai@itaiferber.net>
This commit is contained in:
74
dev-lang/swift/files/swift-6.0.1-link-with-lld.patch
Normal file
74
dev-lang/swift/files/swift-6.0.1-link-with-lld.patch
Normal file
@@ -0,0 +1,74 @@
|
||||
# Swift defaults to building with `gold` on Linux because `bfd` can't correctly
|
||||
# handle Swift symbols; Gentoo no longer supports `gold`, so we have to make
|
||||
# sure that we build with `lld`.
|
||||
|
||||
--- a/swift/lib/Driver/UnixToolChains.cpp
|
||||
+++ b/swift/lib/Driver/UnixToolChains.cpp
|
||||
@@ -109,36 +109,7 @@ ToolChain::InvocationInfo toolchains::GenericUnix::constructInvocation(
|
||||
return II;
|
||||
}
|
||||
|
||||
-std::string toolchains::GenericUnix::getDefaultLinker() const {
|
||||
- if (getTriple().isAndroid()
|
||||
- || (getTriple().isMusl()
|
||||
- && getTriple().getVendor() == llvm::Triple::Swift))
|
||||
- return "lld";
|
||||
-
|
||||
- switch (getTriple().getArch()) {
|
||||
- case llvm::Triple::arm:
|
||||
- case llvm::Triple::aarch64:
|
||||
- case llvm::Triple::aarch64_32:
|
||||
- case llvm::Triple::armeb:
|
||||
- case llvm::Triple::thumb:
|
||||
- case llvm::Triple::thumbeb:
|
||||
- // BFD linker has issues wrt relocation of the protocol conformance
|
||||
- // section on these targets, it also generates COPY relocations for
|
||||
- // final executables, as such, unless specified, we default to gold
|
||||
- // linker.
|
||||
- return "gold";
|
||||
- case llvm::Triple::x86:
|
||||
- case llvm::Triple::x86_64:
|
||||
- case llvm::Triple::ppc64:
|
||||
- case llvm::Triple::ppc64le:
|
||||
- case llvm::Triple::systemz:
|
||||
- // BFD linker has issues wrt relocations against protected symbols.
|
||||
- return "gold";
|
||||
- default:
|
||||
- // Otherwise, use the default BFD linker.
|
||||
- return "";
|
||||
- }
|
||||
-}
|
||||
+std::string toolchains::GenericUnix::getDefaultLinker() const { return "lld"; }
|
||||
|
||||
bool toolchains::GenericUnix::addRuntimeRPath(const llvm::Triple &T,
|
||||
const llvm::opt::ArgList &Args) const {
|
||||
--- a/swift-driver/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift
|
||||
+++ b/swift-driver/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift
|
||||
@@ -17,26 +17,7 @@ import struct TSCBasic.AbsolutePath
|
||||
|
||||
extension GenericUnixToolchain {
|
||||
private func defaultLinker(for targetTriple: Triple) -> String? {
|
||||
- if targetTriple.os == .openbsd || targetTriple.os == .freeBSD ||
|
||||
- targetTriple.environment == .android ||
|
||||
- targetTriple.isFullyStaticLinux {
|
||||
- return "lld"
|
||||
- }
|
||||
-
|
||||
- switch targetTriple.arch {
|
||||
- case .arm, .aarch64, .armeb, .thumb, .thumbeb:
|
||||
- // BFD linker has issues wrt relocation of the protocol conformance
|
||||
- // section on these targets, it also generates COPY relocations for
|
||||
- // final executables, as such, unless specified, we default to gold
|
||||
- // linker.
|
||||
- return "gold"
|
||||
- case .x86, .x86_64, .ppc64, .ppc64le, .systemz:
|
||||
- // BFD linker has issues wrt relocations against protected symbols.
|
||||
- return "gold"
|
||||
- default:
|
||||
- // Otherwise, use the default BFD linker.
|
||||
- return ""
|
||||
- }
|
||||
+ "lld"
|
||||
}
|
||||
|
||||
private func majorArchitectureName(for triple: Triple) -> String {
|
||||
@@ -0,0 +1,15 @@
|
||||
# The Swift backtracer needs to get CPU context information when producing
|
||||
# backtraces, which is necessarily written in assembly. Because it tries to be
|
||||
# portable, it doesn't include a note indicating that the assembled binary
|
||||
# doesn't require an executable stack; we need to include one explicitly to turn
|
||||
# it off.
|
||||
|
||||
--- a/swift/stdlib/public/Backtracing/get-cpu-context.S
|
||||
+++ b/swift/stdlib/public/Backtracing/get-cpu-context.S
|
||||
@@ -140,3 +140,6 @@ FN(_swift_get_cpu_context):
|
||||
bx lr
|
||||
#endif
|
||||
|
||||
+#if defined(__linux__) && defined(__ELF__)
|
||||
+.section .note.GNU-stack,"",%progbits
|
||||
+#endif
|
||||
@@ -0,0 +1,51 @@
|
||||
# Individual preset options:
|
||||
#
|
||||
# 1. mixin-preset: building for Linux, without compiler assertions, and with
|
||||
# most tests disabled
|
||||
# 2. build-ninja=0, libicu=0, skip-build-curl, skip-build-zlib: we'd prefer to
|
||||
# pick these up from the system
|
||||
# 3. build-swift-libexec=0: don't build binaries normally installed in
|
||||
# `/usr/local/libexec` because we're not allowed to install there ourselves
|
||||
# 4. extra-cmake-options:
|
||||
# * -DSWIFT_USE_LINKER=lld: let Swift know we'll be building it with `lld`
|
||||
# * -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
|
||||
|
||||
--- a/swift/utils/build-presets.ini
|
||||
+++ b/swift/utils/build-presets.ini
|
||||
@@ -3040,3 +3040,19 @@ skip-test-cmark
|
||||
skip-test-swift
|
||||
skip-build-benchmarks
|
||||
skip-test-foundation
|
||||
+
|
||||
+[preset: gentoo]
|
||||
+mixin-preset=buildbot_linux,no_assertions,no_test
|
||||
+build-ninja=0
|
||||
+build-swift-libexec=0
|
||||
+extra-cmake-options=
|
||||
+ -DLLVM_USE_LINKER=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=FIRST
|
||||
+libicu=0
|
||||
+llvm-targets-to-build=host
|
||||
+skip-build-curl
|
||||
+skip-build-zlib
|
||||
@@ -0,0 +1,188 @@
|
||||
# Various Swift components require linking against `curses`; Gentoo doesn't
|
||||
# `curses` as an alias for `ncurses`, so we have to link against `ncurses`
|
||||
# explicitly. `ncurses` on Gentoo also doesn't expose the `curses` terminfo
|
||||
# database interface (e.g., `set_curterm`, `del_curterm`, etc.), so we have to
|
||||
# also explicitly link against `tinfo`.
|
||||
|
||||
--- a/swift/utils/test-prefix-map/Makefile
|
||||
+++ b/swift/utils/test-prefix-map/Makefile
|
||||
@@ -11,7 +11,7 @@ CXXFLAGS = -std=c++11 \
|
||||
-I$(objroot)/tools/clang/include \
|
||||
-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS
|
||||
|
||||
-LDFLAGS = -L$(objroot)/lib -lswiftBasic -lLLVMSupport -lcurses
|
||||
+LDFLAGS = -L$(objroot)/lib -lswiftBasic -lLLVMSupport -lncurses -ltinfo
|
||||
|
||||
main: main.cpp $(srcroot)/tools/swift/include/swift/Basic/PrefixMap.h
|
||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o main main.cpp
|
||||
--- a/swift/utils/test-successor-map/Makefile
|
||||
+++ b/swift/utils/test-successor-map/Makefile
|
||||
@@ -11,7 +11,7 @@ CXXFLAGS = -std=c++11 \
|
||||
-I$(objroot)/tools/clang/include \
|
||||
-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS
|
||||
|
||||
-LDFLAGS = -L$(objroot)/Debug+Asserts/lib -lLLVMSupport -lcurses
|
||||
+LDFLAGS = -L$(objroot)/Debug+Asserts/lib -lLLVMSupport -lncurses -ltinfo
|
||||
|
||||
main: main.cpp $(srcroot)/tools/swift/include/swift/Basic/SuccessorMap.h
|
||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o main main.cpp
|
||||
--- a/llbuild/Package.swift
|
||||
+++ b/llbuild/Package.swift
|
||||
@@ -227,7 +227,8 @@ let package = Package(
|
||||
path: "lib/llvm/Support",
|
||||
linkerSettings: [
|
||||
.linkedLibrary("m", .when(platforms: [.linux])),
|
||||
- .linkedLibrary("ncurses", .when(platforms: [.linux, .macOS, .android]))]
|
||||
+ .linkedLibrary("ncurses", .when(platforms: [.linux, .macOS, .android])),
|
||||
+ .linkedLibrary("tinfo", .when(platforms: [.linux]))]
|
||||
),
|
||||
],
|
||||
cxxLanguageStandard: .cxx14
|
||||
--- a/llbuild/lib/llvm/Support/CMakeLists.txt
|
||||
+++ b/llbuild/lib/llvm/Support/CMakeLists.txt
|
||||
@@ -64,6 +64,4 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
execinfo)
|
||||
endif()
|
||||
|
||||
-if(${CMAKE_SYSTEM_NAME} MATCHES "Android|Darwin|Linux")
|
||||
- target_link_libraries(llvmSupport PRIVATE curses)
|
||||
-endif()
|
||||
+target_link_libraries(llvmSupport PRIVATE ncurses tinfo)
|
||||
--- a/llbuild/perftests/Xcode/PerfTests/CMakeLists.txt
|
||||
+++ b/llbuild/perftests/Xcode/PerfTests/CMakeLists.txt
|
||||
@@ -33,7 +33,8 @@ target_link_libraries(XcodePerfTests PRIVATE
|
||||
llbuildNinja
|
||||
llbuildBuildSystem
|
||||
llbuildCommands
|
||||
- curses
|
||||
+ ncurses
|
||||
+ tinfo
|
||||
SQLite::SQLite3
|
||||
"${MACOSX_SDK_PATH}/System/Library/Frameworks/Foundation.framework"
|
||||
"${MACOSX_PLATFORM_PATH}/Developer/Library/Frameworks/XCTest.framework"
|
||||
--- a/llbuild/products/libllbuild/CMakeLists.txt
|
||||
+++ b/llbuild/products/libllbuild/CMakeLists.txt
|
||||
@@ -28,7 +28,7 @@ endif()
|
||||
|
||||
if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
|
||||
target_link_libraries(libllbuild PRIVATE
|
||||
- curses)
|
||||
+ ncurses tinfo)
|
||||
endif()
|
||||
|
||||
target_include_directories(libllbuild
|
||||
@@ -79,7 +79,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
llbuildNinja
|
||||
llvmSupport
|
||||
SQLite::SQLite3
|
||||
- curses)
|
||||
+ ncurses tinfo)
|
||||
|
||||
# Manually set up the remaining framework structure.
|
||||
set(LLBUILD_FW_INPUTS)
|
||||
--- a/llbuild/products/llbuild/CMakeLists.txt
|
||||
+++ b/llbuild/products/llbuild/CMakeLists.txt
|
||||
@@ -16,5 +16,5 @@ endif()
|
||||
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
target_link_libraries(llbuild PRIVATE
|
||||
- curses)
|
||||
+ ncurses tinfo)
|
||||
endif()
|
||||
--- a/llbuild/products/swift-build-tool/CMakeLists.txt
|
||||
+++ b/llbuild/products/swift-build-tool/CMakeLists.txt
|
||||
@@ -10,7 +10,7 @@ target_link_libraries(swift-build-tool PRIVATE
|
||||
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
target_link_libraries(swift-build-tool PRIVATE
|
||||
- curses)
|
||||
+ ncurses tinfo)
|
||||
endif()
|
||||
|
||||
install(TARGETS swift-build-tool
|
||||
--- a/llbuild/tests/lit.site.cfg.in
|
||||
+++ b/llbuild/tests/lit.site.cfg.in
|
||||
@@ -21,7 +21,7 @@ config.sqlite_library = "@SQLite3_LIBRARY@"
|
||||
if sys.platform == 'Windows':
|
||||
config.curses_library = ''
|
||||
else:
|
||||
- config.curses_library = '-lcurses'
|
||||
+ config.curses_library = '-lncurses -ltinfo'
|
||||
config.threads_library = "@CMAKE_THREAD_LIBS_INIT@"
|
||||
if "@CMAKE_DL_LIBS@":
|
||||
config.dl_library = "-l@CMAKE_DL_LIBS@"
|
||||
--- a/llbuild/unittests/Basic/CMakeLists.txt
|
||||
+++ b/llbuild/unittests/Basic/CMakeLists.txt
|
||||
@@ -14,5 +14,5 @@ target_link_libraries(BasicTests PRIVATE
|
||||
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
target_link_libraries(BasicTests PRIVATE
|
||||
- curses)
|
||||
+ ncurses tinfo)
|
||||
endif()
|
||||
--- a/llbuild/unittests/BuildSystem/CMakeLists.txt
|
||||
+++ b/llbuild/unittests/BuildSystem/CMakeLists.txt
|
||||
@@ -16,5 +16,5 @@ target_link_libraries(BuildSystemTests PRIVATE
|
||||
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
target_link_libraries(BuildSystemTests PRIVATE
|
||||
- curses)
|
||||
+ ncurses tinfo)
|
||||
endif()
|
||||
--- a/llbuild/unittests/CAPI/CMakeLists.txt
|
||||
+++ b/llbuild/unittests/CAPI/CMakeLists.txt
|
||||
@@ -15,5 +15,5 @@ target_link_libraries(CAPITests PRIVATE
|
||||
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
target_link_libraries(CAPITests PRIVATE
|
||||
- curses)
|
||||
+ ncurses tinfo)
|
||||
endif()
|
||||
--- a/llbuild/unittests/CAS/CMakeLists.txt
|
||||
+++ b/llbuild/unittests/CAS/CMakeLists.txt
|
||||
@@ -8,6 +8,6 @@ target_link_libraries(CASTests PRIVATE
|
||||
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
target_link_libraries(CASTests PRIVATE
|
||||
- curses)
|
||||
+ ncurses tinfo)
|
||||
endif()
|
||||
|
||||
--- a/llbuild/unittests/Core/CMakeLists.txt
|
||||
+++ b/llbuild/unittests/Core/CMakeLists.txt
|
||||
@@ -15,6 +15,6 @@ target_link_libraries(CoreTests PRIVATE
|
||||
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
target_link_libraries(CoreTests PRIVATE
|
||||
- curses)
|
||||
+ ncurses tinfo)
|
||||
endif()
|
||||
|
||||
--- a/llbuild/unittests/Evo/CMakeLists.txt
|
||||
+++ b/llbuild/unittests/Evo/CMakeLists.txt
|
||||
@@ -11,6 +11,6 @@ target_link_libraries(EvoTests PRIVATE
|
||||
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
target_link_libraries(EvoTests PRIVATE
|
||||
- curses)
|
||||
+ ncurses tinfo)
|
||||
endif()
|
||||
|
||||
--- a/llbuild/unittests/Ninja/CMakeLists.txt
|
||||
+++ b/llbuild/unittests/Ninja/CMakeLists.txt
|
||||
@@ -8,5 +8,5 @@ target_link_libraries(NinjaTests PRIVATE
|
||||
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
target_link_libraries(NinjaTests PRIVATE
|
||||
- curses)
|
||||
+ ncurses tinfo)
|
||||
endif()
|
||||
--- a/llbuild/utils/adjust-times/CMakeLists.txt
|
||||
+++ b/llbuild/utils/adjust-times/CMakeLists.txt
|
||||
@@ -7,5 +7,5 @@ target_link_libraries(adjust-times PRIVATE llvmSupport)
|
||||
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
target_link_libraries(adjust-times PRIVATE
|
||||
- curses)
|
||||
+ ncurses tinfo)
|
||||
endif()
|
||||
Reference in New Issue
Block a user