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

Make Xcode version accessible to aspects #17871

Closed
blorente opened this issue Mar 23, 2023 · 2 comments
Closed

Make Xcode version accessible to aspects #17871

blorente opened this issue Mar 23, 2023 · 2 comments
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Rules-CPP Issues for C++ rules type: feature request

Comments

@blorente
Copy link

Description of the feature request:

For reasons outlined in the following sections, I want to fetch the Xcode version from an aspect. In normal build-land, a cc_* target would get the xcode version via the cc toolchain:

bazel cquery 'somepath(//src/lib:greeting_lib,  @local_config_xcode//:host_xcodes)'
//src/lib:greeting_lib (602a7de)
@bazel_tools//tools/cpp:current_cc_toolchain (602a7de)
@bazel_tools//tools/cpp:toolchain (602a7de)
@local_config_cc//:toolchain (602a7de)
@local_config_cc//:cc-compiler-tvos_sim_arm64 (602a7de)
@bazel_tools//tools/cpp:host_xcodes (602a7de)
@local_config_xcode//:host_xcodes (602a7de)

I have gotten the aspect to propagate up to the right target via the _xcode_config attribute, but I can't get it to pass the relevant information down.

This is the aspect: https://gist.github.com/blorente/95f74405142d5a2364909950e505e79d
And the output of running it on roughly any cc_* target: https://gist.github.com/blorente/296e5fd4bb9eec22299eaa0204dc13f3

As far as I can see, the fundamental pain point here is that the toolchains attribute of cc_toolchain_suite is a LABEL_DICT_UNARY, according to Bazel source code. This is not one of the "dependency attributes", according to Bazel docs. And so I can't really get the deps outputs from @local_config_cc//:toolchain to pass downstream (see this comment).

Therefore, I'd like a way to figure out which version of Xcode a particular cc toolchain is using from an aspect.

What underlying problem are you trying to solve with this feature?

I'm working on the CLion plugin. It uses an aspect to gather build configuration for each target, as well as about the toolchains configured (e.g. the CcToolchainInfo), which is then passed to the plugin to translate into the IDE's model of the world.

One such information we need is the CC compiler. Via CcToolchainInfo we're able to get the clang wrapper script, which we can pass to CLion as "the compiler to use to implement your smarts". This is correct behavior. However, that script has a baked-in assumption that it'll have DEVELOPER_DIR and SDKROOT set.

In Bazel, those are set roughly by querying @local_config_xcode//:host_xcodes (or equivalent) to get the xcode version, and then running xcode-locator -v <that version> to get the right DEVELOPER_DIR.

I want to replicate that behaviour in the compiler we give to CLion.

Which operating system are you running Bazel on?

macOS, arm

What is the output of bazel info release?

Tested with 6.0.0 and 5.4.0

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

No response

Have you found anything relevant by searching the web?

I have googled and searched the GitHub issues, to no avail. Asked in the upstream slack with no success.

Any other information, logs, or outputs that you want to share?

No response

@ShreeM01 ShreeM01 added team-Rules-ObjC Issues for Objective-C maintainers team-Rules-CPP Issues for C++ rules and removed team-Rules-ObjC Issues for Objective-C maintainers labels Mar 23, 2023
@buildbreaker2021 buildbreaker2021 added P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed untriaged labels Apr 3, 2023
Copy link

github-actions bot commented Jun 7, 2024

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 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label Jun 7, 2024
@blorente
Copy link
Author

I think this is done in the PR linked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Rules-CPP Issues for C++ rules type: feature request
Projects
None yet
Development

No branches or pull requests

3 participants