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

Replace hard-coded -g0 flags with a feature that can be used in the toolchain configuration. #13308

Open
chandlerc opened this issue Apr 7, 2021 · 14 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) team-Rules-CPP Issues for C++ rules type: feature request

Comments

@chandlerc
Copy link

Just stumbled across some lingering hard-coded compiler flags:

coptListBuilder.add("-g0");
cxxoptListBuilder.add("-g0");

Could these be removed?

Specifically, it'd be nice to have a feature similar to opt and fastbuild that can be used as a condition to enable flags specifically in the host build. Ideally, I would suggest host. This would cause the host build to enable both opt and host features. And in turn, the crosstool configuration could disable debug info in the host build even if it would be enabled as part of the opt build for the target.

I noticed this because as implemented, the code actually adds -g0 twice.

@hlopko
Copy link
Member

hlopko commented Apr 20, 2021

AFAIK if there is a feature named host it will be enabled by Bazel for host configuration. It certainly did work in the past - @oquenchil is that still true?

@hlopko
Copy link
Member

hlopko commented Apr 20, 2021

Yup it seems we use host and nonhost internally.

@hlopko
Copy link
Member

hlopko commented Apr 20, 2021

So I think @chandlerc can implement what they need. It would still be great if Bazel didn't add -g0, it seems it's one of the very few remaining hardcoded flags.

@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
@sgadrian
Copy link

sgadrian commented May 24, 2021

I have custom rules that use the attribute parameter cfg="host" documented here:

https://docs.bazel.build/versions/master/skylark/rules.html#configurations

and these unexpected added -g0 flags is also present when I try to use the --host_compilation_mode=dbg. I was expecting to get debug information in my host build but was not.

@hlopko
Copy link
Member

hlopko commented Aug 10, 2021

Oh I was very wrong! It turns out incompatible_dont_enable_host_nonhost_crosstool_features defaults to True in Bazel, but to False internally. So internally we have a way to detect host/exec configuration (and we use it), but in Bazel we cannot.

@katre is there a way to detect if we are in the host/exec configuration in Starlark? Right now it seems the only way is to check ctx.genfiles_dir.path.find("-exec-") but that seems suboptimal. Are there better/more supported ways?

If not, can we at least unflip incompatible_dont_enable_host_nonhost_crosstool_features in Bazel? It seems the flag was not as important as it seemed at the time given we still have it disabled internally, and toolchains/platforms work (although we don't use toolchains/platforms for C++, so maybe that is related? I honestly don't remember).

CC @oquenchil

@hlopko
Copy link
Member

hlopko commented Aug 10, 2021

#13315 is in spirit a duplicate of this issue.

@katre
Copy link
Member

katre commented Aug 10, 2021

We are (slowly) working to enable platforms and toolchains for C++ inside google and for Bazel users. Most of the difficulty comes from the interactions of the CC toolchain with Android and Apple code, and we're actively working to resolve that.

You're going to need @oquenchil to figure out whether or not incompatible_dont_enable_host_nonhost_crosstool_features is still needed, I don't have enough context in the state of the CC rules to know now.

@hlopko
Copy link
Member

hlopko commented Aug 10, 2021

@katre what about a language independent way of querying if the current configuration is target or exec from Starlark? Is there a better way than inspecting the genfiles_dir.path?

@katre
Copy link
Member

katre commented Aug 10, 2021

We don't currently have a way to do that. I think there's an open feature request but I don't think we've figured out the right way to expose that.

@hlopko
Copy link
Member

hlopko commented Aug 11, 2021

I see, thank you!

@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 25, 2023
@github-actions
Copy link

github-actions bot commented Jun 8, 2023

This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please reach out to the triage team (@bazelbuild/triage). Thanks!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 8, 2023
@chandlerc
Copy link
Author

How is one supposed to reach out to the triage team? Nothing I type into GitHub seems to do the trick. But this issue is still real, and still needs to be addressed. I don't understand how it is reasonable to just close it.

@fmeum
Copy link
Collaborator

fmeum commented Jun 8, 2023

@bazelbuild/triage Not stale

@sgowroji sgowroji removed the stale Issues or PRs that are stale (no activity for 30 days) label Jun 8, 2023
@sgowroji sgowroji reopened this Jun 8, 2023
@sgowroji sgowroji added the not stale Issues or PRs that are inactive but not considered stale label Jun 8, 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) team-Rules-CPP Issues for C++ rules type: feature request
Projects
None yet
Development

No branches or pull requests

8 participants