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

Fix our default fastbuild Bazel config #4363

Merged
merged 1 commit into from
Oct 7, 2024

Conversation

chandlerc
Copy link
Contributor

@chandlerc chandlerc commented Oct 3, 2024

Causes the default development (fastbuild) Bazel build and test to both use ASan, minimal optimizations, and produce good backtraces with source locations.

This also fixes all of the non-host configs that were deeply broken for the latest releases of Bazel going back quite some time.

The intent of our our Bazel toolchain config was for a minimally optimized, minimal debug info, and ASan + UBSan configuration to be the fastbuild, or the default development build of the project. This matches its inclusion of asserts, etc.

At some point quite some time ago, all of this stopped working. Bazel no longer has a nonhost feature. This was disabled a long time ago, briefly argued to be re-enabled, but has persistently been removed. However, since then the host and non-host features have been separated including the compilation mode, and so none of that is needed now. Instead, we can use a much simpler and more principled approach to all of the feature configuration now which this PR implements.

However, we added TCMalloc after all of the ASan stuff became broken, and so we never saw that it is fundamentally incompatible with ASan. So this PR also reworks how TCMalloc is used to only apply to -c opt builds on Linux, and it also explicitly disables it when using --config=asan. I've not found a convenient way to tie the malloc library choice to a toolchain feature in Bazel, so this relies on the config being used rather than the feature in isolation.

Last but not least, with this change fastbuild creates substantially larger output and so this change also passes several new flags to reduce the size costs. One is a general improvement from outlining ASan instrumentation. The others are in a special feature as they reduce the error message quality for two of the more expensive UBSan checks in favor of small generated code size. Keeping these last two separate allows disabling this locally if needed to debug a failure.

@chandlerc chandlerc marked this pull request as ready for review October 6, 2024 01:43
@github-actions github-actions bot requested a review from josh11b October 6, 2024 01:43
Causes the default development (`fastbuild`) Bazel build and test to
both use ASan, minimal optimizations, and produce good backtraces with
source locations.

This also fixes all of the non-host configs that were deeply broken for
the latest releases of Bazel going back quite some time.

The intent of our our Bazel toolchain config was for a minimally
optimized, minimal debug info, and ASan + UBSan configuration to be the
`fastbuild`, or the default development build of the project. This
matches its inclusion of asserts, etc.

At some point quite some time ago, all of this stopped working. Bazel no
longer has a `nonhost` feature. This was disabled a long time ago,
briefly argued to be re-enabled, but has persistently been removed.
However, since then the host and non-host features have been separated
including the compilation mode, and so none of that is needed now.
Instead, we can use a much simpler and more principled approach to all
of the feature configuration now which this PR implements.

However, we added TCMalloc _after_ all of the ASan stuff became broken,
and so we never saw that it is fundamentally incompatible with ASan. So
this PR also reworks how TCMalloc is used to only apply to `-c opt`
builds on Linux, and it also explicitly disables it when using
`--config=asan`. I've not found a convenient way to tie the malloc
library choice to a toolchain feature in Bazel, so this relies on the
config being used rather than the feature in isolation.

Last but not least, with this change `fastbuild` creates substantially
larger output and so this change also passes several new flags to reduce
the size costs. One is a general improvement from outlining ASan
instrumentation. The others are in a special feature as they reduce the
error message quality for two of the more expensive UBSan checks in
favor of small generated code size. Keeping these last two separate
allows disabling this locally if needed to debug a failure.
@chandlerc
Copy link
Contributor Author

FYI, this should be ready to go! =]

@josh11b josh11b added this pull request to the merge queue Oct 7, 2024
Merged via the queue into carbon-language:trunk with commit 284b149 Oct 7, 2024
8 checks passed
github-merge-queue bot pushed a commit that referenced this pull request Oct 25, 2024
AFAICT #4363 made
builds of extract.cpp go from ~15s to ~35s. I'm not sure how to really
improve on this, short of adding boilerplate to the types in order to
reduce template use (e.g., instead of using struct reflection to return
fields, we could have something that directly returns fields). But, this
switch to `MaybeTrace` seems to be about a 20% build time improvement
(down to ~30s), with `noinline` accounting for a part of that.
github-merge-queue bot pushed a commit that referenced this pull request Oct 30, 2024
https://bazel.build/rules/lib/core/dict#update indicates it returns
`None`. Maybe this hasn't worked for a long time, and was missed due to
the issue fixed by #4363
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants