Revert "Enable LTO in cargo2android.py."
This reverts commit 4f4ac2f8f309db10c7ccc4c8e4e8979fc803b249.
This did not work for all crates (specifically, those with build.rs,
as they don't get passed RUSTFLAGS, as well as proc-macros, since they
get the flag but can't use LTO), so we're using a different approach
where this is not desired.
Test: Run script
Change-Id: Ib1a86d4822f51978cd8ec15ad657eb25c84e01a4
diff --git a/scripts/cargo2android.py b/scripts/cargo2android.py
index ebee1e9..7b7a9a5 100755
--- a/scripts/cargo2android.py
+++ b/scripts/cargo2android.py
@@ -352,14 +352,12 @@
# 'prefer-dynamic' does not work with common flag -C lto
# 'embed-bitcode' is ignored; we might control LTO with other .bp flag
# 'codegen-units' is set in Android global config or by default
- # 'lto' is used in Android, but it's set by the build system
if not (flag.startswith('codegen-units=') or
flag.startswith('debuginfo=') or
flag.startswith('embed-bitcode=') or
flag.startswith('extra-filename=') or
flag.startswith('incremental=') or
flag.startswith('metadata=') or
- flag.startswith('lto=') or
flag == 'prefer-dynamic'):
self.codegens.append(flag)
@@ -1344,9 +1342,6 @@
# set up search PATH for cargo to find the correct rustc
saved_path = os.environ['PATH']
os.environ['PATH'] = os.path.dirname(self.cargo_path) + ':' + saved_path
- # We need to enable lto since our test prebuilts use it
- saved_rustflags = os.environ.get('RUSTFLAGS', '')
- os.environ['RUSTFLAGS'] = '-C lto=thin -C embed-bitcode=yes ' + saved_rustflags
# Add [workspace] to Cargo.toml if it is not there.
added_workspace = False
if self.args.add_workspace:
@@ -1372,7 +1367,7 @@
cmd = self.cargo_path + cmd_v_flag
cmd += c + features + cmd_tail_target + cmd_tail_redir
if self.args.rustflags and c != 'clean':
- cmd = 'RUSTFLAGS="' + os.environ['RUSTFLAGS'] + ' ' + self.args.rustflags + '" ' + cmd
+ cmd = 'RUSTFLAGS="' + self.args.rustflags + '" ' + cmd
self.run_cmd(cmd, cargo_out)
if self.args.tests:
cmd = self.cargo_path + ' test' + features + cmd_tail_target + ' -- --list' + cmd_tail_redir
@@ -1383,7 +1378,6 @@
if self.args.verbose:
print('### INFO: restored original Cargo.toml')
os.environ['PATH'] = saved_path
- os.environ['RUSTFLAGS'] = saved_rustflags
if not self.dry_run:
if not had_cargo_lock: # restore to no Cargo.lock state
os.remove(cargo_lock)