Skip to content

Commit

Permalink
Remove bad command line arguments from the Mac Linker with Rust
Browse files Browse the repository at this point in the history
When linker plugin LTO is enabled on Apple, rustc passes invalid
command line arguments to the linker. They are valid elsewhere but
not known by the Apple linker.

Fortunately, on Apple we have a python script that is used to invoke
the linker. So we drop them from the command line in linker_driver.py
for now.

Upstream issue: rust-lang/rust#60059

R=hans@chromium.org

Bug: 1446796
Change-Id: Idc051457cff194616ac9b0063e3fd255fdd261cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4659997
Reviewed-by: Adrian Taylor <adetaylor@chromium.org>
Commit-Queue: danakj <danakj@chromium.org>
Reviewed-by: Hans Wennborg <hans@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1164710}
  • Loading branch information
danakj authored and Chromium LUCI CQ committed Jun 30, 2023
1 parent ad986be commit dae22dc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion build/toolchain/apple/linker_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,13 @@ def run(self):
assert driver_action[0] not in linker_driver_actions
linker_driver_actions[driver_action[0]] = driver_action[1]
else:
compiler_driver_args.append(arg)
# TODO(crbug.com/1446796): On Apple, the linker command line
# produced by rustc for LTO includes these arguments, but the
# Apple linker doesn't accept them.
# Upstream bug: https://github.com/rust-lang/rust/issues/60059
BAD_RUSTC_ARGS = ['-plugin-opt=O3', '-plugin-opt=mcpu=core2']
if arg not in BAD_RUSTC_ARGS:
compiler_driver_args.append(arg)

if self._object_path_lto is not None:
compiler_driver_args.append('-Wl,-object_path_lto,{}'.format(
Expand Down

0 comments on commit dae22dc

Please sign in to comment.