-
Notifications
You must be signed in to change notification settings - Fork 16.5k
Closed
Labels
lld:wasmquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Description
As per the rust issue rust-lang/rust#80775, if you try to build an empty rust file:
rustc \
-C target-feature=+mutable-globals \
-C relocation-model=pic \
-C link-args='-s SIDE_MODULE' \
--target wasm32-unknown-emscripten \
--crate-type cdylib \
test.rsthe result is the following error:
note: wasm-ld: error: unknown file type: lib.rmetaRust libraries contain an index file called lib.rmeta. The linker is expected to ignore them. I can work around this with the following patch to the linker:
Emscripten linker patch
if any(arg.endswith(".rlib") for arg in cmd):
from tempfile import mkstemp
from pathlib import Path
tempfiles = []
new_cmd = []
try:
for arg in cmd:
if arg == "-lc":
continue
if not arg.endswith(".rlib"):
new_cmd.append(arg)
continue
fd, temp_path = mkstemp()
shutil.copy2(arg, temp_path)
tempfiles.append(Path(temp_path))
subprocess.call(["ar", "-d", temp_path, "lib.rmeta"])
subprocess.call(["emranlib", temp_path])
new_cmd.append(temp_path)
cmd = new_cmd
cmd = get_command_with_possible_response_file(cmd)
check_call(cmd)
finally:
for file in tempfiles:
file.unlink()
else:
cmd = get_command_with_possible_response_file(cmd)
check_call(cmd)xref Pyodide PR pyodide/pyodide#2378
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
lld:wasmquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!