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

Also strip Swift symbols when --objc_enable_binary_stripping is passed #13123

Conversation

thii
Copy link
Member

@thii thii commented Feb 26, 2021

Resolves #13122

@google-cla google-cla bot added the cla: yes label Feb 26, 2021
@@ -1567,7 +1567,7 @@ private void registerBinaryStripAction(Artifact binaryToLink, StrippingType stri
stripArgs = ImmutableList.of("-x");
break;
case DEFAULT:
stripArgs = ImmutableList.<String>of();
stripArgs = ImmutableList.of("-x", "-T");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kinda surprised -x wasn't here before

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, you guys sure -x belongs in the stripping of executables?

My impression was that one only wanted -x for dynamically loaded libraries (dylibs/kexts/loadable bundles) to preserve the global symbols needed to export an ABI from. From the strip man page, I'd guess you might want ("-u", "-r" instead for executables--and that that'd strip all the unneeded symbols?

Would you want to also strip Swift symbols in dynamically loaded libraries? (switch case immediately above) Apologies if I'm missing something--it's not clear to me what makes swift symbols special during the stripping process. Just ran across this while adding the -x case to fix loadable bundles in #13314

@thii thii marked this pull request as ready for review February 26, 2021 23:43
@thii thii requested a review from lberki as a code owner February 26, 2021 23:43
@jin jin requested a review from allevato March 1, 2021 06:14
@lberki lberki removed their request for review March 1, 2021 07:25
@jin jin added team-Rules-CPP Issues for C++ rules z-team-Apple Deprecated. Send to rules_apple, or label team-Rules-CPP + platform:apple labels Mar 1, 2021
@jin
Copy link
Member

jin commented Mar 1, 2021

cc @trybka

@allevato
Copy link
Member

allevato commented Mar 1, 2021

I'll defer to @trybka on this one. We've discussed in the past that this flag is fundamentally broken because it conflates two meanings of "strip" (symbols and dead code stripping) and has other side effects on top of that; I'm not sure if adding more behavior to this already broken flag is the right thing to do or if it would have other undesirable side effects.

@DavidGoldman
Copy link
Contributor

Would it make sense to file a radar/feedback for what API we would need from strip?

@allevato
Copy link
Member

allevato commented Mar 1, 2021

Would it make sense to file a radar/feedback for what API we would need from strip?

Not sure I follow. When I say "this flag" I'm referring to --objc_enable_binary_stripping—I don't see anything here that needs Apple's attention. The problem is the single flag in Bazel that combines too many unrelated behaviors, and this PR would add more behavior to that.

@trybka
Copy link
Contributor

trybka commented Mar 1, 2021

+cc @jyknight

@trybka
Copy link
Contributor

trybka commented Mar 1, 2021

--objc_enable_binary_stripping is a confusing flag that conflates at least two meanings of "strip" and also has other side effects. Dead code elimination happens at link time, and a debugging symbol strip action is registered for final executable links.

We'd like to eliminate it altogether, but there are some... complications.
I'm going to look into externalizing an internal doc I have on the matter to provide additional context.
As such, I'm hesitant to add more meaning to it (i.e. having it affect Swift, too).

It's not clear what exactly to do here--but I think that the hard-coded action created by the ObjC rules should go away.

-x might be fine, but in practice doesn't remove most symbols, because they are all defaulted to dynamically exported.

@keith
Copy link
Member

keith commented Mar 1, 2021

If this isn't the right path I wonder if we should make --stripopt or something apply to this strip logic too so folks can do something to solve this

@trybka
Copy link
Contributor

trybka commented Mar 24, 2021

@trybka
Copy link
Contributor

trybka commented Mar 24, 2021

I think it would be sensible to make this register a strip action like cc_binary does, and then the options can be configured in the Crosstool.

@steeve
Copy link
Contributor

steeve commented Sep 22, 2021

Jumping on this, emergetools.com actually recommends -rSTx -no_code_signature_warning for all binaries.

@keith
Copy link
Member

keith commented Mar 3, 2022

Please checkout #14951

@sgowroji sgowroji added the awaiting-review PR is awaiting review from an assigned reviewer label Oct 19, 2022
@oquenchil oquenchil added team-Rules-ObjC Issues for Objective-C maintainers and removed team-Rules-CPP Issues for C++ rules labels Dec 16, 2022
@keertk
Copy link
Member

keertk commented Mar 22, 2023

Hi @googlewalt, was doing some checks of unmerged PRs and wanted to see if this one is still needed and good to be approved/merged internally?

@thii
Copy link
Member Author

thii commented Mar 23, 2023

Closing in favor of a more proper solution at #14951.

@thii thii closed this Mar 23, 2023
@thii thii deleted the also-strip-swift-symbols-when-objc_enable_binary_stripping-is-passed branch March 23, 2023 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review PR is awaiting review from an assigned reviewer cla: yes team-Rules-ObjC Issues for Objective-C maintainers z-team-Apple Deprecated. Send to rules_apple, or label team-Rules-CPP + platform:apple
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support stripping Swift symbols