From d47722a2f838a167333c62b84d0b6d8b1ed97f81 Mon Sep 17 00:00:00 2001 From: Ron Olson Date: Aug 22 2023 17:59:52 +0000 Subject: Added patches to make Swift buildable with glibc 2.38 --- diff --git a/fclose_issues.patch b/fclose_issues.patch new file mode 100644 index 0000000..b2b0f8d --- /dev/null +++ b/fclose_issues.patch @@ -0,0 +1,20 @@ +--- swift-tools-support-core/Sources/TSCBasic/FileSystem.swift.orig 2023-08-15 14:01:48.975819260 -0500 ++++ swift-tools-support-core/Sources/TSCBasic/FileSystem.swift 2023-08-15 14:02:09.449066299 -0500 +@@ -473,7 +473,7 @@ + if fp == nil { + throw FileSystemError(errno: errno, path) + } +- defer { fclose(fp) } ++ defer { fclose(fp!) } + + // Read the data one block at a time. + let data = BufferedOutputByteStream() +@@ -503,7 +503,7 @@ + if fp == nil { + throw FileSystemError(errno: errno, path) + } +- defer { fclose(fp) } ++ defer { fclose(fp!) } + + // Write the data in one chunk. + var contents = bytes.contents diff --git a/new_glibc.patch b/new_glibc.patch new file mode 100644 index 0000000..6a84f8c --- /dev/null +++ b/new_glibc.patch @@ -0,0 +1,27 @@ +diff --color -Naur swift-corelibs-foundation-orig/CoreFoundation/Base.subproj/CoreFoundation_Prefix.h swift-corelibs-foundation/CoreFoundation/Base.subproj/CoreFoundation_Prefix.h +--- swift-corelibs-foundation-orig/CoreFoundation/Base.subproj/CoreFoundation_Prefix.h 2023-07-06 10:02:48.000000000 -0500 ++++ swift-corelibs-foundation/CoreFoundation/Base.subproj/CoreFoundation_Prefix.h 2023-08-16 12:53:42.332226574 -0500 +@@ -189,7 +189,7 @@ + #define CF_RETAIN_BALANCED_ELSEWHERE(obj, identified_location) do { } while (0) + #endif + +-#if (TARGET_OS_LINUX && !TARGET_OS_ANDROID && !TARGET_OS_CYGWIN) || TARGET_OS_WIN32 ++#if (TARGET_OS_LINUX && !TARGET_OS_ANDROID && !TARGET_OS_CYGWIN && !ALREADY_HAVE_STRL_FUNCS) || TARGET_OS_WIN32 + CF_INLINE size_t + strlcpy(char * dst, const char * src, size_t maxlen) { + const size_t srclen = strlen(src); +diff --color -Naur swift-corelibs-foundation-orig/CoreFoundation/CMakeLists.txt swift-corelibs-foundation/CoreFoundation/CMakeLists.txt +--- swift-corelibs-foundation-orig/CoreFoundation/CMakeLists.txt 2023-07-06 10:02:48.000000000 -0500 ++++ swift-corelibs-foundation/CoreFoundation/CMakeLists.txt 2023-08-16 12:53:44.851386844 -0500 +@@ -80,6 +80,11 @@ + add_compile_definitions($<$:HAVE_SCHED_GETAFFINITY>) + endif() + endif() ++ # XYZZY ++ check_symbol_exists(strlcpy "string.h" HAVE_NEW_GLIBC) ++ if(HAVE_NEW_GLIBC) ++ add_compile_definitions($<$:ALREADY_HAVE_STRL_FUNCS>) ++ endif() + endif() + elseif(CMAKE_SYSTEM_NAME STREQUAL Windows) + # NOTE(compnerd) we only support building with the dynamic CRT as using the diff --git a/swift-lang.spec b/swift-lang.spec index 6d8566d..95cace0 100644 --- a/swift-lang.spec +++ b/swift-lang.spec @@ -32,7 +32,7 @@ Name: swift-lang Version: %{package_version} -Release: %{fedora_release}%{?dist}.2 +Release: %{fedora_release}%{?dist} Summary: The Swift programming language License: Apache-2.0 URL: https://www.swift.org @@ -80,6 +80,9 @@ Patch2: enablelzma.patch Patch3: fs.patch Patch4: unusedvars.patch Patch5: no-test.patch +Patch7: fclose_issues.patch +Patch8: new_glibc.patch + BuildRequires: clang BuildRequires: swig @@ -183,14 +186,25 @@ mv ninja-%{ninja_version} ninja %py3_shebang_fix llvm-project/compiler-rt/lib/hwasan/scripts/hwasan_symbolize # Fix for uinit_ptr not being declared implicitly -%patch1 -p0 +%patch -P1 -p0 # Enable LZMA -%patch2 -p0 +%patch -P2 -p0 # Tests fail for some reason preventing the package from being built -%patch5 -p0 +%patch -P5 -p0 + +# Issue with >= F39 not liking not having the file object +# explicitly forced in an fclose() +%if 0%{?fedora} >= 39 +%patch -P7 -p0 +%endif +# 39 and later, so this patch modifies the CMakeLists.txt file +# to add a check for them, along with a patch to the header +# file that if they are present, don't define the functions +# seperately. +%patch -P8 -p0 %build export VERBOSE=1 @@ -237,6 +251,10 @@ export QA_SKIP_RPATHS=1 %changelog +* Tue Aug 22 2023 Ron Olson 5.8.1-2 +- Added patch to work with glibc 2.38 + Resolves: rhbz#2226476 + * Sat Jul 22 2023 Fedora Release Engineering - 5.8.1-1.2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild