Make remaining objc test jobs to pass on MacOS monterey (#32493)

Make remaining objC jobs compatible with kokoro monterey workers and
prepare for boringssl upgrade.

The changes here are taken from https://github.com/grpc/grpc/pull/32357,
but they should be merged in a separate PR
(we need the changes to be able to upgrade to monterey anyway and
there's no reason to make the boringssl upgrade PR more complicated by
bundling more fixes into it).

I've checked that the grpc_basictests_objc_examples and
grpc_ios_binary_size are green if switched to monterey.
Unfortunately it's hard to make grpc_basictests_objc_examples pass on
both monterey and mojave, so I suggest merging this PR at the same time
as CL to upgrade the kokoro jobs to monterey.
- that way both PR and continuous runs will remain green
- older branches would need a backport anyway

---------

Co-authored-by: Hannah Shi <hannahshisfb@gmail.com>
pull/32507/head
Jan Tattermusch 2 years ago committed by GitHub
parent 649de744a6
commit 740932c899
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 55
      src/objective-c/BoringSSL-GRPC.podspec
  2. 5
      src/objective-c/examples/InterceptorSample/Podfile
  3. 33
      src/objective-c/examples/RemoteTestClient/RemoteTest.podspec
  4. 5
      src/objective-c/examples/Sample/Podfile
  5. 2
      src/objective-c/examples/SwiftSample/Podfile
  6. 1
      src/objective-c/examples/SwiftSample/ViewController.swift
  7. 2
      src/objective-c/examples/tvOS-sample/Podfile
  8. 2
      src/objective-c/examples/watchOS-sample/Podfile
  9. 55
      templates/src/objective-c/BoringSSL-GRPC.podspec.template
  10. 2
      tools/internal_ci/helper_scripts/prepare_build_macos_rc
  11. 123
      tools/profiling/ios_bin/binary_size.py
  12. 5
      tools/run_tests/run_tests.py

@ -103,11 +103,6 @@ Pod::Spec.new do |s|
# following lets users write `#include <openssl/ssl.h>`.
s.header_dir = name
# The module map and umbrella header created automatically by Cocoapods don't work for C libraries
# like this one. The following file, and a correct umbrella header, are created on the fly by the
# `prepare_command` of this pod.
s.module_map = 'src/include/openssl/BoringSSL.modulemap'
# We don't need to inhibit all warnings; only -Wno-shorten-64-to-32. But Cocoapods' linter doesn't
# want that for some reason.
s.compiler_flags = '-DOPENSSL_NO_ASM', '-GCC_WARN_INHIBIT_ALL_WARNINGS', '-w', '-DBORINGSSL_PREFIX=GRPC'
@ -153,56 +148,6 @@ Pod::Spec.new do |s|
s.prepare_command = <<-END_OF_COMMAND
set -e
# Add a module map and an umbrella header
mkdir -p src/include/openssl
cat > src/include/openssl/umbrella.h <<EOF
#include "ssl.h"
#include "crypto.h"
#include "aes.h"
/* The following macros are defined by base.h. The latter is the first file included by the
other headers. */
#if defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64)
# include "arm_arch.h"
#endif
#include "asn1.h"
#include "asn1_mac.h"
#include "asn1t.h"
#include "blowfish.h"
#include "cast.h"
#include "chacha.h"
#include "cmac.h"
#include "conf.h"
#include "cpu.h"
#include "curve25519.h"
#include "des.h"
#include "dtls1.h"
#include "hkdf.h"
#include "md4.h"
#include "md5.h"
#include "obj_mac.h"
#include "objects.h"
#include "opensslv.h"
#include "ossl_typ.h"
#include "pkcs12.h"
#include "pkcs7.h"
#include "pkcs8.h"
#include "poly1305.h"
#include "rand.h"
#include "rc4.h"
#include "ripemd.h"
#include "safestack.h"
#include "srtp.h"
#include "x509.h"
#include "x509v3.h"
EOF
cat > src/include/openssl/BoringSSL.modulemap <<EOF
framework module openssl {
umbrella header "umbrella.h"
textual header "arm_arch.h"
export *
module * { export * }
}
EOF
# To avoid symbol conflict with OpenSSL, gRPC needs to rename all the BoringSSL symbols with a
# prefix. This is done with BoringSSL's BORINGSSL_PREFIX mechanism

@ -2,11 +2,6 @@ platform :ios, '9.0'
install! 'cocoapods', :deterministic_uuids => false
# Default to use framework, so that providing no 'FRAMEWORK' env parameter works consistently
# for all Samples, specifically because Swift only supports framework.
# Only effective for examples/
use_frameworks! if ENV['FRAMEWORKS'] != 'NO'
ROOT_DIR = '../../../..'
target 'InterceptorSample' do

@ -24,30 +24,15 @@ Pod::Spec.new do |s|
# Since we switched to importing full path, -I needs to be set to the directory
# from which the imported file can be found, which is the grpc's root here
if ENV['FRAMEWORKS'] != 'NO' then
s.user_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'USE_FRAMEWORKS=1' }
s.prepare_command = <<-CMD
# Cannot find file if using *.proto. Maybe files' paths must match the -I flags
#{protoc} \
--plugin=protoc-gen-grpc=#{plugin} \
--objc_out=. \
--grpc_out=generate_for_named_framework=#{s.name}:. \
--objc_opt=generate_for_named_framework=#{s.name} \
-I #{repo_root} \
-I #{well_known_types_dir} \
#{repo_root}/src/objective-c/examples/RemoteTestClient/*.proto
CMD
else
s.prepare_command = <<-CMD
#{protoc} \
--plugin=protoc-gen-grpc=#{plugin} \
--objc_out=. \
--grpc_out=. \
-I #{repo_root} \
-I #{well_known_types_dir} \
#{repo_root}/src/objective-c/examples/RemoteTestClient/*.proto
CMD
end
s.prepare_command = <<-CMD
#{protoc} \
--plugin=protoc-gen-grpc=#{plugin} \
--objc_out=. \
--grpc_out=. \
-I #{repo_root} \
-I #{well_known_types_dir} \
#{repo_root}/src/objective-c/examples/RemoteTestClient/*.proto
CMD
s.subspec 'Messages' do |ms|
ms.source_files = 'src/objective-c/examples/RemoteTestClient/*.pbobjc.{h,m}'

