Add a build flavor to opt-out of BTCFI on OpenBSD.

To work-around #80059, we need to stop return address signing and
opt-out of BTCFI enforcement via enabling a platform linker option.

We don't want to completely undo the BTCFI work in the rare case that
we later figure out how to properly address the above issue, or allow
users who might want to benefit from BTCFI enforcement and won't use
Concurrency. To do this, condition the existing BTCFI flag enforcement
into a configuration option that defaults to off for now.

Because the new swift-driver needs to "know" whether the frontend is
configured to opt-out or not, and since the new driver communicates with
the frontend via the target info JSON to begin with, we add a field
that emits the build flavor to signal the right behavior.
This commit is contained in:
3405691582
2025-03-27 19:57:24 -04:00
parent d1737b9c20
commit a341ce5570
7 changed files with 52 additions and 1 deletions

View File

@@ -575,6 +575,17 @@ set(SWIFT_DARWIN_XCRUN_TOOLCHAIN "XcodeDefault" CACHE STRING
set(SWIFT_DARWIN_STDLIB_INSTALL_NAME_DIR "/usr/lib/swift" CACHE STRING
"The directory of the install_name for standard library dylibs")
#
# User-configurable OpenBSD-specific options.
#
option(SWIFT_OPENBSD_BTCFI
"Emit branch target identification instructions and sign return addresses when available"
FALSE)
if(SWIFT_OPENBSD_BTCFI)
add_definitions("-DSWIFT_OPENBSD_BTCFI")
endif()
# We don't want to use the same install_name_dir as the standard library which
# will be installed in /usr/lib/swift. These private libraries should continue
# to use @rpath for now.