Skip to content

ObjcRuntime.h: Add mips64, aarch64, and riscv64 to non-legacy dispatch #76694

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 9 commits into from
Jan 3, 2024
28 changes: 18 additions & 10 deletions clang/include/clang/Basic/ObjCRuntime.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,24 @@ class ObjCRuntime {
bool isLegacyDispatchDefaultForArch(llvm::Triple::ArchType Arch) {
// The GNUstep runtime uses a newer dispatch method by default from
// version 1.6 onwards
if (getKind() == GNUstep && getVersion() >= VersionTuple(1, 6)) {
if (Arch == llvm::Triple::arm ||
Arch == llvm::Triple::x86 ||
Arch == llvm::Triple::x86_64)
return false;
}
else if ((getKind() == MacOSX) && isNonFragile() &&
(getVersion() >= VersionTuple(10, 0)) &&
(getVersion() < VersionTuple(10, 6)))
return Arch != llvm::Triple::x86_64;
if (getKind() == GNUstep) {
switch (Arch) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The version check above is not quite right for these.

AArch64 support is in 1.9.
RV64 in 2.2.

I think mips64 is correct (it looks like I added the code 9 years ago, which probably lines up with the 1.6 release).

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 version check above is not quite right for these.

This was my first approach, but it seems like GNUstep and libobjc2 unit tests are always emitting -fobjc-runtime=gnustep-2.0

So one would need to change this flag in the build configuration everytime libobjc2 gets updated.

Copy link
Contributor Author

@hmelder hmelder Jan 2, 2024

Choose a reason for hiding this comment

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

I can do the version check and update the libobjc2 README to properly document this. I probably need to rewrite the detection in gnustep-make too -_-

Copy link
Contributor

Choose a reason for hiding this comment

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

This was my first approach, but it seems like GNUstep and libobjc2 unit tests are always emitting -fobjc-runtime=gnustep-2.0

That's fine. We should bump that in both places to the correct version. It's better than having the compiler emit things that are not supported when targeting a specific version of the runtime.

case llvm::Triple::arm:
case llvm::Triple::x86:
case llvm::Triple::x86_64:
return !(getVersion() >= VersionTuple(1, 6));
case llvm::Triple::aarch64:
case llvm::Triple::mips64:
return !(getVersion() >= VersionTuple(1, 9));
case llvm::Triple::riscv64:
return !(getVersion() >= VersionTuple(2, 2));
default:
return true;
}
} else if ((getKind() == MacOSX) && isNonFragile() &&
(getVersion() >= VersionTuple(10, 0)) &&
(getVersion() < VersionTuple(10, 6)))
return Arch != llvm::Triple::x86_64;
// Except for deployment target of 10.5 or less,
// Mac runtimes use legacy dispatch everywhere now.
return true;
Expand Down
3 changes: 2 additions & 1 deletion clang/test/CodeGenObjC/messages.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// RUN: %clang_cc1 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-MAC
// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-MAC-NF
// RUN: %clang_cc1 -fobjc-runtime=gcc -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-GNU
// RUN: %clang_cc1 -fobjc-runtime=gnustep -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-GNU-NF
// RUN: %clang_cc1 -fobjc-runtime=gnustep -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-GNU-NF
// RUN: %clang_cc1 -fobjc-runtime=gnustep-2.2 -fobjc-dispatch-method=non-legacy -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-MAC

typedef struct {
int x;
Expand Down
38 changes: 38 additions & 0 deletions clang/test/Driver/gnustep-dispatch-method.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// DEFINE: %{triple} =
// DEFINE: %{ver} = 1.6
// DEFINE: %{prefix} = CHECK-MSGSEND
// DEFINE: %{check} = %clang --target=%{triple} -fobjc-runtime=gnustep-%{ver} -### -c %s 2>&1 | FileCheck -check-prefix=%{prefix} %s

// REDEFINE: %{ver} = 1.6
// REDEFINE: %{triple} = i386-unknown-freebsd
// RUN: %{check}
// REDEFINE: %{triple} = x86_64-unknown-freebsd
// RUN: %{check}
// REDEFINE: %{triple} = arm-unknown-freebsd
// RUN: %{check}
// REDEFINE: %{prefix} = CHECK-MSGLOOKUP
// REDEFINE: %{triple} = aarch64-unknown-freebsd
// RUN: %{check}
// REDEFINE: %{triple} = mips64-unknown-freebsd
// RUN: %{check}
// REDEFINE: %{triple} = riscv64-unknown-freebsd
// RUN: %{check}

// REDEFINE: %{ver} = 1.9
// REDEFINE: %{prefix} = CHECK-MSGSEND
// REDEFINE: %{triple} = aarch64-unknown-freebsd
// RUN: %{check}
// REDEFINE: %{triple} = mips64-unknown-freebsd
// RUN: %{check}
// REDEFINE: %{prefix} = CHECK-MSGLOOKUP
// REDEFINE: %{triple} = riscv64-unknown-freebsd
// RUN: %{check}

// REDEFINE: %{ver} = 2.2
// REDEFINE: %{prefix} = CHECK-MSGSEND
// REDEFINE: %{triple} = riscv64-unknown-freebsd
// RUN: %{check}


// CHECK-MSGSEND: "-cc1"{{.*}} "-fobjc-dispatch-method=non-legacy"
// CHECK-MSGLOOKUP-NOT: "-cc1"{{.*}} "-fobjc-dispatch-method=non-legacy"