@ -3,11 +3,6 @@ platform :ios, '9.0'
install! 'cocoapods', :deterministic_uuids => false
# Default to use framework, so that providing no 'FRAMEWORK' env parameter works consistently
# for all Samples, specifically because Swift only supports framework.
# Only effective for examples/
use_frameworks! if ENV['FRAMEWORKS'] != 'NO'
# Location of gRPC's repo root relative to this file.
GRPC_LOCAL_SRC = '../../../..'

@ -3,7 +3,7 @@ platform :ios, '9.0'
install! 'cocoapods', :deterministic_uuids => false
use_frameworks!
use_modular_headers!
# Location of gRPC's repo root relative to this file.
GRPC_LOCAL_SRC = '../../../..'

@ -19,6 +19,7 @@
import UIKit
import RemoteTest
import RxLibrary
class ViewController: UIViewController {

@ -2,8 +2,6 @@ platform :tvos, '10.0'
install! 'cocoapods', :deterministic_uuids => false
use_frameworks! if ENV['FRAMEWORKS'] != 'NO'
ROOT_DIR = '../../../..'
target 'tvOS-sample' do

@ -1,7 +1,5 @@
install! 'cocoapods', :deterministic_uuids => false
use_frameworks! if ENV['FRAMEWORKS'] != 'NO'
ROOT_DIR = '../../../..'
def grpc_deps

@ -133,11 +133,6 @@
# following lets users write `#include <openssl/ssl.h>`.
s.header_dir = name
# The module map and umbrella header created automatically by Cocoapods don't work for C libraries
# like this one. The following file, and a correct umbrella header, are created on the fly by the
# `prepare_command` of this pod.
s.module_map = 'src/include/openssl/BoringSSL.modulemap'
# We don't need to inhibit all warnings; only -Wno-shorten-64-to-32. But Cocoapods' linter doesn't
# want that for some reason.
s.compiler_flags = '-DOPENSSL_NO_ASM', '-GCC_WARN_INHIBIT_ALL_WARNINGS', '-w', '-DBORINGSSL_PREFIX=GRPC'
@ -183,56 +178,6 @@
s.prepare_command = <<-END_OF_COMMAND
set -e
# Add a module map and an umbrella header
mkdir -p src/include/openssl
cat > src/include/openssl/umbrella.h <<EOF
#include "ssl.h"
#include "crypto.h"
#include "aes.h"
/* The following macros are defined by base.h. The latter is the first file included by the
other headers. */
#if defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64)
# include "arm_arch.h"
#endif
#include "asn1.h"
#include "asn1_mac.h"
#include "asn1t.h"
#include "blowfish.h"
#include "cast.h"
#include "chacha.h"
#include "cmac.h"
#include "conf.h"
#include "cpu.h"
#include "curve25519.h"
#include "des.h"
#include "dtls1.h"
#include "hkdf.h"
#include "md4.h"
#include "md5.h"
#include "obj_mac.h"
#include "objects.h"
#include "opensslv.h"
#include "ossl_typ.h"
#include "pkcs12.h"
#include "pkcs7.h"
#include "pkcs8.h"
#include "poly1305.h"
#include "rand.h"
#include "rc4.h"
#include "ripemd.h"
#include "safestack.h"
#include "srtp.h"
#include "x509.h"
#include "x509v3.h"
EOF
cat > src/include/openssl/BoringSSL.modulemap <<EOF
framework module openssl {
umbrella header "umbrella.h"
textual header "arm_arch.h"
export *
module * { export * }
}
EOF
# To avoid symbol conflict with OpenSSL, gRPC needs to rename all the BoringSSL symbols with a
# prefix. This is done with BoringSSL's BORINGSSL_PREFIX mechanism

@ -99,7 +99,7 @@ then
# cocoapods
export LANG=en_US.UTF-8
# use "sudo" to avoid permission error on kokoro monterey image
time sudo gem install cocoapods --version 1.7.2 --no-document --user-install
time sudo gem install cocoapods --version 1.11.3 --no-document --user-install
# pre-fetch cocoapods master repo's most recent commit only
mkdir -p ~/.cocoapods/repos
time git clone --depth 1 https://github.com/CocoaPods/Specs.git ~/.cocoapods/repos/master

@ -54,36 +54,19 @@ def dir_size(dir):
return total
def get_size(where, frameworks):
def get_size(where):
build_dir = 'src/objective-c/examples/Sample/Build/Build-%s/' % where
if not frameworks:
link_map_filename = 'Build/Intermediates.noindex/Sample.build/Release-iphoneos/Sample.build/Sample-LinkMap-normal-arm64.txt'
# IMPORTANT: order needs to match labels in _SIZE_LABELS
return parse_link_map(build_dir + link_map_filename)
else:
framework_dir = 'Build/Products/Release-iphoneos/Sample.app/Frameworks/'
core_size = dir_size(build_dir + framework_dir + 'grpc.framework')
objc_size = dir_size(build_dir + framework_dir + 'GRPCClient.framework') + \
dir_size(build_dir + framework_dir + 'RxLibrary.framework') + \
dir_size(build_dir + framework_dir + 'ProtoRPC.framework')
boringssl_size = dir_size(build_dir + framework_dir +
'openssl.framework')
protobuf_size = dir_size(build_dir + framework_dir +
'Protobuf.framework')
# a.k.a. "Total"
app_size = dir_size(build_dir +
'Build/Products/Release-iphoneos/Sample.app')
# IMPORTANT: order needs to match labels in _SIZE_LABELS
return core_size, objc_size, boringssl_size, protobuf_size, app_size
def build(where, frameworks):
link_map_filename = 'Build/Intermediates.noindex/Sample.build/Release-iphoneos/Sample.build/Sample-LinkMap-normal-arm64.txt'
# IMPORTANT: order needs to match labels in _SIZE_LABELS
return parse_link_map(build_dir + link_map_filename)
def build(where):
subprocess.check_call(['make', 'clean'])
shutil.rmtree('src/objective-c/examples/Sample/Build/Build-%s' % where,
ignore_errors=True)
subprocess.check_call(
'CONFIG=opt EXAMPLE_PATH=src/objective-c/examples/Sample SCHEME=Sample FRAMEWORKS=%s ./build_one_example.sh'
% ('YES' if frameworks else 'NO'),
'CONFIG=opt EXAMPLE_PATH=src/objective-c/examples/Sample SCHEME=Sample ./build_one_example.sh',
shell=True,
cwd='src/objective-c/tests')
os.rename('src/objective-c/examples/Sample/Build/Build',
@ -119,57 +102,55 @@ def _diff_sign(new, old, diff_threshold=None):
text = 'Objective-C binary sizes\n'
for frameworks in [False, True]:
build('new', frameworks)
new_size = get_size('new', frameworks)
old_size = None
if args.diff_base:
old = 'old'
where_am_i = subprocess.check_output(
['git', 'rev-parse', '--abbrev-ref', 'HEAD']).decode().strip()
build('new')
new_size = get_size('new')
old_size = None
if args.diff_base:
old = 'old'
where_am_i = subprocess.check_output(
['git', 'rev-parse', '--abbrev-ref', 'HEAD']).decode().strip()
subprocess.check_call(['git', 'checkout', '--', '.'])
subprocess.check_call(['git', 'checkout', args.diff_base])
subprocess.check_call(['git', 'submodule', 'update', '--force'])
try:
build('old')
old_size = get_size('old')
finally:
subprocess.check_call(['git', 'checkout', '--', '.'])
subprocess.check_call(['git', 'checkout', args.diff_base])
subprocess.check_call(['git', 'checkout', where_am_i])
subprocess.check_call(['git', 'submodule', 'update', '--force'])
try:
build('old', frameworks)
old_size = get_size('old', frameworks)
finally:
subprocess.check_call(['git', 'checkout', '--', '.'])
subprocess.check_call(['git', 'checkout', where_am_i])
subprocess.check_call(['git', 'submodule', 'update', '--force'])
text += ('********************FRAMEWORKS****************\n' if frameworks
else '**********************STATIC******************\n')
text += _render_row('New size', '', 'Old size')
if old_size == None:
for i in range(0, len(_SIZE_LABELS)):
if i == len(_SIZE_LABELS) - 1:
# skip line before rendering "Total"
text += '\n'
text += _render_row(new_size[i], _SIZE_LABELS[i], '')
else:
has_diff = False
# go through all labels but "Total"
for i in range(0, len(_SIZE_LABELS) - 1):
if abs(new_size[i] - old_size[i]) >= _DIFF_THRESHOLD:
has_diff = True
diff_sign = _diff_sign(new_size[i],
old_size[i],
diff_threshold=_DIFF_THRESHOLD)
text += _render_row(new_size[i], _SIZE_LABELS[i] + diff_sign,
old_size[i])
# render the "Total"
i = len(_SIZE_LABELS) - 1
diff_sign = _diff_sign(new_size[i], old_size[i])
# skip line before rendering "Total"
text += '\n'
text += '**********************STATIC******************\n'
text += _render_row('New size', '', 'Old size')
if old_size == None:
for i in range(0, len(_SIZE_LABELS)):
if i == len(_SIZE_LABELS) - 1:
# skip line before rendering "Total"
text += '\n'
text += _render_row(new_size[i], _SIZE_LABELS[i], '')
else:
has_diff = False
# go through all labels but "Total"
for i in range(0, len(_SIZE_LABELS) - 1):
if abs(new_size[i] - old_size[i]) >= _DIFF_THRESHOLD:
has_diff = True
diff_sign = _diff_sign(new_size[i],
old_size[i],
diff_threshold=_DIFF_THRESHOLD)
text += _render_row(new_size[i], _SIZE_LABELS[i] + diff_sign,
old_size[i])
if not has_diff:
text += '\n No significant differences in binary sizes\n'
# render the "Total"
i = len(_SIZE_LABELS) - 1
diff_sign = _diff_sign(new_size[i], old_size[i])
# skip line before rendering "Total"
text += '\n'
text += _render_row(new_size[i], _SIZE_LABELS[i] + diff_sign, old_size[i])
if not has_diff:
text += '\n No significant differences in binary sizes\n'
text += '\n'
print(text)

@ -967,18 +967,15 @@ class ObjCLanguage(object):
def test_specs(self):
out = []
# Currently not supporting compiling as frameworks in Bazel
# TODO(jtattermusch): verify the above claim is still accurate.
out.append(
self.config.job_spec(
['src/objective-c/tests/build_one_example.sh'],
timeout_seconds=20 * 60,
shortname='ios-buildtest-example-sample-frameworks',
shortname='ios-buildtest-example-sample',
cpu_cost=1e6,
environ={
'SCHEME': 'Sample',
'EXAMPLE_PATH': 'src/objective-c/examples/Sample',
'FRAMEWORKS': 'YES'
}))
# TODO(jtattermusch): Create bazel target for the sample and remove the test task from here.
out.append(

Loading…
Cancel
Save