Skip to content

Commit 2e3612c

Browse files
committed
Work around lack of embed in OpenBSD's clang.
For various reasons, the Swift toolchain for OpenBSD relies on using the platform's native clang, which is 16. clang 19 is the most recent version that will not emit an error with the new __has_embed features in C23. Since swift-testing is experimentally supported by OpenBSD and thus to make swift-testing build again on the platform, work around the issue with a platform-specific command-line specified macro override in swiftpm and in cmake. Furthermore, we can use cmake trickery to subsitute the version file contents instead of using embed. This may not be possible to do with swiftpm, but I don't know for sure.
1 parent 279629f commit 2e3612c

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Package.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ extension Array where Element == PackageDescription.CXXSetting {
466466

467467
.define("SWT_NO_LEGACY_TEST_DISCOVERY", .whenEmbedded()),
468468
.define("SWT_NO_LIBDISPATCH", .whenEmbedded()),
469+
.define("SWT_TESTING_LIBRARY_VERSION", to: "0", .when(platforms: [.openbsd]))
469470
]
470471

471472
// Capture the testing library's commit info as C++ constants.

cmake/modules/shared/CompilerSettings.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "WASI")
4242
add_compile_definitions("SWT_NO_DYNAMIC_LINKING")
4343
add_compile_definitions("SWT_NO_PIPES")
4444
endif()
45+
if(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
46+
file(STRINGS "../VERSION.txt" SWT_TESTING_LIBRARY_VERSION)
47+
add_compile_definitions(SWT_TESTING_LIBRARY_VERSION="${SWT_TESTING_LIBRARY_VERSION}")
48+
endif()

0 commit comments

Comments
 (0)