Skip to content
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

Cross-compile for androideabi (linux host!) #58

Closed
aep opened this issue Jul 21, 2017 · 9 comments
Closed

Cross-compile for androideabi (linux host!) #58

aep opened this issue Jul 21, 2017 · 9 comments

Comments

@aep
Copy link

aep commented Jul 21, 2017

different from #44

aep@stark: ~/kram/backtrace-rs cargo rustc  --target arm-linux-androideabi    --   -C linker=/home/aep/android/build/android-18-toolchain/bin/arm-linux-androideabi-clang

    Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling libc v0.2.26
   Compiling rustc-demangle v0.1.4
   Compiling gcc v0.3.51
   Compiling cfg-if v0.1.2
   Compiling backtrace-sys v0.1.12 (file:///home/aep/kram/backtrace-rs/backtrace-sys)
error: failed to run custom build command for `backtrace-sys v0.1.12 (file:///home/aep/kram/backtrace-rs/backtrace-sys)`
process didn't exit successfully: `/home/aep/kram/backtrace-rs/target/debug/build/backtrace-sys-c8941b55014412f0/build-script-build` (exit code: 101)
--- stdout
OPT_LEVEL = Some("0")
TARGET = Some("arm-linux-androideabi")
HOST = Some("x86_64-unknown-linux-gnu")
TARGET = Some("arm-linux-androideabi")
TARGET = Some("arm-linux-androideabi")
HOST = Some("x86_64-unknown-linux-gnu")
CC_arm-linux-androideabi = None
CC_arm_linux_androideabi = None
TARGET_CC = None
CC = None
TARGET = Some("arm-linux-androideabi")
HOST = Some("x86_64-unknown-linux-gnu")
CFLAGS_arm-linux-androideabi = None
CFLAGS_arm_linux_androideabi = None
TARGET_CFLAGS = None
CFLAGS = None
PROFILE = Some("debug")
running: "sh" "/home/aep/kram/backtrace-rs/backtrace-sys/src/libbacktrace/configure" "--with-pic" "--disable-multilib" "--disable-shared" "--disable-host-shared" "--host=arm-linux-androideabi" "--build=x86_64-unknown-linux-gnu"
checking build system type... x86_64-unknown-linux-gnu
checking host system type... arm-unknown-linux-androideabi
checking target system type... arm-unknown-linux-androideabi
checking for arm-linux-androideabi-gcc... arm-linux-androideabi-gcc
checking for C compiler default output file name... 

--- stderr
configure: error: in `/home/aep/kram/backtrace-rs/target/arm-linux-androideabi/debug/build/backtrace-sys-e9614a5f38c40b50/out':
configure: error: C compiler cannot create executables
See `config.log' for more details.
thread 'main' panicked at 'failed with: exit code: 77', backtrace-sys/build.rs:169
note: Run with `RUST_BACKTRACE=1` for a backtrace.


@ghost
Copy link

ghost commented Jul 21, 2017

Is there anything interesting about this in config.log ?

@aep
Copy link
Author

aep commented Jul 21, 2017

hmm, where is config.log?

aep@stark: ~/kram/backtrace-rs find . -name config.log
aep@stark: ~/kram/backtrace-rs 

the fix appears to be

export CC=/home/aep/android/build/android-18-toolchain/bin/arm-linux-androideabi-clang
cargo rustc  --target arm-linux-androideabi    --   -C linker=/home/aep/android/build/android-18-toolchain/bin/arm-linux-androideabi-clang

not sure what you could do about that. just using the linker as CC by default seems like a bad idea, since people could specify a linker that can't compile (ld)

@alexcrichton
Copy link
Member

Hm seems odd that config.log doesn't exist! That'd have more error information as to what's going on here. In theory it shoudl be located at /home/aep/kram/backtrace-rs/target/arm-linux-androideabi/debug/build/backtrace-sys-e9614a5f38c40b50/out, but it's not there?

@aep
Copy link
Author

aep commented Jul 22, 2017

i must have broken something earlier, sorry. config.log is there now

This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by package-unused configure version-unused, which was
generated by GNU Autoconf 2.64.  Invocation command line was

  $ /home/aep/kram/backtrace-rs/backtrace-sys/src/libbacktrace/configure --with-pic --disable-multilib --disable-shared --disable-host-shared --host=arm-linux-androideabi --build=x86_64-unknown-linux-gnu

## --------- ##
## Platform. ##
## --------- ##

hostname = stark
uname -m = x86_64
uname -r = 4.11.9-1-ARCH
uname -s = Linux
uname -v = #1 SMP PREEMPT Wed Jul 5 18:23:08 CEST 2017

/usr/bin/uname -p = unknown
/bin/uname -X     = unknown

/bin/arch              = unknown
/usr/bin/arch -k       = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo      = unknown
/bin/machine           = unknown
/usr/bin/oslevel       = unknown
/bin/universe          = unknown

PATH: /home/aep/.cargo/bin
PATH: /home/aep/.rbenv/shims
PATH: /home/aep/.rbenv/bin/
PATH: /proj/nordic/JLink_Linux_V488a_x86_64/
PATH: /opt/android-sdk/platform-tools/
PATH: /home/aep/bin
PATH: /usr/lib/ccache/bin/
PATH: /usr/lib/colorgcc/bin
PATH: /usr/local/bin
PATH: /usr/sbin/
PATH: /sbin
PATH: /usr/local/sbin
PATH: /usr/local/bin
PATH: /usr/bin
PATH: /opt/android-sdk/tools
PATH: /opt/cuda/bin
PATH: /usr/lib/jvm/default/bin
PATH: /usr/bin/site_perl
PATH: /usr/bin/vendor_perl
PATH: /usr/bin/core_perl
PATH: /opt/android-sdk/tools


## ----------- ##
## Core tests. ##
## ----------- ##

configure:2524: checking build system type
configure:2538: result: x86_64-unknown-linux-gnu
configure:2558: checking host system type
configure:2571: result: arm-unknown-linux-androideabi
configure:2591: checking target system type
configure:2604: result: arm-unknown-linux-androideabi
configure:2641: checking for arm-linux-androideabi-gcc
configure:2668: result: arm-linux-androideabi-gcc
configure:2937: checking for C compiler version
configure:2946: arm-linux-androideabi-gcc --version >&5
/home/aep/kram/backtrace-rs/backtrace-sys/src/libbacktrace/configure: line 2948: arm-linux-androideabi-gcc: command not found
configure:2957: $? = 127
configure:2946: arm-linux-androideabi-gcc -v >&5
/home/aep/kram/backtrace-rs/backtrace-sys/src/libbacktrace/configure: line 2948: arm-linux-androideabi-gcc: command not found
configure:2957: $? = 127
configure:2946: arm-linux-androideabi-gcc -V >&5
/home/aep/kram/backtrace-rs/backtrace-sys/src/libbacktrace/configure: line 2948: arm-linux-androideabi-gcc: command not found
configure:2957: $? = 127
configure:2946: arm-linux-androideabi-gcc -qversion >&5
/home/aep/kram/backtrace-rs/backtrace-sys/src/libbacktrace/configure: line 2948: arm-linux-androideabi-gcc: command not found
configure:2957: $? = 127
configure:2977: checking for C compiler default output file name
configure:2999: arm-linux-androideabi-gcc -O0 -ffunction-sections -fdata-sections -fPIC -g   conftest.c  >&5
/home/aep/kram/backtrace-rs/backtrace-sys/src/libbacktrace/configure: line 3001: arm-linux-androideabi-gcc: command not found
configure:3003: $? = 127
configure:3040: result: 
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "package-unused"
| #define PACKAGE_TARNAME "libbacktrace"
| #define PACKAGE_VERSION "version-unused"
| #define PACKAGE_STRING "package-unused version-unused"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }
configure:3046: error: in `/home/aep/kram/backtrace-rs/target/arm-linux-androideabi/debug/build/backtrace-sys-e9614a5f38c40b50/out':
configure:3050: error: C compiler cannot create executables
See `config.log' for more details.

## ---------------- ##
## Cache variables. ##
## ---------------- ##

ac_cv_build=x86_64-unknown-linux-gnu
ac_cv_env_CC_set=set
ac_cv_env_CC_value=arm-linux-androideabi-gcc
ac_cv_env_CFLAGS_set=set
ac_cv_env_CFLAGS_value='-O0 -ffunction-sections -fdata-sections -fPIC -g'
ac_cv_env_CPPFLAGS_set=
ac_cv_env_CPPFLAGS_value=
ac_cv_env_CPP_set=
ac_cv_env_CPP_value=
ac_cv_env_LDFLAGS_set=
ac_cv_env_LDFLAGS_value=
ac_cv_env_LIBS_set=
ac_cv_env_LIBS_value=
ac_cv_env_build_alias_set=set
ac_cv_env_build_alias_value=x86_64-unknown-linux-gnu
ac_cv_env_host_alias_set=set
ac_cv_env_host_alias_value=arm-linux-androideabi
ac_cv_env_target_alias_set=
ac_cv_env_target_alias_value=
ac_cv_host=arm-unknown-linux-androideabi
ac_cv_prog_CC=arm-linux-androideabi-gcc
ac_cv_target=arm-unknown-linux-androideabi

## ----------------- ##
## Output variables. ##
## ----------------- ##

ACLOCAL=''
ALLOC_FILE=''
AMTAR=''
AR='ar'
AUTOCONF=''
AUTOHEADER=''
AUTOMAKE=''
AWK=''
BACKTRACE_FILE=''
BACKTRACE_SUPPORTED=''
BACKTRACE_SUPPORTS_DATA=''
BACKTRACE_SUPPORTS_THREADS=''
BACKTRACE_USES_MALLOC=''
CC='arm-linux-androideabi-gcc'
CFLAGS='-O0 -ffunction-sections -fdata-sections -fPIC -g'
CPP=''
CPPFLAGS=''
CYGPATH_W=''
DEFS=''
DSYMUTIL=''
DUMPBIN=''
ECHO_C=''
ECHO_N='-n'
ECHO_T=''
EGREP=''
EXEEXT=''
EXTRA_FLAGS=''
FGREP=''
FORMAT_FILE=''
GREP=''
INSTALL_DATA=''
INSTALL_PROGRAM=''
INSTALL_SCRIPT=''
INSTALL_STRIP_PROGRAM=''
LD=''
LDFLAGS=''
LIBOBJS=''
LIBS=''
LIBTOOL=''
LIPO=''
LN_S=''
LTLIBOBJS=''
MAINT=''
MAINTAINER_MODE_FALSE=''
MAINTAINER_MODE_TRUE=''
MAKEINFO=''
MKDIR_P=''
NATIVE_FALSE=''
NATIVE_TRUE=''
NM=''
NMEDIT=''
OBJDUMP=''
OBJEXT=''
OTOOL64=''
OTOOL=''
PACKAGE=''
PACKAGE_BUGREPORT=''
PACKAGE_NAME='package-unused'
PACKAGE_STRING='package-unused version-unused'
PACKAGE_TARNAME='libbacktrace'
PACKAGE_URL=''
PACKAGE_VERSION='version-unused'
PATH_SEPARATOR=':'
PIC_FLAG=''
RANLIB=''
SED=''
SET_MAKE=''
SHELL='/bin/sh'
STRIP=''
VERSION=''
VIEW_FILE=''
WARN_FLAGS=''
ac_ct_CC=''
ac_ct_DUMPBIN=''
am__EXEEXT_FALSE=''
am__EXEEXT_TRUE=''
am__isrc=''
am__leading_dot=''
am__tar=''
am__untar=''
bindir='${exec_prefix}/bin'
build='x86_64-unknown-linux-gnu'
build_alias='x86_64-unknown-linux-gnu'
build_cpu='x86_64'
build_os='linux-gnu'
build_vendor='unknown'
datadir='${datarootdir}'
datarootdir='${prefix}/share'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
dvidir='${docdir}'
exec_prefix='NONE'
host='arm-unknown-linux-androideabi'
host_alias='arm-linux-androideabi'
host_cpu='arm'
host_os='linux-androideabi'
host_vendor='unknown'
htmldir='${docdir}'
includedir='${prefix}/include'
infodir='${datarootdir}/info'
install_sh=''
libdir='${exec_prefix}/lib'
libexecdir='${exec_prefix}/libexec'
libtool_VERSION=''
localedir='${datarootdir}/locale'
localstatedir='${prefix}/var'
mandir='${datarootdir}/man'
mkdir_p=''
multi_basedir=''
oldincludedir='/usr/include'
pdfdir='${docdir}'
prefix='NONE'
program_transform_name='s,x,x,'
psdir='${docdir}'
sbindir='${exec_prefix}/sbin'
sharedstatedir='${prefix}/com'
sysconfdir='${prefix}/etc'
target='arm-unknown-linux-androideabi'
target_alias='arm-linux-androideabi'
target_cpu='arm'
target_os='linux-androideabi'
target_vendor='unknown'

## ----------- ##
## confdefs.h. ##
## ----------- ##

/* confdefs.h */
#define PACKAGE_NAME "package-unused"
#define PACKAGE_TARNAME "libbacktrace"
#define PACKAGE_VERSION "version-unused"
#define PACKAGE_STRING "package-unused version-unused"
#define PACKAGE_BUGREPORT ""
#define PACKAGE_URL ""

configure: exit 77

@aep
Copy link
Author

aep commented Jul 22, 2017

From the log it's also obvious that it's trying arm-linux-androideabi-gcc from PATH, which is actually standard.
I'll close this because i don't think there's a sane way to guess the absolute path.

@aep aep closed this as completed Jul 22, 2017
@alexcrichton
Copy link
Member

@aep ok thanks for the logs! I wonder if this is a bug in the gcc crate? It's attempting to detect the right compiler and it's concluding arm-linux-androideabi-gcc which doesn't exist while arm-linux-androideabi-clang does exist?

@dbrgn
Copy link

dbrgn commented Sep 25, 2017

I have the same problem here. I set the path to the NDK binaries in ~/.cargo/config:

[target.armv7-linux-androideabi]
ar = "/path/to/NDK/arm/bin/arm-linux-androideabi-ar"
linker = "/path/to/NDK/arm/bin/arm-linux-androideabi-clang"

...but that path is not picked up. Using export CC=/path/to/NDK/arm/bin/arm-linux-androideabi-clang seems to help.

Shouldn't that be picked up automatically?

@alexcrichton
Copy link
Member

@dbrgn I think that's covered by rust-lang/cc-rs#82

@NanoMichael
Copy link

It seems you didn't set the option --host correctly, try --host=<the host system>

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

No branches or pull requests

4 participants