Skip to content

[Stdlib][Frontend][CMake] Remove SWIFT_DARWIN_ENABLE_STABLE_ABI_BIT option, make it permanently on. #23235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,6 @@ option(SWIFT_RUNTIME_CRASH_REPORTER_CLIENT
"Whether to enable CrashReporter integration"
FALSE)

option(SWIFT_DARWIN_ENABLE_STABLE_ABI_BIT
"Enable the Swift stable ABI's class marker bit for new deployment targets"
TRUE)

set(SWIFT_DARWIN_XCRUN_TOOLCHAIN "XcodeDefault" CACHE STRING
"The name of the toolchain to pass to 'xcrun'")

Expand Down
5 changes: 0 additions & 5 deletions include/swift/AST/KnownIdentifiers.def
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,7 @@ IDENTIFIER(stringValue)
IDENTIFIER(super)
IDENTIFIER(superDecoder)
IDENTIFIER(superEncoder)
#if SWIFT_DARWIN_ENABLE_STABLE_ABI_BIT
IDENTIFIER_WITH_NAME(SwiftObject, "_TtCs12_SwiftObject")
#else
// Pre-stable ABI uses un-mangled name for SwiftObject.
IDENTIFIER(SwiftObject)
#endif
IDENTIFIER(to)
IDENTIFIER(toRaw)
IDENTIFIER(Type)
Expand Down
6 changes: 4 additions & 2 deletions include/swift/Basic/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,10 @@ namespace swift {
bool EnableObjCInterop = true;

/// On Darwin platforms, use the pre-stable ABI's mark bit for Swift
/// classes instead of the stable ABI's bit.
bool UseDarwinPreStableABIBit = !bool(SWIFT_DARWIN_ENABLE_STABLE_ABI_BIT);
/// classes instead of the stable ABI's bit. This is needed when
/// targeting OSes prior to macOS 10.14.4 and iOS 12.2, where
/// libobjc does not support the stable ABI's marker bit.
bool UseDarwinPreStableABIBit = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this guard at this point?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compiler still needs to emit the pre-stable ABI bit when targeting OSes prior to 10.14.4 and corresponding releases. This option controls that. It gets set based on the target OS version here: https://github.com/apple/swift/pull/23235/files#diff-487c2f92307618024a8f8f553589405dR431

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind putting a reference to that in a comment? It seems like it would be something that could get dropped at some point (when 10.14.4 is EOL'ed).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll do that. Given that we still support 10.9 that might be a while, but it would be good to explain.


/// Enables checking that uses of @objc require importing
/// the Foundation module.
Expand Down
2 changes: 0 additions & 2 deletions include/swift/Config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,4 @@

#cmakedefine HAVE_PROC_PID_RUSAGE 1

#cmakedefine01 SWIFT_DARWIN_ENABLE_STABLE_ABI_BIT

#endif // SWIFT_CONFIG_H
1 change: 0 additions & 1 deletion include/swift/Runtime/CMakeConfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#ifndef SWIFT_RUNTIME_CMAKECONFIG_H
#define SWIFT_RUNTIME_CMAKECONFIG_H

#cmakedefine01 SWIFT_DARWIN_ENABLE_STABLE_ABI_BIT
#cmakedefine01 SWIFT_BNI_OS_BUILD
#cmakedefine01 SWIFT_BNI_XCODE_BUILD

Expand Down
4 changes: 0 additions & 4 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,15 +428,11 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
Target.isOSDarwin());
Opts.EnableSILOpaqueValues |= Args.hasArg(OPT_enable_sil_opaque_values);

#if SWIFT_DARWIN_ENABLE_STABLE_ABI_BIT
Opts.UseDarwinPreStableABIBit =
(Target.isMacOSX() && Target.isMacOSXVersionLT(10, 14, 4)) ||
(Target.isiOS() && Target.isOSVersionLT(12, 2)) ||
(Target.isTvOS() && Target.isOSVersionLT(12, 2)) ||
(Target.isWatchOS() && Target.isOSVersionLT(5, 2));
#else
Opts.UseDarwinPreStableABIBit = true;
#endif

Opts.DisableConstraintSolverPerformanceHacks |=
Args.hasArg(OPT_disable_constraint_solver_performance_hacks);
Expand Down
6 changes: 0 additions & 6 deletions lib/IRGen/GenMeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2411,12 +2411,6 @@ static void emitFieldOffsetGlobals(IRGenModule &IGM,
static ClassFlags getClassFlags(ClassDecl *classDecl) {
auto flags = ClassFlags();

#if !SWIFT_DARWIN_ENABLE_STABLE_ABI_BIT
// FIXME: Remove this after enabling stable ABI.
// This bit is NOT conditioned on UseDarwinPreStableABIBit.
flags |= ClassFlags::IsSwiftPreStableABI;
#endif

// Set a flag if the class uses Swift refcounting.
auto type = classDecl->getDeclaredType()->getCanonicalType();
if (type->getReferenceCounting() == ReferenceCounting::Native) {
Expand Down
4 changes: 0 additions & 4 deletions stdlib/public/runtime/SwiftObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,9 @@

#if SWIFT_OBJC_INTEROP

#if SWIFT_DARWIN_ENABLE_STABLE_ABI_BIT
// Source code: "SwiftObject"
// Real class name: mangled "Swift._SwiftObject"
#define SwiftObject _TtCs12_SwiftObject
#else
// Pre-stable ABI uses un-mangled name for SwiftObject
#endif

#if __has_attribute(objc_root_class)
__attribute__((__objc_root_class__))
Expand Down
4 changes: 2 additions & 2 deletions test/Interpreter/SDK/Inputs/OldABI/OldABI.mm
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ static void initialize(void) {

bool CanTestOldABI() {
// These tests don't work until the stable ABI is using its designed bit.
// This check can be removed after SWIFT_DARWIN_ENABLE_STABLE_ABI_BIT
// is set everywhere.
// This check can be removed after SWIFT_CLASS_IS_SWIFT_MASK is made
// static everywhere.
Class cls = objc_getClass("_TtCs19__EmptyArrayStorage");
if (!cls) abort();
uintptr_t *words = (uintptr_t *)cls;
Expand Down
6 changes: 0 additions & 6 deletions test/stdlib/Inputs/SwiftObjectNSObject/SwiftObjectNSObject.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,6 @@ void HackSwiftObject()
{
SwiftObjectDemangledName = "Swift._SwiftObject";
Class cls = objc_getClass(SwiftObjectDemangledName);
// FIXME: Remove this fallback after we enable
// SWIFT_DARWIN_ENABLE_STABLE_ABI_BIT everywhere.
if (!cls) {
SwiftObjectDemangledName = "SwiftObject";
cls = objc_getClass(SwiftObjectDemangledName);
}

class_addMethod(cls, @selector(perform0), (IMP)Perform0, "@@:");
class_addMethod(cls, @selector(perform1:), (IMP)Perform1, "@@:@");
Expand Down