Skip to content

Commit

Permalink
Turn off is_official_build in the Rust Host Build Tools toolchain
Browse files Browse the repository at this point in the history
Tools built to be used during the build process don't need PGO and
other official build things. This works around a bug on Mac for
chrome.exe where Rust gives the linker -plugin-opt flags it doesn't
understand: rust-lang/rust#60059

However the bug will be unresolved for other build targets that are
link-driven by Rust.

R=brucedawson@chromium.org

Bug: 1386212
Change-Id: I21824ad484048f0bc283454579f2f603acf3fa99
Cq-Include-Trybots: luci.chromium.try:win-rust-x64-rel,win-rust-x64-dbg,linux-rust-x64-rel,linux-rust-x64-dbg,android-rust-arm64-rel,android-rust-arm64-dbg,android-rust-arm32-rel
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4545355
Commit-Queue: danakj <danakj@chromium.org>
Reviewed-by: Bruce Dawson <brucedawson@chromium.org>
Auto-Submit: danakj <danakj@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1146226}
NOKEYCHECK=True
GitOrigin-RevId: df7d81e33033a594ff56d5ab8387aa1f13cd1c39
  • Loading branch information
danakj authored and Copybara-Service committed May 18, 2023
1 parent 5972f46 commit ab552cc
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
14 changes: 12 additions & 2 deletions toolchain/apple/toolchain.gni
Original file line number Diff line number Diff line change
Expand Up @@ -807,8 +807,14 @@ template("apple_toolchain") {
}

if (enable_rust && current_toolchain == default_toolchain) {
# Make an additional toolchain which uses the prebuilt stdlib shipped with
# rustc.
# Make an additional toolchain which is used for making tools that are run
# on the host machine as part of the build process (such as proc macros
# and Cargo build scripts). This toolchain uses the prebuilt stdlib that
# comes with the compiler, so it doesn't have to wait for the stdlib to be
# built before building other stuff. And this ensures its proc macro
# outputs have the right ABI to be loaded by the compiler, and it can be
# used to compile build scripts that are part of the stdlib that is built
# for the default toolchain.
single_apple_toolchain("${target_name}_for_rust_host_build_tools") {
assert(defined(invoker.toolchain_args),
"Toolchains must declare toolchain_args")
Expand All @@ -823,8 +829,12 @@ template("apple_toolchain") {
# Populate toolchain args from the invoker.
forward_variables_from(invoker.toolchain_args, "*")
toolchain_for_rust_host_build_tools = true

# The host build tools are static release builds to make the Chromium
# build faster. They do not need PGO etc, so no official builds.
is_debug = false
is_component_build = false
is_official_build = false
}
}
}
Expand Down
11 changes: 9 additions & 2 deletions toolchain/gcc_toolchain.gni
Original file line number Diff line number Diff line change
Expand Up @@ -827,8 +827,14 @@ template("gcc_toolchain") {
}

if (enable_rust && current_toolchain == default_toolchain) {
# Make an additional toolchain which uses the prebuilt stdlib shipped with
# rustc.
# Make an additional toolchain which is used for making tools that are run
# on the host machine as part of the build process (such as proc macros
# and Cargo build scripts). This toolchain uses the prebuilt stdlib that
# comes with the compiler, so it doesn't have to wait for the stdlib to be
# built before building other stuff. And this ensures its proc macro
# outputs have the right ABI to be loaded by the compiler, and it can be
# used to compile build scripts that are part of the stdlib that is built
# for the default toolchain.
single_gcc_toolchain("${target_name}_for_rust_host_build_tools") {
assert(defined(invoker.toolchain_args),
"Toolchains must declare toolchain_args")
Expand All @@ -848,6 +854,7 @@ template("gcc_toolchain") {
# build faster.
is_debug = false
is_component_build = false
is_official_build = false
}
}
}
Expand Down
13 changes: 10 additions & 3 deletions toolchain/win/toolchain.gni
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,14 @@ template("msvc_toolchain") {
}

if (enable_rust && current_toolchain == default_toolchain) {
# Make an additional toolchain which uses the prebuilt stdlib shipped with
# rustc.
# Make an additional toolchain which is used for making tools that are run
# on the host machine as part of the build process (such as proc macros
# and Cargo build scripts). This toolchain uses the prebuilt stdlib that
# comes with the compiler, so it doesn't have to wait for the stdlib to be
# built before building other stuff. And this ensures its proc macro
# outputs have the right ABI to be loaded by the compiler, and it can be
# used to compile build scripts that are part of the stdlib that is built
# for the default toolchain.
single_msvc_toolchain("${target_name}_for_rust_host_build_tools") {
assert(defined(invoker.toolchain_args),
"Toolchains must declare toolchain_args")
Expand All @@ -600,9 +606,10 @@ template("msvc_toolchain") {
toolchain_for_rust_host_build_tools = true

# The host build tools are static release builds to make the Chromium
# build faster.
# build faster. They do not need PGO etc, so no official builds.
is_debug = false
is_component_build = false
is_official_build = false
}
}
}
Expand Down

0 comments on commit ab552cc

Please sign in to comment.