From f92fb3051c2afcf9cee0264b170a03d3848ee6c7 Mon Sep 17 00:00:00 2001 From: Evan Wilde Date: Wed, 23 Jul 2025 15:04:02 -0700 Subject: [PATCH 1/4] FreeBSD: cfuncs_parse powl Like on 64-bit Android and arm64 Linux, arm64 FreeBSD uses 128 bit long doubles, which is not supported by Swift resulting in powl to fail to import and failing the test. https://github.com/swiftlang/swift/issues/51573 --- test/ClangImporter/cfuncs_parse.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/ClangImporter/cfuncs_parse.swift b/test/ClangImporter/cfuncs_parse.swift index f2ca15c0876a5..051ffd35e52aa 100644 --- a/test/ClangImporter/cfuncs_parse.swift +++ b/test/ClangImporter/cfuncs_parse.swift @@ -70,7 +70,9 @@ func test_pow() { // https://github.com/apple/swift/issues/51573 // long doubles in AAPCS64 and 64-bit Android are 128 bits, which is not // supported by Swift, so don't test this. -#if !((os(Android) && _pointerBitWidth(_64)) || (os(Linux) && arch(arm64))) +#if !((os(Android) && _pointerBitWidth(_64)) || + (os(Linux) && arch(arm64)) || + (os(FreeBSD) && arch(arm64))) func test_powl() { powl(1.5, 2.5) } From 292601826f1ca31fbfd40b378cbab737b87e5299 Mon Sep 17 00:00:00 2001 From: Evan Wilde Date: Wed, 23 Jul 2025 15:06:38 -0700 Subject: [PATCH 2/4] FreeBSD: ASAN hang on aarch64 ASAN hangs on aarch64 FreeBSD. Disabling until we have a chance to dig through it. --- test/Sanitizers/asan/asan.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/Sanitizers/asan/asan.swift b/test/Sanitizers/asan/asan.swift index b6e38598a4636..d5636c0c5140c 100644 --- a/test/Sanitizers/asan/asan.swift +++ b/test/Sanitizers/asan/asan.swift @@ -1,5 +1,10 @@ // XFAIL: OS=windows-msvc +// This test hangs on aarch64 FreeBSD +// XFAIL will try to run the test and the verify that the test fails, which +// still hits the hang. +// UNSUPPORTED: OS=freebsd && CPU=aarch64 + // RUN: %target-swiftc_driver %s -g -sanitize=address -o %t_asan-binary // RUN: %target-codesign %t_asan-binary // RUN: env %env-ASAN_OPTIONS=abort_on_error=0 not %target-run %t_asan-binary 2>&1 | %FileCheck %s From de23d4b2516b5801283427a55f968824f49fa119 Mon Sep 17 00:00:00 2001 From: Evan Wilde Date: Thu, 24 Jul 2025 15:08:19 -0700 Subject: [PATCH 3/4] FreeBSD: PIC cdecl_official_run.swift Client.o Swift defaults to PIC everywhere. The Swift toolchain clang emits PIC relocatable objects by default without passing `-fPIC` on Linux, so the emitted Client.o is relocatable. This is not the case on FreeBSD, where clang uses the static relocation model by default resulting in a link failure due to mixing relocations with non-relocatable objects. ``` ld.lld: error: relocation R_X86_64_64 cannot be used against local symbol; recompile with -fPIC ``` Passing `-fPIC` where needed. --- test/Interpreter/cdecl_official_run.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Interpreter/cdecl_official_run.swift b/test/Interpreter/cdecl_official_run.swift index 2ed14a1b6022d..cdc6872fee727 100644 --- a/test/Interpreter/cdecl_official_run.swift +++ b/test/Interpreter/cdecl_official_run.swift @@ -9,7 +9,7 @@ /// Build and run a binary from Swift and C code. // RUN: %clang-no-modules -c %t/Client.c -o %t/Client.o -target %target-triple \ -// RUN: -I %t -I %clang-include-dir -Werror -isysroot %sdk +// RUN: %target-pic-opt -I %t -I %clang-include-dir -Werror -isysroot %sdk // RUN: %target-build-swift %t/Lib.swift %t/Client.o -O -o %t/a.out \ // RUN: -enable-experimental-feature CDecl -parse-as-library // RUN: %target-codesign %t/a.out From 698dbc03f130af69443b24e83a7772e27c82ed27 Mon Sep 17 00:00:00 2001 From: Evan Wilde Date: Thu, 24 Jul 2025 17:36:59 -0700 Subject: [PATCH 4/4] FreeBSD: Disable broken tests Disabling a few tests. The distributed tests are failing for the same reason they fail on Linux, the rpaths and library search paths are mucked up. Fixing that shouldn't be too hard, but should be enabled on both platforms at once. CollectiveTransformers doesn't work because it imports Darwin directly. There is a note that is several years old saying that we should port the test to the other platforms, but that is beyond the scope of this PR at the moment. --- ...ted_actor_remoteCall_accessibleFunctions_crossModule.swift | 2 +- ...tor_remoteCall_accessibleFunctions_crossModule_irgen.swift | 4 ++-- test/IRGen/profiling_marker_thunks.swift | 2 +- test/Prototypes/CollectionTransformers.swift | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/Distributed/Runtime/distributed_actor_remoteCall_accessibleFunctions_crossModule.swift b/test/Distributed/Runtime/distributed_actor_remoteCall_accessibleFunctions_crossModule.swift index e4da26b8221af..71fd7347b648f 100644 --- a/test/Distributed/Runtime/distributed_actor_remoteCall_accessibleFunctions_crossModule.swift +++ b/test/Distributed/Runtime/distributed_actor_remoteCall_accessibleFunctions_crossModule.swift @@ -79,7 +79,7 @@ // Locating the built libraries failed on Linux (construction of test case), // but we primarily care about macOS in this test -// UNSUPPORTED: OS=linux-gnu +// UNSUPPORTED: OS=linux-gnu || OS=freebsd // %env does not seem to work on Windows // UNSUPPORTED: OS=windows-msvc diff --git a/test/Distributed/Runtime/distributed_actor_remoteCall_accessibleFunctions_crossModule_irgen.swift b/test/Distributed/Runtime/distributed_actor_remoteCall_accessibleFunctions_crossModule_irgen.swift index 155ecfb060068..fbc9fd5b21f9a 100644 --- a/test/Distributed/Runtime/distributed_actor_remoteCall_accessibleFunctions_crossModule_irgen.swift +++ b/test/Distributed/Runtime/distributed_actor_remoteCall_accessibleFunctions_crossModule_irgen.swift @@ -50,7 +50,7 @@ // Locating the built libraries failed on Linux (construction of test case), // but we primarily care about macOS in this test -// UNSUPPORTED: OS=linux-gnu +// UNSUPPORTED: OS=linux-gnu || OS=freebsd // %env does not seem to work on Windows // UNSUPPORTED: OS=windows-msvc @@ -244,4 +244,4 @@ class AnotherImpl {} // CHECK-SAME: ) to i64) // CHECK-SAME: ) to i32 // CHECK-SAME: ) -// CHECK-SAME: }, section "__TEXT,__const", no_sanitize_address, align 4 \ No newline at end of file +// CHECK-SAME: }, section "__TEXT,__const", no_sanitize_address, align 4 diff --git a/test/IRGen/profiling_marker_thunks.swift b/test/IRGen/profiling_marker_thunks.swift index 824fd65be5995..e1a767d9d35d6 100644 --- a/test/IRGen/profiling_marker_thunks.swift +++ b/test/IRGen/profiling_marker_thunks.swift @@ -7,7 +7,7 @@ // RUN: %target-swift-frontend -module-name A -I %t -emit-ir %s | %FileCheck %s --check-prefix=NOTHUNK // UNSUPPORTED: OS=windows-msvc -// UNSUPPORTED: OS=linux-gnu, OS=linux-android, OS=linux-androideabi +// UNSUPPORTED: OS=linux-gnu, OS=linux-android, OS=linux-androideabi, OS=freebsd // UNSUPPORTED: CPU=arm64e diff --git a/test/Prototypes/CollectionTransformers.swift b/test/Prototypes/CollectionTransformers.swift index 4943ba01d0c57..e8d04cfc7b28a 100644 --- a/test/Prototypes/CollectionTransformers.swift +++ b/test/Prototypes/CollectionTransformers.swift @@ -200,7 +200,7 @@ import Darwin import Dispatch // FIXME: port to Linux. -// XFAIL: OS=linux-gnu, OS=windows-msvc, OS=openbsd, OS=linux-android +// XFAIL: OS=linux-gnu, OS=windows-msvc, OS=freebsd, OS=openbsd, OS=linux-android // A wrapper for pthread_t with platform-independent interface. public struct _stdlib_pthread_t : Equatable, Hashable {