Skip to content

[missing -fPIC] libstd fails to link on ARM with -flto #30688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MagaTailor opened this issue Jan 4, 2016 · 2 comments
Closed

[missing -fPIC] libstd fails to link on ARM with -flto #30688

MagaTailor opened this issue Jan 4, 2016 · 2 comments
Labels
O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state

Comments

@MagaTailor
Copy link

Using gcc 4.9 and lto on armv7 leads to libstd's link failure:

/usr/bin/ld.bfd.real: error: /tmp/cczYIjMC.ltrans0.ltrans.o: requires unsupported dynamic reloc R_ARM_THM_MOVW_ABS_NC; recompile with -fPIC

error: linking with `cc` failed: exit code: 1
note: "cc" "-Wl,--as-needed" "-L" "/tmp/rustc-nightly/arm-unknown-linux-gnueabihf/stage0/lib/rustlib/arm-unknown-linux-gnueabihf/lib" "arm-unknown-linux-gnueabihf/stage0/lib/rustlib/arm-unknown-linux-gnueabihf/lib/std-ca1c970e.0.o" "-o" "arm-unknown-linux-gnueabihf/stage0/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libstd-ca1c970e.so" "arm-unknown-linux-gnueabihf/stage0/lib/rustlib/arm-unknown-linux-gnueabihf/lib/std-ca1c970e.metadata.o" "-Wl,-O1" "-nodefaultlibs" "-L" "arm-unknown-linux-gnueabihf/rt" "-L" "/usr/lib/llvm-3.6/lib" "-L" "/tmp/rustc-nightly/arm-unknown-linux-gnueabihf/stage0/lib/rustlib/arm-unknown-linux-gnueabihf/lib" "-Wl,-Bstatic" "-Wl,--whole-archive" "-l" "backtrace" "-Wl,--no-whole-archive" "-Wl,-Bdynamic" "-l" "dl" "-l" "pthread" "-l" "gcc_s" "-Wl,--whole-archive" "/tmp/rustc.K1iwqkGsmEEU/libcollections-ca1c970e.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.K1iwqkGsmEEU/liballoc-ca1c970e.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.K1iwqkGsmEEU/librustc_unicode-ca1c970e.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.K1iwqkGsmEEU/liballoc_jemalloc-ca1c970e.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.K1iwqkGsmEEU/liblibc-ca1c970e.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.K1iwqkGsmEEU/librand-ca1c970e.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.K1iwqkGsmEEU/libcore-ca1c970e.rlib" "-Wl,--no-whole-archive" "-l" "pthread" "-l" "c" "-l" "m" "-l" "rt" "-shared" "-l" "compiler-rt"

Andrew Pinski from gcc suggested adding -fPIC to the linker's command line which ultimately helped.

@MagaTailor MagaTailor changed the title libstd fails to link on ARM with -flto [-fPIC] libstd fails to link on ARM with -flto Jan 4, 2016
@MagaTailor MagaTailor changed the title [-fPIC] libstd fails to link on ARM with -flto [missing -fPIC] libstd fails to link on ARM with -flto Jan 4, 2016
@steveklabnik steveklabnik added the O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state label Jan 4, 2016
@MagaTailor
Copy link
Author

gchp/termbox-sys#16

@MagaTailor
Copy link
Author

MagaTailor commented Apr 25, 2016

Adding -C link-args=-fPIC to RUSTFLAGS is enough to fix the issue. Strange that it still persists, though.

The size of the lib directory presently goes down from 180MB to 163MB thanks to -flto.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state
Projects
None yet
Development

No branches or pull requests

2 participants