rust-mobile / android-rs-glue

Glue between Rust and Android
Apache License 2.0
905 stars 111 forks source link

'Missing cargo_apk_gcc option in linker' #191

Closed OptimisticPeach closed 5 years ago

OptimisticPeach commented 6 years ago

I set up android-rs-glue, and built a hello-world kind of example. I succeeded, but then I attempted to use piston, and when compiling this:

extern crate android_glue;
extern crate piston_window;
fn main(){}

I end up with the following output:

> cargo apk build
Compiling android_native_app_glue.c
Compiling injected-glue
Compiling glue_obj
Compiling crate
warning: unused manifest key: package.edition
   Compiling android_test v0.1.0 (file:///C:/Users/name_omitted/Rust/android_test)
error: linking with 'C:\Users\name_omitted\Rust\android_test\target\android-artifacts\linker_exe.exe'     failed: exit code: 101
  |
  = note: "C:\Users\name_omitted\Rust\android_test\target\android-artifacts\linker_exe.exe" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-Wl,--allow-multiple-definition" "-L" 
"C:\Users\name_omitted\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\arm-linux-androideabi\lib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\android_test-e649baceaf118d11.android_test.cx1x15hv-cgu.0.rcgu.o" 
"C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\android_test-e649baceaf118d11.android_test.cx1x15hv-cgu.1.rcgu.o" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\android_test-e649baceaf118d11.android_test.cx1x15hv-cgu.2.rcgu.o" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\android_test-e649baceaf118d11.android_test.cx1x15hv-cgu.3.rcgu.o" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\android_test-e649baceaf118d11.android_test.cx1x15hv-cgu.4.rcgu.o" "-o" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\android_test-e649baceaf118d11" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\android_test-e649baceaf118d11.ppry5fjzqnae2os.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs" "-L" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps" "-L" "C:\Users\name_omitted\Rust\android_test\target\debug\deps" "-L" "C:\Users\name_omitted\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\arm-linux-androideabi\lib" "-Wl,-Bstatic" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libpiston_window-434dcfac313eaf56.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libglutin_window-952bd32991f4d6c7.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libgl-6e4ef531d1263ff9.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libglutin-d561fc5536fc05b1.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libwinit-c2ad24de8e14d47d.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libgfx_graphics-10f106a69693c32d.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libshaders_graphics2d-5eb8235256cd5930.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libgraphics-ea8f2a276de2ae57.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libfnv-f8ae411f37033c9e.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\librusttype-48377acea2567360.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libordered_float-81c1d0d501e7cde5.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libunreachable-83847e56b4c7644f.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libvoid-e51ca2eede09a0a2.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libnum_traits-8594509e37e61ced.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libstb_truetype-577ed8a8b3d7653a.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libinterpolation-8b540ffd3fac8301.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libread_color-aa07cd34fd52d7e8.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libvecmath-11e0452e92920141.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libgfx_texture-79e035d15477b41d.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libimage-570d049abec43471.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libtiff-515dcbb8b42c9e25.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libpng-74c18d5ec1fbf733.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libdeflate-223a42020170e47b.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libinflate-cc8029b7b5a2ff66.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libadler32-365c3c934a7f1b07.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libjpeg_decoder-183934b3cb6f69eb.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\librayon-edf00e859387c5f7.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libeither-5ea6be8e497fe86a.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\librayon_core-6501d4183851329d.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libnum_cpus-b79c1bc35e6e16f6.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\liblibc-929f39e74d2d6fe2.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libcrossbeam_deque-367eddf1505b9956.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libcrossbeam_epoch-dc86a5e50c5a4244.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libscopeguard-2457eb89b3bd6959.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libmemoffset-892539ec0cb8210d.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\liblazy_static-7f7df9e27a65da8c.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libcrossbeam_utils-a3b5188d05bbc27b.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libarrayvec-dfe4766d104f86ee.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libnodrop-0548302860764f69.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libscoped_threadpool-fcd446abfcbf36c4.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libgif-adf94720522a25c1.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libcolor_quant-194350278489795c.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libnum_rational-6ccacefdfe780750.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libnum_iter-579aaa80b4942f97.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libnum_integer-52f5e2a3e8143b16.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libnum_traits-5e8833caac3af002.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\liblzw-829770f55d85f6d8.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libbyteorder-c15cc285efbc27e1.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libtexture-9089eab8d12630e8.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libgfx_device_gl-a233d6d62e9424aa.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libgfx_gl-2ec6bfe5179478b9.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libgfx-2118bd3880a8cbef.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libgfx_core-d4f0390702d3ec3c.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libdraw_state-a08fcd864039426f.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\liblog-4c4bcccb29a272c1.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libcfg_if-03fc8156e29f96de.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libpiston-3e6c78650bb04755.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libevent_loop-3bb655e89c111304.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libwindow-1f37786edba6ae04.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libshader_version-e3857542161cf383.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libinput-9b87c3e222a32e86.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libviewport-4c2030108e1c20ac.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libfloat-da31c0a34ac637c1.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libserde-12934af7d28056d0.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libbitflags-307a84c6824f2142.rlib" "C:\Users\name_omitted\Rust\android_test\target\arm-linux-androideabi\debug\deps\libandroid_glue-8af033bed6591091.rlib" "-Wl,--start-group" "C:\Users\name_omitted\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\arm-linux-androideabi\lib\libstd-8742d1a3e916bc5f.rlib" "C:\Users\name_omitted\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\arm-linux-androideabi\lib\libpanic_unwind-efa06fb124dba20d.rlib" "C:\Users\name_omitted\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\arm-linux-androideabi\lib\libunwind-95f74442e79def6e.rlib" "C:\Users\name_omitted\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\arm-linux-androideabi\lib\liballoc_system-98b41d45b3686f4d.rlib" "C:\Users\name_omitted\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\arm-linux-androideabi\lib\liblibc-7899d3c8c19ca5e1.rlib" "C:\Users\name_omitted\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\arm-linux-androideabi\lib\liballoc-c5d3fd47d77e21ad.rlib" "C:\Users\name_omitted\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\arm-linux-androideabi\lib\libcore-0a980ea71709207b.rlib" "-Wl,--end-group" "C:\Users\name_omitted\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\arm-linux-androideabi\lib\libcompiler_builtins-edd9753c2ed7ad48.rlib" "-Wl,-Bdynamic" "-landroid" "-lEGL" "-lGLESv2" "-landroid" "-landroid" "-lEGL" "-lGLESv2" "-landroid" "-ldl" "-llog" "-lgcc" "-lgcc" "-lc" "-lm" "--cargo-apk-gcc" "P:\ndk\toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64\bin/arm-linux-androideabi-gcc" "--cargo-apk-gcc-sysroot" "P:\ndk\platforms/android-18/arch-arm" "--cargo-apk-native-app-glue" "C:\Users\name_omitted\Rust\android_test\target\android-artifacts\arm-linux-androideabi\android_native_app_glue.o" "--cargo-apk-glue-obj" "C:\Users\name_omitted\Rust\android_test\target\android-artifacts\arm-linux-androideabi\glue_obj.o" "--cargo-apk-glue-lib" "C:\Users\name_omitted\Rust\android_test\target\android-artifacts\arm-linux-androideabi\libcargo_apk_injected_glue.rlib" "--cargo-apk-linker-output" "C:\Users\name_omitted\Rust\android_test\target\android-artifacts\app/lib/armeabi\libmain.so" "--cargo-apk-libs-path-output" "C:\Users\name_omitted\Rust\android_test\target\android-artifacts\arm-linux-androideabi\lib_paths" "--cargo-apk-libs-output" "C:\Users\name_omitted\Rust\android_test\target\android-artifacts\arm-linux-androideabi\libs"
  = note: thread 'main' panicked at 'Missing cargo_apk_gcc option in linker', libcore\option.rs:1010:5
          note: Run with 'RUST_BACKTRACE=1' for a backtrace.

error: aborting due to previous error

(It'd probably be best you copy it into something that wraps text to see it better; it's unwieldy to look at it like this)

I figured out that if I go and run the command the 'note' procures, I get no errors, so I'm not sure what the problem is...

robojumper commented 6 years ago

Most likely due to this: https://github.com/rust-lang/rust/blob/f32f1113c93fe84f252293ae4af86be1ceae4a84/src/librustc_codegen_llvm/back/link.rs#L886-L937

rustc invokes the linker with a temporary args file when the arguments get too long, but the linker script in cargo-apk doesn't handle it.

OptimisticPeach commented 6 years ago

Oh okay, so while I wait for this to be implemented, is there a way to extend the spawn limit temporarily? Thanks!

OptimisticPeach commented 6 years ago

So I was attempting to build this from source to attempt to fix it, but I ended up with a funny case: When I compile with x64 vars, I end up with this error. Similarly, when I compile with x32 vars, I end up with various errors because I set the wrong vars presumably. But, when I change the toolchain, I end up with different errors, tell me if they are needed. So, I tracked the error down to the satanically annoying file.obj and its accomplices (All the other obj files in the folder) I tested a few of them using dumpbin /HEADERS file.obj | findstr "machine" and ended up with x86 for file.obj and some others... Do you know why libcurl would compile itself to 32 bit (x86) while I am compiling to x64? Also, if I'm just completely doing this wrong, tell me please.

OptimisticPeach commented 6 years ago

By the way, I got this (cargo apk build) to work by using WSL instead of powershell. But still, this is just a workaround...

mb64 commented 5 years ago

Fixed by #223.