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

Define program-wide Rust flags in .bazelrc #454

Merged
merged 1 commit into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,16 @@ build:fastdbg -c fastbuild
build:fastdbg --cxxopt='-gline-tables-only' --host_cxxopt='-gline-tables-only'
build:fastdbg --linkopt='-gline-tables-only' --host_linkopt='-gline-tables-only'
build:fastdbg --strip=never

# Additional Rust flags (see https://doc.rust-lang.org/rustc/codegen-options/index.html)
# Need to disable debug-assertions for fastdbg, should be off automatically for opt
build --@rules_rust//:extra_rustc_flags=-C,panic=abort,-C,debug-assertions=n

build:fastdbg --@rules_rust//:extra_rustc_flags=-C,panic=unwind,-C,debug-assertions=y,-C,debuginfo=1

# TODO(later): -C codegen-units=1 improves code size and quality, should be enabled in a future
# release configuration even if lto is off. Similarly, adding -C lto=thin would improve binary size
# a lot (~2.2MB on Linux) – disable it for now due to compile errors and wrong code generation when
# bazel and Rust use different LLVM versions. -C opt-level=s provides a comparatively small size
# improvement, ~35k or ~75k with LTO.
build:thin-lto --@rules_rust//:extra_rustc_flags=-C,panic=abort,-C,codegen-units=1
3 changes: 0 additions & 3 deletions rust-deps/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,6 @@ rust_static_library(
rustc_env = {
"WORKERD_VERSION": "{WORKERD_VERSION}"
},
rustc_flags = [
"-C", "panic=abort"
],
visibility = ["//visibility:public"],
deps = [
":addr2line",
Expand Down