Do not emit dwarf information


#1

I’m trying to get rust running on an ancient architecture with an ancient compiler. Although I set debuginfo=0 to my Cargo.toml I still get the error, that the dwarf version is not supported (only capable of handling version 2, got version 4).
Is it possible to downgrade or even better get completly rid of the dwarf information?


#2

I’m not sure about rustc and cargo but you can use GNU strip to remove the debug info from the binary.


#3

Sorry for not being absolutly specific. It’s about compile time dwarf information :slight_smile:

op@devVM:~/workspace/armtest$ cargo rustc --target=armv5te-unknown-linux-gnueabi --release --verbose -- -C debuginfo=0
Compiling armtest v0.1.0 (file:///home/op/workspace/armtest)
 Running `rustc --crate-name armtest src/main.rs --crate-type bin --emit=dep-info,link -C opt-level=3 -C panic=abort -C debuginfo=0 -C metadata=9303b3958cbb06c4 -C extra-filename=-9303b3958cbb06c4 --out-dir /home/op/workspace/armtest/target/armv5te-unknown-linux-gnueabi/release/deps --target armv5te-unknown-linux-gnueabi -C linker=/opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-gcc -L dependency=/home/op/workspace/armtest/target/armv5te-unknown-linux-gnueabi/release/deps -L dependency=/home/op/workspace/armtest/target/release/deps`
error: linking with `/opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-gcc` failed: exit code: 1
|
= note: "/opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-gcc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-L" "/home/op/.rustup/toolchains/nightly-i686-unknown-linux-gnu/lib/rustlib/armv5te-unknown-linux-gnueabi/lib" "/home/op/workspace/armtest/target/armv5te-unknown-linux-gnueabi/release/deps/armtest-9303b3958cbb06c4.armtest0-74dacd3afafd13a62609aca988dcc887.rs.rcgu.o" "/home/op/workspace/armtest/target/armv5te-unknown-linux-gnueabi/release/deps/armtest-9303b3958cbb06c4.armtest1-74dacd3afafd13a62609aca988dcc887.rs.rcgu.o" "/home/op/workspace/armtest/target/armv5te-unknown-linux-gnueabi/release/deps/armtest-9303b3958cbb06c4.armtest2-74dacd3afafd13a62609aca988dcc887.rs.rcgu.o" "/home/op/workspace/armtest/target/armv5te-unknown-linux-gnueabi/release/deps/armtest-9303b3958cbb06c4.armtest3-74dacd3afafd13a62609aca988dcc887.rs.rcgu.o" "/home/op/workspace/armtest/target/armv5te-unknown-linux-gnueabi/release/deps/armtest-9303b3958cbb06c4.armtest4-74dacd3afafd13a62609aca988dcc887.rs.rcgu.o" "/home/op/workspace/armtest/target/armv5te-unknown-linux-gnueabi/release/deps/armtest-9303b3958cbb06c4.armtest5-74dacd3afafd13a62609aca988dcc887.rs.rcgu.o" "/home/op/workspace/armtest/target/armv5te-unknown-linux-gnueabi/release/deps/armtest-9303b3958cbb06c4.armtest6-74dacd3afafd13a62609aca988dcc887.rs.rcgu.o" "-o" "/home/op/workspace/armtest/target/armv5te-unknown-linux-gnueabi/release/deps/armtest-9303b3958cbb06c4" "/home/op/workspace/armtest/target/armv5te-unknown-linux-gnueabi/release/deps/armtest-9303b3958cbb06c4.crate.allocator.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-nodefaultlibs" "-L" "/home/op/workspace/armtest/target/armv5te-unknown-linux-gnueabi/release/deps" "-L" "/home/op/workspace/armtest/target/release/deps" "-L" "/home/op/.rustup/toolchains/nightly-i686-unknown-linux-gnu/lib/rustlib/armv5te-unknown-linux-gnueabi/lib" "-Wl,-Bstatic" "/home/op/.rustup/toolchains/nightly-i686-unknown-linux-gnu/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libstd-46dee8e2445b6fde.rlib" "/home/op/.rustup/toolchains/nightly-i686-unknown-linux-gnu/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libpanic_abort-4a0af619eafe2cb7.rlib" "/home/op/.rustup/toolchains/nightly-i686-unknown-linux-gnu/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libunwind-d6155d6810a00e0b.rlib" "/home/op/.rustup/toolchains/nightly-i686-unknown-linux-gnu/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/liballoc_system-4706734acfecbee4.rlib" "/home/op/.rustup/toolchains/nightly-i686-unknown-linux-gnu/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/liblibc-d13fd515f0e3aae4.rlib" "/home/op/.rustup/toolchains/nightly-i686-unknown-linux-gnu/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/liballoc-e0fbee440c2aed35.rlib" "/home/op/.rustup/toolchains/nightly-i686-unknown-linux-gnu/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libstd_unicode-a170b31ec4b191be.rlib" "/home/op/.rustup/toolchains/nightly-i686-unknown-linux-gnu/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcore-cc0e52160d2113eb.rlib" "/home/op/.rustup/toolchains/nightly-i686-unknown-linux-gnu/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libcompiler_builtins-b511442e4b89828a.rlib" "-Wl,-Bdynamic" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "pthread" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-l" "util" "-l" "util"
= note: /opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/lib/gcc/arm-none-linux-gnueabi/4.1.2/../../../../arm-none-linux-gnueabi/bin/ld: Dwarf Error: found dwarf version '4', this reader only handles version 2 information.
      /home/op/.rustup/toolchains/nightly-i686-unknown-linux-gnu/lib/rustlib/armv5te-unknown-linux-gnueabi/lib/libstd-46dee8e2445b6fde.rlib(std-46dee8e2445b6fde.std14-f2283e82cf47c3fb3e6c22f93526d0a3.rs.rcgu.o): In function `std::sys::unix::backtrace::tracing::imp::unwind_backtrace::h392fc78ecb65f012':
      std14-f2283e82cf47c3fb3e6c22f93526d0a3.rs:(.text._ZN3std3sys4unix9backtrace7tracing3imp16unwind_backtrace17h392fc78ecb65f012E+0x24): undefined reference to `_Unwind_Backtrace'
      collect2: ld returned 1 exit status
      

error: aborting due to previous error

error: Could not compile `armtest`.

Caused by:
  process didn't exit successfully: `rustc --crate-name armtest src/main.rs --crate-type bin --emit=dep-info,link -C opt-level=3 -C panic=abort -C debuginfo=0 -C metadata=9303b3958cbb06c4 -C extra-filename=-9303b3958cbb06c4 --out-dir /home/op/workspace/armtest/target/armv5te-unknown-linux-gnueabi/release/deps --target armv5te-unknown-linux-gnueabi -C linker=/opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-gcc -L dependency=/home/op/workspace/armtest/target/armv5te-unknown-linux-gnueabi/release/deps -L dependency=/home/op/workspace/armtest/target/release/deps` (exit code: 101)