-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[LLD, MachO] Default objc_relative_method_lists on MacOS11+/iOS14+ #101360
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
Changes from 3 commits
7f50084
f40e80c
dee85bc
d82b683
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,23 +2,34 @@ | |
# UNSUPPORTED: target=arm{{.*}}-unknown-linux-gnueabihf | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to add cases to test the new logic. Specifically: MacOS 10 => defaults to not relative MacOS 10 + There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
(2) Should be covered by removing (4) Should be covered by unchanged I need to modify lit config to test 1 and 3 (our lit config defaults to MacOS 11 now). I tried yesterday but with no luck. Let me try it again. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Why change lit configs - why not manually overwrite on the command line ? Like here. |
||
# RUN: rm -rf %t; split-file %s %t && cd %t | ||
|
||
## Compile a64_rel_dylib.o | ||
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos -o a64_rel_dylib.o a64_simple_class.s | ||
## Compile a64_rel_dylib.o with MacOS 11 | ||
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos11 -o a64_rel_dylib.o a64_simple_class.s | ||
|
||
## Test arm64 + relative method lists | ||
# RUN: %no-lsystem-lld a64_rel_dylib.o -o a64_rel_dylib.dylib -map a64_rel_dylib.map -dylib -arch arm64 -objc_relative_method_lists | ||
# RUN: %no-lsystem-lld a64_rel_dylib.o -o a64_rel_dylib.dylib -map a64_rel_dylib.map -dylib -arch arm64 | ||
# RUN: llvm-objdump --macho --objc-meta-data a64_rel_dylib.dylib | FileCheck %s --check-prefix=CHK_REL | ||
|
||
## Test arm64 + relative method lists + dead-strip | ||
# RUN: %no-lsystem-lld a64_rel_dylib.o -o a64_rel_dylib.dylib -map a64_rel_dylib.map -dylib -arch arm64 -objc_relative_method_lists -dead_strip | ||
# RUN: %no-lsystem-lld a64_rel_dylib.o -o a64_rel_dylib.dylib -map a64_rel_dylib.map -dylib -arch arm64 -dead_strip | ||
# RUN: llvm-objdump --macho --objc-meta-data a64_rel_dylib.dylib | FileCheck %s --check-prefix=CHK_REL | ||
|
||
## Test arm64 + traditional method lists (no relative offsets) | ||
# RUN: %no-lsystem-lld a64_rel_dylib.o -o a64_rel_dylib.dylib -map a64_rel_dylib.map -dylib -arch arm64 -no_objc_relative_method_lists | ||
# RUN: llvm-objdump --macho --objc-meta-data a64_rel_dylib.dylib | FileCheck %s --check-prefix=CHK_NO_REL | ||
|
||
## Compile a64_rel_dylib.o with MacOS 10 | ||
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos10 -o a64_rel_dylib.o a64_simple_class.s | ||
|
||
CHK_REL: Contents of (__DATA_CONST,__objc_classlist) section | ||
## Test arm64 + relative method lists by explicitly adding `-objc_relative_method_lists`. | ||
# RUN: %lld a64_rel_dylib.o -o a64_rel_dylib.dylib -map a64_rel_dylib.map -dylib -arch arm64 -platform_version macOS 10.0 10.0 -objc_relative_method_lists | ||
# RUN: llvm-objdump --macho --objc-meta-data a64_rel_dylib.dylib | FileCheck %s --check-prefix=CHK_REL | ||
|
||
## Test arm64 + no relative method lists by default. | ||
# RUN: %lld a64_rel_dylib.o -o a64_rel_dylib.dylib -map a64_rel_dylib.map -dylib -arch arm64 -platform_version macOS 10.0 10.0 | ||
# RUN: llvm-objdump --macho --objc-meta-data a64_rel_dylib.dylib | FileCheck %s --check-prefix=CHK_NO_REL | ||
|
||
|
||
CHK_REL: Contents of (__DATA{{(_CONST)?}},__objc_classlist) section | ||
CHK_REL-NEXT: _OBJC_CLASS_$_MyClass | ||
CHK_REL: baseMethods | ||
CHK_REL-NEXT: entsize 12 (relative) | ||
|
@@ -51,7 +62,7 @@ CHK_REL-NEXT: imp 0x{{[0-9a-f]*}} (0x{{[0-9a-f]*}}) +[MyClass class_method_0 | |
|
||
CHK_NO_REL-NOT: (relative) | ||
|
||
CHK_NO_REL: Contents of (__DATA_CONST,__objc_classlist) section | ||
CHK_NO_REL: Contents of (__DATA{{(_CONST)?}},__objc_classlist) section | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
CHK_NO_REL-NEXT: _OBJC_CLASS_$_MyClass | ||
|
||
CHK_NO_REL: baseMethods 0x{{[0-9a-f]*}} (struct method_list_t *) | ||
|
@@ -125,7 +136,7 @@ CHK_NO_REL-NEXT: imp +[MyClass class_method_02] | |
.include "objc-macros.s" | ||
|
||
.section __TEXT,__text,regular,pure_instructions | ||
.build_version macos, 11, 0 | ||
.build_version macos, 10, 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Build version still required or There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It produces 11 output even when specifying There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about changing the "old" target to Even if we do say that our generated binaries should run on macOS 10.0 (from 2001!), they won't. Dyld opcodes -- which we use for pre-chained-fixups targets -- were introduced around the 10.9 times. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should work: --- a/lld/test/MachO/objc-relative-method-lists-simple.s
+++ b/lld/test/MachO/objc-relative-method-lists-simple.s
@@ -2,8 +2,8 @@
# UNSUPPORTED: target=arm{{.*}}-unknown-linux-gnueabihf
# RUN: rm -rf %t; split-file %s %t && cd %t
-## Compile a64_rel_dylib.o with MacOS 11
-# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos11 -o a64_rel_dylib.o a64_simple_class.s
+## Compile a64_rel_dylib.o
+# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos10.15 -o a64_rel_dylib.o a64_simple_class.s
## Test arm64 + relative method lists
# RUN: %no-lsystem-lld a64_rel_dylib.o -o a64_rel_dylib.dylib -map a64_rel_dylib.map -dylib -arch arm64
@@ -17,19 +17,16 @@
# RUN: %no-lsystem-lld a64_rel_dylib.o -o a64_rel_dylib.dylib -map a64_rel_dylib.map -dylib -arch arm64 -no_objc_relative_method_lists
# RUN: llvm-objdump --macho --objc-meta-data a64_rel_dylib.dylib | FileCheck %s --check-prefix=CHK_NO_REL
-## Compile a64_rel_dylib.o with MacOS 10
-# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos10 -o a64_rel_dylib.o a64_simple_class.s
-
## Test arm64 + relative method lists by explicitly adding `-objc_relative_method_lists`.
-# RUN: %lld a64_rel_dylib.o -o a64_rel_dylib.dylib -map a64_rel_dylib.map -dylib -arch arm64 -platform_version macOS 10.0 10.0 -objc_relative_method_lists
+# RUN: %lld a64_rel_dylib.o -o a64_rel_dylib.dylib -map a64_rel_dylib.map -dylib -arch arm64 -platform_version macOS 10.15 10.15 -objc_relative_method_lists
# RUN: llvm-objdump --macho --objc-meta-data a64_rel_dylib.dylib | FileCheck %s --check-prefix=CHK_REL
## Test arm64 + no relative method lists by default.
-# RUN: %lld a64_rel_dylib.o -o a64_rel_dylib.dylib -map a64_rel_dylib.map -dylib -arch arm64 -platform_version macOS 10.0 10.0
+# RUN: %lld a64_rel_dylib.o -o a64_rel_dylib.dylib -map a64_rel_dylib.map -dylib -arch arm64 -platform_version macOS 10.15 10.15
# RUN: llvm-objdump --macho --objc-meta-data a64_rel_dylib.dylib | FileCheck %s --check-prefix=CHK_NO_REL
-CHK_REL: Contents of (__DATA{{(_CONST)?}},__objc_classlist) section
+CHK_REL: Contents of (__DATA_CONST,__objc_classlist) section
CHK_REL-NEXT: _OBJC_CLASS_$_MyClass
CHK_REL: baseMethods
CHK_REL-NEXT: entsize 12 (relative)
@@ -62,7 +59,7 @@ CHK_REL-NEXT: imp 0x{{[0-9a-f]*}} (0x{{[0-9a-f]*}}) +[MyClass class_method_0
CHK_NO_REL-NOT: (relative)
-CHK_NO_REL: Contents of (__DATA{{(_CONST)?}},__objc_classlist) section
+CHK_NO_REL: Contents of (__DATA_CONST,__objc_classlist) section
CHK_NO_REL-NEXT: _OBJC_CLASS_$_MyClass
CHK_NO_REL: baseMethods 0x{{[0-9a-f]*}} (struct method_list_t *)
@@ -136,7 +133,7 @@ CHK_NO_REL-NEXT: imp +[MyClass class_method_02]
.include "objc-macros.s"
.section __TEXT,__text,regular,pure_instructions
-.build_version macos, 10, 0
+.build_version macos, 10, 15
.objc_selector_def "-[MyClass instance_method_00]"
.objc_selector_def "-[MyClass instance_method_01]"
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh Cool! That works! |
||
|
||
.objc_selector_def "-[MyClass instance_method_00]" | ||
.objc_selector_def "-[MyClass instance_method_01]" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason we can't enable it for the other platforms?
See for example what we do for chained fixups (which based on my understanding was basically introduced alongside this feature):
llvm-project/lld/MachO/Driver.cpp
Lines 1109 to 1132 in 0512ba0
Looks like ld64 special-cases x86, but other than that, the
version2020Fall
condition covers watchOS, tvOS and friends as well.https://github.com/apple-oss-distributions/ld64/blob/47f477cb721755419018f7530038b272e9d0cdea/src/ld/Options.cpp#L6085-L6101
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can definitely add those platforms as well.
But can you shed more light how to special case x86 like the code you mentioned?
I don't find equivalence of
Options::kDynamicExecutable
in LLVM yet, onlyMH_EXECUTE
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think that part is safe to ignore, no need to special case it.
Apple might need to back-deploy executables during macOS's development process, but that is not relevant for user code.