Skip to content

Commit 301a0c4

Browse files
committed
Swift on OpenBSD supports arm64.
However, to do this, we end up changing how amd64 is supported too. Previously, I had tried to keep some meaningful separation between platform spelling and LLVM spelling, but this is becoming more difficult to meaningfully maintain. Target specifications are trivially converted LLVM triples, and the module files are looked up by LLVM triples. We can make sure that the targets align, but then the Glibc to SwiftGlibc import breaks. That could also be addressed, but then we get to a point where the targets set up by build-script and referenced by cmake begin to misalign. There are references in build-script-impl for a potential renaming site, but it's not quite enough. It's far simpler to give up and rename to LLVM spellings right at the beginning. This does mean that this commit is less constrained to just adding the necessary parts to enable arm64, but it should mean less headaches overall from differing architecture spellings.
1 parent c690fef commit 301a0c4

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

cmake/modules/SwiftConfigureSDK.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,14 +429,14 @@ macro(configure_sdk_unix name architectures)
429429

430430
set(SWIFT_SDK_FREEBSD_ARCH_${arch}_TRIPLE "${arch}-unknown-freebsd${freebsd_system_version}")
431431
elseif("${prefix}" STREQUAL "OPENBSD")
432-
if(NOT arch STREQUAL "amd64")
432+
if(NOT arch STREQUAL "x86_64" AND NOT arch STREQUAL "aarch64")
433433
message(FATAL_ERROR "unsupported arch for OpenBSD: ${arch}")
434434
endif()
435435

436436
set(openbsd_system_version ${CMAKE_SYSTEM_VERSION})
437437
message(STATUS "OpenBSD Version: ${openbsd_system_version}")
438438

439-
set(SWIFT_SDK_OPENBSD_ARCH_amd64_TRIPLE "amd64-unknown-openbsd${openbsd_system_version}")
439+
set(SWIFT_SDK_OPENBSD_ARCH_${arch}_TRIPLE "${arch}-unknown-openbsd${openbsd_system_version}")
440440

441441
if(CMAKE_SYSROOT)
442442
set(SWIFT_SDK_OPENBSD_ARCH_${arch}_PATH "${CMAKE_SYSROOT}${SWIFT_SDK_OPENBSD_ARCH_${arch}_PATH}" CACHE INTERNAL "sysroot path" FORCE)

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ function(_add_target_variant_link_flags)
529529
list(APPEND link_libraries "pthread")
530530
elseif("${LFLAGS_SDK}" STREQUAL "OPENBSD")
531531
list(APPEND link_libraries "pthread")
532+
list(APPEND result "-Wl,-Bsymbolic")
532533
elseif("${LFLAGS_SDK}" STREQUAL "CYGWIN")
533534
# No extra libraries required.
534535
elseif("${LFLAGS_SDK}" STREQUAL "WINDOWS")

stdlib/public/core/CTypes.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ public typealias CLongDouble = Double
108108
#elseif os(OpenBSD)
109109
#if arch(x86_64)
110110
public typealias CLongDouble = Float80
111+
#elseif arch(arm64)
112+
public typealias CLongDouble = Double
111113
#else
112114
#error("CLongDouble needs to be defined for this OpenBSD architecture")
113115
#endif

utils/build-script-impl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,8 @@ function verify_host_is_supported() {
459459
case ${host} in
460460
freebsd-arm64 \
461461
| freebsd-x86_64 \
462-
| openbsd-amd64 \
462+
| openbsd-x86_64 \
463+
| openbsd-aarch64 \
463464
| cygwin-x86_64 \
464465
| haiku-x86_64 \
465466
| linux-x86_64 \

utils/swift_build_support/swift_build_support/targets.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ class StdlibDeploymentTarget(object):
296296
'x86_64',
297297
'aarch64'])
298298

299-
OpenBSD = OpenBSDPlatform("openbsd", archs=["amd64"])
299+
OpenBSD = OpenBSDPlatform("openbsd", archs=["x86_64", "aarch64"])
300300

301301
Cygwin = Platform("cygwin", archs=["x86_64"])
302302

@@ -403,7 +403,9 @@ def host_target():
403403

404404
elif system == 'OpenBSD':
405405
if machine == 'amd64':
406-
return StdlibDeploymentTarget.OpenBSD.amd64
406+
return StdlibDeploymentTarget.OpenBSD.x86_64
407+
elif machine == 'arm64':
408+
return StdlibDeploymentTarget.OpenBSD.aarch64
407409

408410
elif system == 'CYGWIN_NT-10.0':
409411
if machine == 'x86_64':

0 commit comments

Comments
 (0)