Skip to content
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

Support stripping Swift symbols #13122

Open
thii opened this issue Feb 26, 2021 · 4 comments
Open

Support stripping Swift symbols #13122

thii opened this issue Feb 26, 2021 · 4 comments
Labels
not stale Issues or PRs that are inactive but not considered stale P3 We're not considering working on this, but happy to review a PR. (No assignee) platform: apple team-Rules-CPP Issues for C++ rules type: feature request

Comments

@thii
Copy link
Member

thii commented Feb 26, 2021

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.

private void registerBinaryStripAction(Artifact binaryToLink, StrippingType strippingType) {
final ImmutableList<String> stripArgs;
switch (strippingType) {
case DYNAMIC_LIB:
case KERNEL_EXTENSION:
// For dylibs and kexts, must strip only local symbols.
stripArgs = ImmutableList.of("-x");
break;
case DEFAULT:
stripArgs = ImmutableList.<String>of();
break;
default:
throw new IllegalArgumentException("Unsupported stripping type " + strippingType);
}

strip_action = action_config(
action_name = ACTION_NAMES.strip,
flag_sets = [
flag_set(
flag_groups = [
flag_group(flags = ["-S", "-o", "%{output_file}"]),
flag_group(
flags = ["%{stripopts}"],
iterate_over = "stripopts",
),
flag_group(flags = ["%{input_file}"]),
],
),
],
tools = [tool(path = "/usr/bin/strip")],
)

@jin
Copy link
Member

jin commented Mar 1, 2021

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

@keith
Copy link
Member

keith commented Mar 1, 2021

#13123

@susinmotion
Copy link
Contributor

@jin you did exactly the right thing!

@oquenchil oquenchil added P3 We're not considering working on this, but happy to review a PR. (No assignee) type: feature request and removed untriaged labels May 10, 2021
@github-actions
Copy link

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.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label May 10, 2023
@thii thii added not stale Issues or PRs that are inactive but not considered stale and removed stale Issues or PRs that are stale (no activity for 30 days) labels May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not stale Issues or PRs that are inactive but not considered stale P3 We're not considering working on this, but happy to review a PR. (No assignee) platform: apple team-Rules-CPP Issues for C++ rules type: feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants