Rust LLVM链接器(rust-lld)段故障

时间:2019-12-01 15:25:14

标签: debugging rust linker llvm

我想尝试LLVM链接器,看看它是否可以帮我加快速度。我已经找到了如何帮助lld找到所有系统库的方法,但是听起来好像在构建脚本(我猜是编译并执行?)而找不到那些库时出了点问题。

我正在使用rustlang / rust:nightly容器(今天刚被拉出)。这样启动容器:

docker run --name=rust --workdir=/datascience-web --rm -it -p 8000:8000 -v $(shell pwd):/datascience-web -v $(shell pwd)/../../samuel-rs:/samuel-rs -v $(shell pwd)/target/linux-env-cargo-git:/usr/local/cargo/git -v $(shell pwd)/target/linux-env-cargo-registry:/usr/local/cargo/registry rustlang/rust:nightly bash

然后从容器内部进入/code并运行:

RUSTFLAGS='-C linker=rust-lld -L /usr/lib/x86_64-linux-gnu -L /usr/lib/gcc/x86_64-linux-gnu/8' cargo build
   Compiling libc v0.2.65
   Compiling proc-macro2 v1.0.6
   Compiling byteorder v1.3.2
   Compiling log v0.4.8
   Compiling syn v1.0.5
   Compiling semver v0.9.0
error: failed to run custom build command for `byteorder v1.3.2`

Caused by:
  process didn't exit successfully: `/code/target/debug/build/byteorder-ce648015d7f0b8ef/build-script-build` (signal: 11, SIGSEGV: invalid memory reference)
warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `libc v0.2.65`

Caused by:
  process didn't exit successfully: `/code/target/debug/build/libc-00921b43cd2fe1bc/build-script-build` (signal: 11, SIGSEGV: invalid memory reference)
warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `proc-macro2 v1.0.6`

Caused by:
  process didn't exit successfully: `/code/target/debug/build/proc-macro2-12e6e3f6412e607e/build-script-build` (signal: 11, SIGSEGV: invalid memory reference)
warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `log v0.4.8`

Caused by:
  process didn't exit successfully: `/code/target/debug/build/log-f937be6d994db414/build-script-build` (signal: 11, SIGSEGV: invalid memory reference)
warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `syn v1.0.5`

Caused by:
  process didn't exit successfully: `/code/target/debug/build/syn-38e19eef1c830c5c/build-script-build` (signal: 11, SIGSEGV: invalid memory reference)
warning: build failed, waiting for other jobs to finish...
error: build failed
make: *** [Makefile:36: build-linux-lld] Error 101

看起来那些build-script-build东西应该不错:

# file /code/target/debug/build/syn-38e19eef1c830c5c/build-script-build
/code/target/debug/build/syn-38e19eef1c830c5c/build-script-build: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
# root@59255e7d6349:/code# ldd /code/target/debug/build/syn-38e19eef1c830c5c/build-script-build
    linux-vdso.so.1 (0x00007ffffc9de000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fe303b87000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fe303b7d000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fe303b5c000)
    libgcc_s.so.1 => /usr/lib/gcc/x86_64-linux-gnu/8/libgcc_s.so.1 (0x00007fe303b42000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe303981000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe3037fe000)
    libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007fe3037f7000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fe303b9d000)
# /code/target/debug/build/syn-38e19eef1c830c5c/build-script-build
Segmentation fault # :( 

我用apt update; apt install -y rust-gdb将gdb安装到了rustlang / rust:nightly容器中。希望这有助于拆除锈迹符号。

# rust-gdb /datascience-web/target/debug/build/log-f937be6d994db414/build-script-build
GNU gdb (Debian 8.2.1-2+b3) 8.2.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /datascience-web/target/debug/build/log-f937be6d994db414/build-script-build...done.
(gdb) run
Starting program: /datascience-web/target/debug/build/log-f937be6d994db414/build-script-build

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00007ffff7ffc01b in std::sys::unix::mutex::Mutex::lock () at src/libstd/sys/unix/mutex.rs:55
#2  std::sys_common::mutex::Mutex::raw_lock () at src/libstd/sys_common/mutex.rs:36
#3  std::sys_common::mutex::Mutex::lock () at src/libstd/sys_common/mutex.rs:42
#4  std::sys::unix::args::imp::really_init () at src/libstd/sys/unix/args.rs:76
#5  std::sys::unix::args::imp::ARGV_INIT_ARRAY::init_wrapper () at src/libstd/sys/unix/args.rs:103

有人知道那些build-script-build文件怎么了吗?他们有什么目的,为什么现在会炸毁?

0 个答案:

没有答案