mirror of
https://github.com/copy/v86.git
synced 2025-12-31 04:23:15 +00:00
Without this patch, the following error is thrown: rust-lld: error: --import-table and --export-table may not be used together Tested on the following nightly versions: rustc 1.30.0-nightly (7e8ca9f8b 2018-08-03) rustc 1.30.0-nightly (33b923fd4 2018-08-18)
42 lines
1.1 KiB
Python
Executable file
42 lines
1.1 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
# A wrapper for rust-lld that removes certain arguments inserted by rustc that
|
|
# we'd like to override
|
|
|
|
import sys
|
|
import subprocess
|
|
from os import path
|
|
|
|
def main():
|
|
args = sys.argv[1:]
|
|
|
|
# filter out args inserted by rustc
|
|
TO_REMOVE = {
|
|
"--export-table",
|
|
"--stack-first",
|
|
"--strip-debug", # TODO: Make this configurable
|
|
}
|
|
args = list(filter(lambda arg: arg not in TO_REMOVE, args))
|
|
|
|
lld = find_rust_lld()
|
|
|
|
result = subprocess.run([lld] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
result.check_returncode()
|
|
|
|
print(result.stderr, file=sys.stderr)
|
|
print(result.stdout)
|
|
|
|
def find_rust_lld():
|
|
which = subprocess.run(["rustup", "which", "rustc"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
which.check_returncode()
|
|
|
|
rustc_path = which.stdout.decode("utf8").strip()
|
|
assert path.basename(rustc_path) == "rustc"
|
|
|
|
bin_path = path.dirname(rustc_path)
|
|
rust_lld_path = path.join(bin_path, "../lib/rustlib/x86_64-unknown-linux-gnu/bin/rust-lld")
|
|
|
|
assert path.isfile(rust_lld_path)
|
|
return rust_lld_path
|
|
|
|
main()
|