From 0158137afcd2c6ffd4102b4e3dc7962f011166df Mon Sep 17 00:00:00 2001 From: 3405691582 Date: Mon, 20 Oct 2025 21:19:08 -0400 Subject: [PATCH] Supply -z,nobtcfi on x86_64 as well. On older x86_64 hardware, this isn't a problem since CET IBT hardware support may not have been available. However, newer x86_64 hardware supports the feature, which will lead to BTCFI failures. Therefore ensure the same BTCFI disabling logic applies on x86_64 as well as aarch64. --- cmake/modules/AddSwift.cmake | 2 +- lib/Basic/Platform.cpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmake/modules/AddSwift.cmake b/cmake/modules/AddSwift.cmake index ed28ab1891dba..289716edfd496 100644 --- a/cmake/modules/AddSwift.cmake +++ b/cmake/modules/AddSwift.cmake @@ -995,7 +995,7 @@ function(add_swift_host_tool executable) endif() # Opt-out of OpenBSD BTCFI if instructed where it is enforced by default. - if(SWIFT_HOST_VARIANT_SDK STREQUAL "OPENBSD" AND SWIFT_HOST_VARIANT_ARCH STREQUAL "aarch64" AND NOT SWIFT_OPENBSD_BTCFI) + if(SWIFT_HOST_VARIANT_SDK STREQUAL "OPENBSD" AND SWIFT_HOST_VARIANT_ARCH MATCHES "aarch64|x86_64" AND NOT SWIFT_OPENBSD_BTCFI) target_link_options(${executable} PRIVATE "LINKER:-z,nobtcfi") endif() diff --git a/lib/Basic/Platform.cpp b/lib/Basic/Platform.cpp index 8c6f1200c0a39..c7f0bfa2757aa 100644 --- a/lib/Basic/Platform.cpp +++ b/lib/Basic/Platform.cpp @@ -150,7 +150,10 @@ bool swift::tripleRequiresRPathForSwiftLibrariesInOS( } bool swift::tripleBTCFIByDefaultInOpenBSD(const llvm::Triple &triple) { - return triple.isOSOpenBSD() && triple.getArch() == llvm::Triple::aarch64; + return triple.isOSOpenBSD() && ( + triple.getArch() == llvm::Triple::aarch64 || + triple.getArch() == llvm::Triple::x86_64); + } DarwinPlatformKind swift::getDarwinPlatformKind(const llvm::Triple &triple) {