Skip to content

Commit 72c4c37

Browse files
committed
Special-case OpenBSD in Versions.cpp instead of in Package.swift in case it gets a clang update in the future
1 parent 955dc35 commit 72c4c37

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

Package.swift

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

467467
.define("SWT_NO_LEGACY_TEST_DISCOVERY", .whenEmbedded()),
468468
.define("SWT_NO_LIBDISPATCH", .whenEmbedded()),
469-
470-
// OpenBSD's version of clang doesn't support __has_embed.
471-
.define("SWT_TESTING_LIBRARY_VERSION", to: "0", .when(platforms: [.openbsd]))
472469
]
473470

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

Sources/_TestingInternals/Versions.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
const char *swt_getTestingLibraryVersion(void) {
1919
#if defined(SWT_TESTING_LIBRARY_VERSION)
2020
// The current environment explicitly specifies a version string to return.
21+
// All CMake builds should take this path (see CompilerSettings.cmake.)
2122
return SWT_TESTING_LIBRARY_VERSION;
2223
#elif __clang_major__ >= 17 && defined(__has_embed)
2324
#if __has_embed("../../VERSION.txt")
@@ -43,6 +44,9 @@ const char *swt_getTestingLibraryVersion(void) {
4344
#warning SWT_TESTING_LIBRARY_VERSION not defined and VERSION.txt not found: testing library version is unavailable
4445
return nullptr;
4546
#endif
47+
#elif defined(__OpenBSD__)
48+
// OpenBSD's version of clang doesn't support __has_embed or #embed.
49+
return nullptr;
4650
#else
4751
#warning SWT_TESTING_LIBRARY_VERSION not defined and could not read from VERSION.txt at compile time: testing library version is unavailable
4852
return nullptr;

cmake/modules/shared/CompilerSettings.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,5 @@ if(CMAKE_SYSTEM_NAME STREQUAL "WASI")
4343
add_compile_definitions("SWT_NO_PIPES")
4444
endif()
4545

46-
# Avoid using C23's #embed when building with CMake as OpenBSD and Amazon Linux
47-
# 2 are both using older clang versions that don't support it.
4846
file(STRINGS "../VERSION.txt" SWT_TESTING_LIBRARY_VERSION LIMIT_COUNT 1)
4947
add_compile_definitions("$<$<COMPILE_LANGUAGE:CXX>:SWT_TESTING_LIBRARY_VERSION=\"${SWT_TESTING_LIBRARY_VERSION}\">")

0 commit comments

Comments
 (0)