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

Add oso_prefix_is_pwd macOS feature #11671

Closed

Conversation

keith
Copy link
Member

@keith keith commented Jun 29, 2020

With Xcode 11 Apple's linker introduced a new oso_prefix option which
removes the given prefix from the path in debug info. This improves the
goal of producing reproducible builds.

More info: https://milen.me/writings/apple-linker-ld64-deterministic-builds-oso-prefix

RELNOTES: Add opt in 'oso_prefix_is_pwd' feature for Apple builds

With Xcode 11 Apple's linker introduced a new oso_prefix option which
removes the given prefix from the path in debug info. This improves the
goal of producing reproducible builds.

More info: https://milen.me/writings/apple-linker-ld64-deterministic-builds-oso-prefix
@keith
Copy link
Member Author

keith commented Jun 29, 2020

If there's a better way to do this type of feature that requires a specific Xcode version I'm happy to change this, but I figured it being opt in is probably "good enough" (although it's possible we want to join it with -fdebug-prefix-map's logic

flag_sets = [
flag_set(
actions = all_link_actions +
["objc-executable", "objc++-executable"],
Copy link
Contributor

Choose a reason for hiding this comment

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

will this flag apply to executables without any objc as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

@michaeleisel
Copy link
Contributor

what's the status of debug-prefix-map in bazel? since it requires that each compile invocation change based on the path, as opposed to just the link invocation, does it invalidate any bazel caches for that reason?

otherwise, i haven't tested this linker flag myself but this look sound overall

@keith
Copy link
Member Author

keith commented Jun 30, 2020

Both debug-prefix-map and this one are "hidden" in the clang wrapper, so the command line is stable, and the wrapper resolves and puts the arbitrary path in the actually invocation (rules_swift does something similar too) so they don't invalidate any caches.

@michaeleisel
Copy link
Contributor

👍

@jin jin requested a review from allevato July 13, 2020 14:32
@jin jin added the z-team-Apple Deprecated. Send to rules_apple, or label team-Rules-CPP + platform:apple label Jul 13, 2020
@jin
Copy link
Member

jin commented Jul 13, 2020

+@allevato this seems like a useful thing to have, and I don't see it set up in internal toolchains.

@jin jin assigned jin and jmmv and unassigned jin Jul 13, 2020
@jin jin requested a review from jmmv July 13, 2020 14:35
@allevato
Copy link
Member

@googlewalt @trybka

@allevato allevato requested a review from googlewalt July 13, 2020 15:38
@trybka
Copy link
Contributor

trybka commented Jul 13, 2020

+@allevato this seems like a useful thing to have, and I don't see it set up in internal toolchains.

We are tracking this internally.

@keith
Copy link
Member Author

keith commented Jul 13, 2020

Even if this was fixed internally that wouldn't apply to the public crosstool correct?

@trybka
Copy link
Contributor

trybka commented Jul 13, 2020

Even if this was fixed internally that wouldn't apply to the public crosstool correct?

Correct. Not at this time. This change seems fine.

@keith
Copy link
Member Author

keith commented Jul 13, 2020

Is this aligned with how it would work with the internal crosstool? It doesn't sound like that's happening anymore but if there's a small change I could make to be more in line with that I'd be happy to!

@trybka
Copy link
Contributor

trybka commented Jul 13, 2020

Yes, I think this is how it would be handled. wrapped_clang needs to set this because we don't know pwd until the compile/link is executing on the machine.

@jin
Copy link
Member

jin commented Jul 13, 2020

@trybka I'll import this for your review.

@bazel-io bazel-io closed this in 930424b Jul 14, 2020
@keith
Copy link
Member Author

keith commented Jul 14, 2020

Thanks!!

@keith keith deleted the ks/add-oso_prefix_is_pwd-macos-feature branch September 25, 2020 19:38
bazel-io pushed a commit that referenced this pull request Oct 19, 2021
Expands the targeted actions to allow stripping the absolute build path for debug symbols from all libraries.  The support in wrapped_clang is indifferent to whether we are linking a true objc or regular cpp library.

When used in concert with `--features=oso_prefix_is_pwd --remote_download_outputs=all`, allows successful local debugging of executables/libraries built remotely.  Probably also helps with sandboxed actions.

Helps mitigate #6327 and kinda sorta #2537?  See also #11671

Closes #13311.

PiperOrigin-RevId: 404262861
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes 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.

7 participants