Skip to content

Commit 4b3da9f

Browse files
committed
Revert "Add option for eliding property metadata from messages"
This reverts commit ca3674b. While there are savings, it ends up being to easy/common to run into issues with AppStore validation since the selector usage now appears to be a possible match for private apis vs. for selectors/properties in the generated code.
1 parent 378238e commit 4b3da9f

File tree

13 files changed

+90
-1430
lines changed

13 files changed

+90
-1430
lines changed

objectivec/DevTools/compile_testing_protos.sh

+2-22
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,15 @@
11
#!/bin/bash -eu
22
# Invoked by the Xcode projects to build the protos needed for the unittests.
33

4+
readonly OUTPUT_DIR="${PROJECT_DERIVED_FILE_DIR}/protos"
5+
46
# -----------------------------------------------------------------------------
57
# Helper for bailing.
68
die() {
79
echo "Error: $1"
810
exit 2
911
}
1012

11-
# -----------------------------------------------------------------------------
12-
# Parameters.
13-
if (( $# > 1 )); then
14-
die "Script takes only one parameter: $#"
15-
fi
16-
17-
if (( $# == 1 )); then
18-
case "$1" in
19-
"--elide_message_metadata")
20-
readonly ELIDE_MESSAGE_METADATA_OPTION="--objc_opt=elide_message_metadata"
21-
readonly OUTPUT_DIR="${PROJECT_DERIVED_FILE_DIR}/elided/protos"
22-
;;
23-
*)
24-
die "Unknown option: $1"
25-
;;
26-
esac
27-
else
28-
readonly ELIDE_MESSAGE_METADATA_OPTION=""
29-
readonly OUTPUT_DIR="${PROJECT_DERIVED_FILE_DIR}/normal/protos"
30-
fi
31-
3213
# -----------------------------------------------------------------------------
3314
# What to do.
3415
case "${ACTION}" in
@@ -176,7 +157,6 @@ compile_protos() {
176157
--proto_path=src/google/protobuf/ \
177158
--proto_path=src \
178159
--experimental_allow_proto3_optional \
179-
${ELIDE_MESSAGE_METADATA_OPTION} \
180160
"$@"
181161
}
182162

objectivec/GPBMessage_PackagePrivate.h

-130
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434

3535
#import "GPBMessage.h"
3636

37-
#import "GPBUtilities_PackagePrivate.h"
38-
3937
// TODO: Remove this import. Older generated code use the OSAtomic* apis,
4038
// so anyone that hasn't regenerated says building by having this. After
4139
// enough time has passed, this likely can be removed as folks should have
@@ -44,134 +42,6 @@
4442

4543
#import "GPBBootstrap.h"
4644

47-
#if defined(__LP64__) && __LP64__
48-
#define GPB_ASM_PTR " .quad "
49-
#define GPB_ASM_PTRSIZE " 8 "
50-
#define GPB_ASM_ONLY_LP64(x) x
51-
#define GPB_ALIGN_SIZE " 3 "
52-
#define GPB_DESCRIPTOR_METHOD_TYPE "@16@0:8"
53-
#else // __LP64__
54-
#define GPB_ASM_PTR " .long "
55-
#define GPB_ASM_PTRSIZE " 4 "
56-
#define GPB_ASM_ONLY_LP64(x)
57-
#define GPB_ALIGN_SIZE " 2 "
58-
#define GPB_DESCRIPTOR_METHOD_TYPE "@8@0:4"
59-
#endif // __LP64__
60-
61-
#define GPB_MESSAGE_CLASS_NAME_RAW GPBMessage
62-
#define GPB_MESSAGE_CLASS_NAME GPBStringifySymbol(GPB_MESSAGE_CLASS_NAME_RAW)
63-
64-
#if !__has_feature(objc_arc)
65-
#define GPB_CLASS_FLAGS " 0x00 "
66-
#define GPB_METACLASS_FLAGS " 0x01 "
67-
#else
68-
// 0x80 denotes that the class supports ARC.
69-
#define GPB_CLASS_FLAGS " 0x80 "
70-
#define GPB_METACLASS_FLAGS " 0x81 "
71-
#endif
72-
73-
// This generates code equivalent to:
74-
// ```
75-
// @implementation _name_
76-
// + (GPBDescriptor *)descriptor {
77-
// return _descriptorFunc_(self, _cmd);
78-
// }
79-
// @end
80-
// ```
81-
// We do this to avoid all of the @property metadata.
82-
// If we use `@dynamic` the compiler generates a lot of property data including
83-
// selectors and encoding strings. For large uses of protobufs, this can add
84-
// up to several megabytes of unused Objective-C metadata.
85-
// This inline class definition avoids the property data generation at the
86-
// cost of being a little ugly. This has been tested with both 32 and 64 bits
87-
// on intel and arm with Xcode 11.7 and Xcode 12.4.
88-
// We make cstring_literals be local definitions by starting them with "L".
89-
// https://ftp.gnu.org/old-gnu/Manuals/gas-2.9.1/html_chapter/as_5.html#SEC48
90-
// This keeps our symbols tables smaller, and is what the linker expects.
91-
// The linker in Xcode 12+ seems to be a bit more lenient about it, but the
92-
// Xcode 11 linker requires it, and will give a cryptic "malformed method list"
93-
// assertion if they are global.
94-
#define GPB_MESSAGE_SUBCLASS_IMPL(name, descriptorFunc) \
95-
__asm__( \
96-
".section __TEXT, __objc_classname, cstring_literals \n" \
97-
"L_OBJC_CLASS_NAME_" GPBStringifySymbol(name) ": " \
98-
" .asciz \"" GPBStringifySymbol(name) "\" \n" \
99-
\
100-
".ifndef L_GBPDescriptorMethodName \n" \
101-
".section __TEXT, __objc_methname, cstring_literals \n" \
102-
"L_GBPDescriptorMethodName: .asciz \"descriptor\" \n" \
103-
".endif \n" \
104-
\
105-
".ifndef L_GPBDescriptorMethodType \n" \
106-
".section __TEXT, __objc_methtype, cstring_literals \n" \
107-
"L_GPBDescriptorMethodType: .asciz \"" GPB_DESCRIPTOR_METHOD_TYPE "\" \n" \
108-
".endif \n" \
109-
\
110-
".section __DATA,__objc_const, regular \n" \
111-
".p2align" GPB_ALIGN_SIZE "\n" \
112-
"__OBJC_$_CLASS_METHODS_" GPBStringifySymbol(name) ": \n" \
113-
".long 3 *" GPB_ASM_PTRSIZE "\n" \
114-
".long 0x1 \n" \
115-
GPB_ASM_PTR "L_GBPDescriptorMethodName \n" \
116-
GPB_ASM_PTR "L_GPBDescriptorMethodType \n" \
117-
GPB_ASM_PTR "_" #descriptorFunc " \n" \
118-
\
119-
".section __DATA,__objc_const, regular \n" \
120-
".p2align" GPB_ALIGN_SIZE "\n" \
121-
"__OBJC_METACLASS_RO_$_" GPBStringifySymbol(name) ": \n" \
122-
".long" GPB_METACLASS_FLAGS "\n" \
123-
".long 5 *" GPB_ASM_PTRSIZE "\n" \
124-
".long 5 *" GPB_ASM_PTRSIZE "\n" \
125-
GPB_ASM_ONLY_LP64(".space 4 \n") \
126-
GPB_ASM_PTR "0 \n" \
127-
GPB_ASM_PTR "L_OBJC_CLASS_NAME_" GPBStringifySymbol(name) " \n" \
128-
GPB_ASM_PTR "__OBJC_$_CLASS_METHODS_" GPBStringifySymbol(name) " \n" \
129-
GPB_ASM_PTR "0 \n" \
130-
GPB_ASM_PTR "0 \n" \
131-
GPB_ASM_PTR "0 \n" \
132-
GPB_ASM_PTR "0 \n" \
133-
\
134-
".section __DATA,__objc_const, regular \n" \
135-
".p2align" GPB_ALIGN_SIZE "\n" \
136-
"__OBJC_CLASS_RO_$_" GPBStringifySymbol(name) ": \n" \
137-
".long" GPB_CLASS_FLAGS "\n" \
138-
".long" GPB_ASM_PTRSIZE "\n" \
139-
".long" GPB_ASM_PTRSIZE "\n" \
140-
GPB_ASM_ONLY_LP64(".long 0 \n") \
141-
GPB_ASM_PTR "0 \n" \
142-
GPB_ASM_PTR "L_OBJC_CLASS_NAME_" GPBStringifySymbol(name) " \n" \
143-
GPB_ASM_PTR "0 \n" \
144-
GPB_ASM_PTR "0 \n" \
145-
GPB_ASM_PTR "0 \n" \
146-
GPB_ASM_PTR "0 \n" \
147-
GPB_ASM_PTR "0 \n" \
148-
\
149-
".globl _OBJC_METACLASS_$_" GPBStringifySymbol(name) "\n" \
150-
".section __DATA,__objc_data, regular \n" \
151-
".p2align" GPB_ALIGN_SIZE "\n" \
152-
"_OBJC_METACLASS_$_" GPBStringifySymbol(name) ": \n" \
153-
GPB_ASM_PTR "_OBJC_METACLASS_$_NSObject \n" \
154-
GPB_ASM_PTR "_OBJC_METACLASS_$_" GPB_MESSAGE_CLASS_NAME " \n" \
155-
GPB_ASM_PTR "__objc_empty_cache \n" \
156-
GPB_ASM_PTR "0 \n" \
157-
GPB_ASM_PTR "__OBJC_METACLASS_RO_$_" GPBStringifySymbol(name) " \n" \
158-
\
159-
".globl _OBJC_CLASS_$_" GPBStringifySymbol(name) "\n" \
160-
".section __DATA,__objc_data, regular \n" \
161-
".p2align" GPB_ALIGN_SIZE "\n" \
162-
"_OBJC_CLASS_$_" GPBStringifySymbol(name) ": \n" \
163-
GPB_ASM_PTR "_OBJC_METACLASS_$_" GPBStringifySymbol(name) " \n" \
164-
GPB_ASM_PTR "_OBJC_CLASS_$_" GPB_MESSAGE_CLASS_NAME " \n" \
165-
GPB_ASM_PTR "__objc_empty_cache \n" \
166-
GPB_ASM_PTR "0 \n" \
167-
GPB_ASM_PTR "__OBJC_CLASS_RO_$_" GPBStringifySymbol(name) " \n" \
168-
\
169-
".section __DATA, __objc_classlist, regular, no_dead_strip \n" \
170-
".p2align" GPB_ALIGN_SIZE "\n" \
171-
"_OBJC_LABEL_CLASS_$" GPBStringifySymbol(name) ": \n" \
172-
GPB_ASM_PTR "_OBJC_CLASS_$_" GPBStringifySymbol(name) " \n" \
173-
)
174-
17545
typedef struct GPBMessage_Storage {
17646
uint32_t _has_storage_[0];
17747
} GPBMessage_Storage;

0 commit comments

Comments
 (0)