Closed JohnSully closed 7 years ago
This from the latest in the "wasm" branch.
An additional way to narrow this down: It repros even with an empty file at the right spot called libc.a. So it doesn't appear to be based upon the content of the shared lib.
Hmm.. that is very strange. I can't seem to reproduce this at all.
Its interesting because the file seems to have been found since otherwise you would see a different error:
lld: error: unable to find library -lc
So its finding the library then failing to open it.
Can you run with "--verbose" and "-lllvm -debug" perhaps and post the output?
--verbose gives the same output. I get unknown library and unknown argument for -lllvm -debug.
I'm running this on windows subsystem for linux, I'll try on a native linux box.
--verbose should give more output if its passed to the linker. If you are running via clang you need to do -Wl,--verbose
.
I had typo in the other args. Should have been -mllvm -debug
(precede both of these with -Wl,
if calling via clang).
All commands are passed directly to lld to prevent other issues. --verbose had no effect, the other flags change the output as follows: john@DESKTOP-42MHL48:~/testwebasm$ "/usr/local/bin/lld" -flavor wasm -mllvm -debug -L/home/john/wasm_sysroot//lib test.o -allow-undefined-file /home/john/wasm_sysroot//lib/wasm.syms -lc -o a.out Args: lld-link (LLVM option parsing) -debug addDefinedGlobal: __stack_pointer setOutputIndex __stackpointer -> 0 /usr/local/bin/lld: error: cannot open # hn/wasm`T /lib/libc.a: No such file or directory
This repros on a pure linux box as well.
I've narrowed it down. The issue only repros when lld was built with gcc. Rebuilding with clang solves the problem.
It looks like there's some undefined behavior that triggers in gcc but not clang.
I also ran into this problem building lld
with MSVC, and tracked the problem down to this code, which returns StringRef
to a local SmallString<128>
that is destructed when the function returns. Changing findFile
to return a SmallString<128>
solves the problem.
Thanks for tracking that down!
Command: "/usr/local/bin/lld" -flavor wasm -L/home/john/wasm_sysroot//lib test.o -allow-undefined-file /home/john/wasm_sysroot//lib/wasm.syms -lc -o a.out
Error: /usr/local/bin/lld: error: cannot open # hn/wasm_� /lib/libc.a: No such file or directory
Linking instead with /home/john/wasm_sysroot/lib/libc.a directly works fine. The libc.a file is attached libc.zip