bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
22.97k stars 4.03k forks source link

Support stripping Swift symbols #13122

Open thii opened 3 years ago

thii commented 3 years ago

Description of the problem / feature request:

Support stripping Swift symbols for binaries built for Apple platforms.

Feature requests: what underlying problem are you trying to solve with this feature?

There's currently no option to allow stripping Swift symbols for binaries built for Apple platforms. Since xcodebuild's ipa exporting supports that (and defaults to YES), results in binaries produced by Bazel has a slightly larger size compared to Xcode's.

What operating system are you running Bazel on?

macOS

What's the output of bazel info release?

release 4.0.0

Have you found anything relevant by searching the web?

From the strip man page:

-T
The intent of this flag is to remove Swift symbols. It removes the symbols whose names
begin with `_$S' or `_$s' only when it finds an __objc_imageinfo section with and it has
a non-zero swift version. The future the implementation of this flag may change to match the intent.

From the xcodebuild -h page:

Available keys for -exportOptionsPlist:
        ...
        stripSwiftSymbols : Bool

                Should symbols be stripped from Swift libraries in your IPA? Defaults to YES.

I found two code paths referencing to code stripping but -T is not passed, and passing it via --stripopt doesn't take effect.

https://github.com/bazelbuild/bazel/blob/25768512a6c30cdc6af3098078ef02375fd5c914/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java#L1561-L1574

https://github.com/bazelbuild/bazel/blob/ef903e08b270f3fa3c4d36f8122876a892b47087/tools/osx/crosstool/cc_toolchain_config.bzl#L296-L311

jin commented 3 years ago

@susinmotion how should we route ObjC rules issues like this one?

keith commented 3 years ago

https://github.com/bazelbuild/bazel/pull/13123

susinmotion commented 3 years ago

@jin you did exactly the right thing!

github-actions[bot] commented 1 year ago

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.