Skip to content

Fix Cargo Config Linker Reference #161

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

Merged
merged 1 commit into from
Apr 10, 2017
Merged

Fix Cargo Config Linker Reference #161

merged 1 commit into from
Apr 10, 2017

Conversation

bschwind
Copy link
Contributor

@bschwind bschwind commented Apr 9, 2017

Today I went through this guide to running Rust on Android. I got everything working but had to make one modification to the cargo config file.

Instead of

[target.arm-linux-androideabi]
linker = "/home/rust/android-18-toolchain"

I had to write something like

linker = "/home/rust/android-18-toolchain/bin/arm-linux-androideabi-clang"

I was getting an error on cargo build which looked like this:

$ cargo build -v --release
...snipped output...
checking for C compiler default output file name... 

--- stderr
configure: WARNING: If you wanted to set the --build type, don't use --host.
    If a cross compiler is detected then cross compile mode will be used.
configure: error: in `/Users/brian/projects/helloRust/rust-code/target/arm-linux-androideabi/release/build/backtrace-sys-c41044212322c9f2/out':
configure: error: C compiler cannot create executables
See `config.log' for more details.
thread 'main' panicked at 'failed with: exit code: 77', /Users/brian/.cargo/registry/src/i.8713187.xyz-1ecc6299db9ec823/backtrace-sys-0.1.10/build.rs:134
note: Run with `RUST_BACKTRACE=1` for a backtrace.

Just plain clang worked as well so I'm not sure what the best solution is here. For the record, here are all the binaries in the /bin directory of the standalone toolchain I made:

$ ls android-18-toolchain/bin/
arm-linux-androideabi-addr2line  arm-linux-androideabi-gcov       armeabi                          llvm-ar
arm-linux-androideabi-ar         arm-linux-androideabi-gdb        armeabi-v7a                      llvm-as
arm-linux-androideabi-as         arm-linux-androideabi-gprof      armeabi-v7a-hard                 llvm-dis
arm-linux-androideabi-c++        arm-linux-androideabi-ld         asan_device_setup                llvm-link
arm-linux-androideabi-c++filt    arm-linux-androideabi-ld.bfd     clang                            mips
arm-linux-androideabi-clang      arm-linux-androideabi-ld.gold    clang++                          mips64
arm-linux-androideabi-clang++    arm-linux-androideabi-ld.mcld    clang36                          ndk-link
arm-linux-androideabi-cpp        arm-linux-androideabi-nm         clang36++                        ndk-strip
arm-linux-androideabi-dwp        arm-linux-androideabi-objcopy    ld.mcld                          ndk-translate
arm-linux-androideabi-elfedit    arm-linux-androideabi-objdump    le32-none-ndk-link               opt
arm-linux-androideabi-g++        arm-linux-androideabi-ranlib     le32-none-ndk-strip              python
arm-linux-androideabi-gcc        arm-linux-androideabi-readelf    le32-none-ndk-translate          python2
arm-linux-androideabi-gcc-4.8    arm-linux-androideabi-size       le64-none-ndk-link               python2.7
arm-linux-androideabi-gcc-ar     arm-linux-androideabi-strings    le64-none-ndk-strip              x86
arm-linux-androideabi-gcc-nm     arm-linux-androideabi-strip      le64-none-ndk-translate          x86_64
arm-linux-androideabi-gcc-ranlib arm64-v8a                        llc

In any case, I just want to update this article so no one is as confused as I was when trying to build a shared lib for Android.

@alexcrichton alexcrichton merged commit 8a38814 into rust-lang:gh-pages Apr 10, 2017
@alexcrichton
Copy link
Member

Thanks!

@bschwind
Copy link
Contributor Author

Thanks, @alexcrichton!

As an aside, out of that list of possible tools to use for a linker, is there a preferred one? arm-linux-androideabi-clang and clang both worked for me but I'm not sure if I'm setting myself up for headaches down the road in some way.

@alexcrichton
Copy link
Member

I'd typically recommend the target-prefixed one, but I think it may just be a symlink to the other one?

@bschwind
Copy link
Contributor Author

Hmm, there are no symlinks in that particular bin directory. I'll just go with what I have for now and report any problems later on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants