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

NDK r25 does not handle quoted parameters to clang on Windows #92

Closed
GlennFolker opened this issue Mar 11, 2023 · 18 comments · Fixed by #99 or #108
Closed

NDK r25 does not handle quoted parameters to clang on Windows #92

GlennFolker opened this issue Mar 11, 2023 · 18 comments · Fixed by #99 or #108

Comments

@GlennFolker
Copy link

Running cargo ndk -t x86_64 -p 33 build gives me this error:

[2023-03-11T17:32:51Z INFO  cargo_ndk::cli] Using NDK at path: C:\AndroidNDK (ANDROID_NDK_HOME)
[2023-03-11T17:32:51Z INFO  cargo_ndk::cli] NDK API level: 33
[2023-03-11T17:32:51Z INFO  cargo_ndk::cli] Building targets: x86_64
[2023-03-11T17:32:51Z INFO  cargo_ndk::cli] Building x86_64 (x86_64-linux-android)
   Compiling and2 v0.1.0 (C:\Users\Glenn\and2)
error: linking with `C:\AndroidNDK\toolchains\llvm\prebuilt\windows-x86_64\bin\x86_64-linux-android33-clang.cmd` failed: exit code: 255
  |
  = note: "C:\\AndroidNDK\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\x86_64-linux-android33-clang.cmd" "-Wl,--version-script=C:\\Users\\Glenn\\AppData\\Local\\Temp\\rustcMmyczo\\list" "-m64" "C:\\Users\\Glenn\\AppData\\Local\\Temp\\rustcMmyczo\\symbols.o" "C:\\Users\\Glenn\\and2\\target\\x86_64-linux-android\\debug\\deps\\and2.220y3l223trvteix.rcgu.o" "C:\\Users\\Glenn\\and2\\target\\x86_64-linux-android\\debug\\deps\\and2.3izm99ra9qa3p8id.rcgu.o" "-Wl,--as-needed" "-L" "C:\\Users\\Glenn\\and2\\target\\x86_64-linux-android\\debug\\deps" "-L" "C:\\Users\\Glenn\\and2\\target\\debug\\deps" "-L" "C:\\Users\\Glenn\\and2\\target\\cargo-ndk\\libgcc-workaround" "-L" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib" "-Wl,-Bstatic" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\libstd-3b76298062fcbb41.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\libpanic_unwind-5c79ad5020a8a376.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\libobject-c856ab6f9f61a0c8.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\libmemchr-4330e4945024bd31.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\libaddr2line-b743fb28f7e6f36b.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\libgimli-3c967a14752063ee.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\librustc_demangle-de83573183ce509d.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\libstd_detect-189990c033015975.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\libhashbrown-4ac8e97124e072c7.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\libminiz_oxide-c58c6d1c5b304afc.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\libadler-4112d160f12e0da0.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\librustc_std_workspace_alloc-e50526c393c6b479.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\libunwind-c0afb47c69be5adb.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\libcfg_if-36bd188b5238bf89.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\liblibc-9c1c158f10c4615e.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\liballoc-ae67f691b53af35a.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\librustc_std_workspace_core-e9e3e381106ad9fb.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\libcore-e3d2ffae725503a0.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib\\libcompiler_builtins-7de08890edb9a78a.rlib" "-Wl,-Bdynamic" "-ldl" "-llog" "-lunwind" "-ldl" "-lm" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-linux-android\\lib" "-o" "C:\\Users\\Glenn\\and2\\target\\x86_64-linux-android\\debug\\deps\\liband2.so" "-Wl,--gc-sections" "-shared" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
  = note: --version-script=C:\Users\Glenn\AppData\Local\Temp\rustcMmyczo\list"" was unexpected at this time.


error: could not compile `and2` due to previous error
[2023-03-11T17:33:05Z INFO  cargo_ndk::cli] If the build failed due to a missing target, you can run this command:
[2023-03-11T17:33:05Z INFO  cargo_ndk::cli]
[2023-03-11T17:33:05Z INFO  cargo_ndk::cli]     rustup target install x86_64-linux-android

I'm on a x86_64 Windows 10 machine, and I have installed both Android SDK and Android NDK.

@bbqsrc
Copy link
Owner

bbqsrc commented Mar 12, 2023

Which version of cargo-ndk? If it's not v3, try with v3.

@GlennFolker
Copy link
Author

cargo ndk --version returns cargo-ndk 2.12.2; I'll try updating.

@GlennFolker
Copy link
Author

Still the same error, unfortunately.

@GlennFolker
Copy link
Author

So I tried manually invoking whatever the compiler script NDK had, and apparently removing the quotes from the arguments ("-Wl,--version-script=..." to -Wl,--version-script=...) fixes it.

@bbqsrc
Copy link
Owner

bbqsrc commented Mar 12, 2023

I will need you to provide a repository with a reproduction case, as with my simple repositories I cannot reproduce this.

@bbqsrc
Copy link
Owner

bbqsrc commented Mar 15, 2023

I'll close this, feel free to re-open if more information comes about.

@bbqsrc bbqsrc closed this as not planned Won't fix, can't repro, duplicate, stale Mar 15, 2023
@TomieAi
Copy link

TomieAi commented May 8, 2023

same error xD simple to reproduce in windows ..

cargo new sad --lib
cd sad
cargo ndk -t armeabi-v7a -t arm64-v8a -o ./jniLibs build --release

@bbqsrc
Copy link
Owner

bbqsrc commented May 8, 2023

Hm, okay, I'll look into it. Thanks!

@bbqsrc bbqsrc reopened this May 8, 2023
@TomieAi
Copy link

TomieAi commented May 8, 2023

So I tried manually invoking whatever the compiler script NDK had, and apparently removing the quotes from the arguments ("-Wl,--version-script=..." to -Wl,--version-script=...) fixes it.

how did u remove it..

@TomieAi
Copy link

TomieAi commented May 8, 2023

Hm, okay, I'll look into it. Thanks!

and i put this

[lib]
# This must contain at least cdylib for Android libraries to be generated.
crate-type = ["cdylib"]

and the result is

  = note: "D:\\AndroidSDK\\ndk\\25.2.9519653\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\armv7a-linux-androideabi21-clang.cmd" "-Wl,--version-script=C:\\Users\\redacted\\AppData\\Local\\Temp\\rustcfOdF9F\\list" "-march=armv7-a" "C:\\Users\\redacted\\AppData\\Local\\Temp\\rustcfOdF9F\\symbols.o" "D:\\rustpj\\learn\\sad\\target\\armv7-linux-androideabi\\release\\deps\\sad.sad.c609ceec-cgu.0.rcgu.o" "D:\\rustpj\\learn\\sad\\target\\armv7-linux-androideabi\\release\\deps\\sad.lvl3fyn229r5lzw.rcgu.o" "-Wl,--as-needed" "-L" "D:\\rustpj\\learn\\sad\\target\\armv7-linux-androideabi\\release\\deps" "-L" "D:\\rustpj\\learn\\sad\\target\\release\\deps" "-L" "C:\\Users\\redacted\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib" "-Wl,-Bstatic" "C:\\Users\\redacted\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\libstd-9d5134f0ea4594d8.rlib" "C:\\Users\\redacted\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\libpanic_unwind-01b1c5f80e0e7f9b.rlib" "C:\\Users\\redacted\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\libobject-ae30fd2e510e40d6.rlib" "C:\\Users\\redacted\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\libmemchr-9ad4b962e90cf093.rlib" "C:\\Users\\redacted\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\libaddr2line-6c5f47bc28436fe1.rlib" "C:\\Users\\redacted\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\libgimli-ff6b9ee0b9139d30.rlib" "C:\\Users\\redacted\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\librustc_demangle-4ddc39bc389bb6df.rlib" "C:\\Users\\redacted\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\libstd_detect-00cad421ee04a0db.rlib" "C:\\Users\\redacted\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\libhashbrown-1470100c3925e285.rlib" "C:\\Users\\redacted\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\libminiz_oxide-61a0eae65236d4ab.rlib" "C:\\Users\\redacted\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\libadler-946535f5774d69b3.rlib" "C:\\Users\\redacted\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\librustc_std_workspace_alloc-151b8b3dd2d9d9bf.rlib" "C:\\Users\\redacted\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\libunwind-7138631d4908511a.rlib" "C:\\Users\\redacted\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\libcfg_if-a40e9b397e82f2d1.rlib" "C:\\Users\\redacted\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\liblibc-fe55f15858518399.rlib" "C:\\Users\\redacted\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\liballoc-ab9bdff74387450f.rlib" "C:\\Users\\redacted\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\librustc_std_workspace_core-1e49a5531690b2be.rlib" "C:\\Users\\redacted\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\libcore-7a614fc5f2c1e83e.rlib" "C:\\Users\\redacted\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib\\libcompiler_builtins-a7b4a7b4024efe3d.rlib" "-Wl,-Bdynamic" "-ldl" "-llog" "-lunwind" "-ldl" "-lm" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "C:\\Users\\redacted\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\armv7-linux-androideabi\\lib" "-o" "D:\\rustpj\\learn\\sad\\target\\armv7-linux-androideabi\\release\\deps\\libsad.so" "-Wl,--gc-sections" "-shared" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-nodefaultlibs"
  = note: --version-script=C:\Users\redacted\AppData\Local\Temp\rustcfOdF9F\list"" was unexpected at this time.

@rubenh2905
Copy link


C:\Users\ASUS\Documents\RandomProjects\android-test3>cargo ndk -t x86_64 -o ./jniLibs build
[2023-05-08T10:30:46Z INFO  cargo_ndk::cli] Using NDK at path: C:\Users\ASUS\AppData\Local\Android\Sdk\ndk\25.1.8937393 (ANDROID_NDK_HOME)
[2023-05-08T10:30:46Z INFO  cargo_ndk::cli] NDK API level: 21
[2023-05-08T10:30:46Z INFO  cargo_ndk::cli] Building targets: x86_64
[2023-05-08T10:30:46Z INFO  cargo_ndk::cli] Building x86_64 (x86_64-linux-android)
   Compiling android-test3 v0.1.0 (C:\Users\ASUS\Documents\RandomProjects\android-test3)
error: linking with `C:\Users\ASUS\AppData\Local\Android\Sdk\ndk\25.1.8937393\toolchains\llvm\prebuilt\windows-x86_64\bin\x86_64-linux-android21-clang.cmd` failed: exit code: 255
  |
  = note: "C:\\Users\\ASUS\\AppData\\Local\\Android\\Sdk\\ndk\\25.1.8937393\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\x86_64-linux-android21-clang.cmd" "-Wl,--version-script=C:\\Users\\ASUS\\AppData\\Local\\Temp\\rustcnmJlPU\\list" "-m64" "C:\\Users\\ASUS\\AppData\\Local\\Temp\\rustcnmJlPU\\symbols.o" "C:\\Users\\ASUS\\Documents\\RandomProjects\\android-test3\\target\\x86_64-linux-android\\debug\\deps\\android_test3.1u2n4515x8eam8xj.rcgu.o" "C:\\Users\\ASUS\\Documents\\RandomProjects\\android-test3\\target\\x86_64-linux-android\\debug\\deps\\android_test3.1vxjli7pziqs971o.rcgu.o" "C:\\Users\\ASUS\\Documents\\RandomProjects\\android-test3\\target\\x86_64-linux-android\\debug\\deps\\android_test3.1y3an2s7kwelw2w.rcgu.o" "C:\\Users\\ASUS\\Documents\\RandomProjects\\android-test3\\target\\x86_64-linux-android\\debug\\deps\\android_test3.22zi7qbfva1kjifj.rcgu.o" "C:\\Users\\ASUS\\Documents\\RandomProjects\\android-test3\\target\\x86_64-linux-android\\debug\\deps\\android_test3.26264m0lrkdgjjye.rcgu.o" "C:\\Users\\ASUS\\Documents\\RandomProjects\\android-test3\\target\\x86_64-linux-android\\debug\\deps\\android_test3.2b6jrv4psh0reryv.rcgu.o" "C:\\Users\\ASUS\\Documents\\RandomProjects\\android-test3\\target\\x86_64-linux-android\\debug\\deps\\android_test3.2ofoo0y03ebznn4.rcgu.o" "C:\\Users\\ASUS\\Documents\\RandomProjects\\android-test3\\target\\x86_64-linux-android\\debug\\deps\\android_test3.31iyavmbonshyje8.rcgu.o" "C:\\Users\\ASUS\\Documents\\RandomProjects\\android-test3\\target\\x86_64-linux-android\\debug\\deps\\android_test3.324t3w29udtre370.rcgu.o" "C:\\Users\\ASUS\\Documents\\RandomProjects\\android-test3\\target\\x86_64-linux-android\\debug\\deps\\android_test3.38ucdogteljll2v1.rcgu.o" "C:\\Users\\ASUS\\Documents\\RandomProjects\\android-test3\\target\\x86_64-linux-android\\debug\\deps\\android_test3.4vbrfxijjzxtbar.rcgu.o" "C:\\Users\\ASUS\\Documents\\RandomProjects\\android-test3\\target\\x86_64-linux-android\\debug\\deps\\android_test3.5g8pwkwbklthe52n.rcgu.o" "C:\\Users\\ASUS\\Documents\\RandomProjects\\android-test3\\target\\x86_64-linux-android\\debug\\deps\\android_test3.9hijtvcn9rdpomh.rcgu.o" "C:\\Users\\ASUS\\Documents\\RandomProjects\\android-test3\\target\\x86_64-linux-android\\debug\\deps\\android_test3.ipycet62omepz0a.rcgu.o" "C:\\Users\\ASUS\\Documents\\RandomProjects\\android-test3\\target\\x86_64-linux-android\\debug\\deps\\android_test3.l7gdenm59xs1gx.rcgu.o" "C:\\Users\\ASUS\\Documents\\RandomProjects\\android-test3\\target\\x86_64-linux-android\\debug\\deps\\android_test3.o07k0imq1t06sgr.rcgu.o" "C:\\Users\\ASUS\\Documents\\RandomProjects\\android-test3\\target\\x86_64-linux-android\\debug\\deps\\android_test3.ztwn93xgfel3jkl.rcgu.o" "C:\\Users\\ASUS\\Documents\\RandomProjects\\android-test3\\target\\x86_64-linux-android\\debug\\deps\\android_test3.4hlbywnxk6a6bf5a.rcgu.rmeta" "C:\\Users\\ASUS\\Documents\\RandomProjects\\android-test3\\target\\x86_64-linux-android\\debug\\deps\\android_test3.2tcrs3bte86hyhxc.rcgu.o" "-Wl,--as-needed" "-L" "C:\\Users\\ASUS\\Documents\\RandomProjects\\android-test3\\target\\x86_64-linux-android\\debug\\deps" "-L" "C:\\Users\\ASUS\\Documents\\RandomProjects\\android-test3\\target\\debug\\deps" "-L" "C:\\Users\\ASUS\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-linux-android\\lib" "-Wl,-Bstatic" "C:\\Users\\ASUS\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-linux-android\\lib\\libstd-4fd3234e8de3f87c.rlib" "C:\\Users\\ASUS\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-linux-android\\lib\\libpanic_unwind-c10fe7842122b00f.rlib" "C:\\Users\\ASUS\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-linux-android\\lib\\libobject-1e13a9a735200cc8.rlib" "C:\\Users\\ASUS\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-linux-android\\lib\\libmemchr-8254e266dc1e166b.rlib" "C:\\Users\\ASUS\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-linux-android\\lib\\libaddr2line-4647fe39813382ab.rlib" "C:\\Users\\ASUS\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-linux-android\\lib\\libgimli-d7124c945c58d38f.rlib" "C:\\Users\\ASUS\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-linux-android\\lib\\librustc_demangle-d847e893ae0d9044.rlib" "C:\\Users\\ASUS\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-linux-android\\lib\\libstd_detect-5ac1d92eeefb916a.rlib" "C:\\Users\\ASUS\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-linux-android\\lib\\libhashbrown-1647a8d56520a2cb.rlib" "C:\\Users\\ASUS\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-linux-android\\lib\\libminiz_oxide-c8d11ae040c72b2b.rlib" "C:\\Users\\ASUS\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-linux-android\\lib\\libadler-7129e1a30bbf6361.rlib" "C:\\Users\\ASUS\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-linux-android\\lib\\librustc_std_workspace_alloc-c0b496ddef22f068.rlib" "C:\\Users\\ASUS\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-linux-android\\lib\\libunwind-0fec60cfc694600d.rlib" "C:\\Users\\ASUS\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-linux-android\\lib\\libcfg_if-aa65b71a702203ad.rlib" "C:\\Users\\ASUS\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-linux-android\\lib\\liblibc-f52fe2d927c04f28.rlib" "C:\\Users\\ASUS\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-linux-android\\lib\\liballoc-cbfe596f80e28fdc.rlib" "C:\\Users\\ASUS\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-linux-android\\lib\\librustc_std_workspace_core-4e4df940ca409aed.rlib" "C:\\Users\\ASUS\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-linux-android\\lib\\libcore-495edec0a5ea885e.rlib" "C:\\Users\\ASUS\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-linux-android\\lib\\libcompiler_builtins-1b3ab72718fa335e.rlib" "-Wl,-Bdynamic" "-ldl" "-llog" "-lunwind" "-ldl" "-lm" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "C:\\Users\\ASUS\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-linux-android\\lib" "-o" "C:\\Users\\ASUS\\Documents\\RandomProjects\\android-test3\\target\\x86_64-linux-android\\debug\\deps\\libandroid_test3.so" "-shared" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
  = note: --version-script=C:\Users\ASUS\AppData\Local\Temp\rustcnmJlPU\list"" was unexpected at this time.


error: could not compile `android-test3` due to previous error
[2023-05-08T10:30:47Z INFO  cargo_ndk::cli] If the build failed due to a missing target, you can run this command:
[2023-05-08T10:30:47Z INFO  cargo_ndk::cli]
[2023-05-08T10:30:47Z INFO  cargo_ndk::cli]     rustup target install x86_64-linux-android

C:\Users\ASUS\Documents\RandomProjects\android-test3>

@rubenh2905
Copy link

i searched all the internet and it's look like that this is just our problem
anyone have any idea ?
is it "rust" fault or my local version did not install correctly ?

@bbqsrc
Copy link
Owner

bbqsrc commented May 8, 2023

This is a bug in the NDK. I can reproduce it by passing just:

 cargo build --release --target armv7-linux-androideabi --config target.armv7-linux-androideabi.linker="'D:\\ndk\\25.2.9519653\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\armv7a-linux-androideabi21-clang.cmd'"

@rubenh2905

This comment was marked as off-topic.

@bbqsrc
Copy link
Owner

bbqsrc commented May 8, 2023

android/ndk#1856

It's a known issue. Some kind of depressing workaround is likely needed. I won't have time to do that for a while, so consider using an older NDK or building on either Linux and Windows for now.

@bbqsrc bbqsrc changed the title "... was unexpected at this time." NDK r25 does not handle quoted parameters to clang on Windows May 8, 2023
@rubenh2905

This comment was marked as off-topic.

@bbqsrc
Copy link
Owner

bbqsrc commented May 8, 2023

I'm going to lock this issue since it's likely others are going to come here. I will work on a workaround some time in the next few weeks, as it will require essentially replacing the .cmd files that come with NDK r25, as specific configuration of each of the targets is handled in those .cmd files, and cannot handle quoted paths. Since it is the LTS version, this is going to linger around for a long-ass time.

So once again, cargo-ndk will become full of hacks because Google has done a silly thing and likes to create work for open source developers. 😶‍🌫️

Repository owner locked as resolved and limited conversation to collaborators May 8, 2023
@bbqsrc bbqsrc pinned this issue May 8, 2023
@bbqsrc
Copy link
Owner

bbqsrc commented May 9, 2023

Follow #99 for the fix.

@bbqsrc bbqsrc closed this as completed in #99 May 9, 2023
@bbqsrc bbqsrc unpinned this issue May 9, 2023
rib added a commit to rib/cargo-ndk that referenced this issue May 18, 2023
This is an alternative workaround for bbqsrc#92 that's similar to the solution
used in ndk-build except that the `-Clink-arg rustflag` is injected via
a RUSTC_WRAPPER instead of trying to modify CARGO_ENCODED_RUSTFLAGS.

It turned out to be practically impossible to be able to reliably
set CARGO_ENCODED_RUSTFLAGS without risking trampling over rustflags
that might be configured via Cargo (for example `target.<cfg>.rustflags`
are especially difficult to read outside of cargo itself)

This approach avoids hitting the command line length limitations of the
current workaround and avoids needing temporary hard links or copying
the cargo-ndk binary to the target/ directory.

Even though we've only seen quoting issues with the Windows `.cmd`
wrappers this change to avoid using the wrapper scripts is being
applied consistently for all platforms. E.g. considering the upstream
recommendation to avoid the wrapper scripts if possible:

https://android-review.googlesource.com/c/platform/ndk/+/2134712

Fixes: bbqsrc#92
Fixes: bbqsrc#104
Addresses: android/ndk#1856
rib added a commit to rib/cargo-ndk that referenced this issue May 18, 2023
This is an alternative workaround for bbqsrc#92 that's similar to the solution
used in ndk-build except that the `-Clink-arg rustflag` is injected via
a RUSTC_WRAPPER instead of trying to modify CARGO_ENCODED_RUSTFLAGS.

It turned out to be practically impossible to be able to reliably
set CARGO_ENCODED_RUSTFLAGS without risking trampling over rustflags
that might be configured via Cargo (for example `target.<cfg>.rustflags`
are especially difficult to read outside of cargo itself)

This approach avoids hitting the command line length limitations of the
current workaround and avoids needing temporary hard links or copying
the cargo-ndk binary to the target/ directory.

Even though we've only seen quoting issues with the Windows `.cmd`
wrappers this change to avoid using the wrapper scripts is being
applied consistently for all platforms. E.g. considering the upstream
recommendation to avoid the wrapper scripts if possible:

https://android-review.googlesource.com/c/platform/ndk/+/2134712

Fixes: bbqsrc#92
Fixes: bbqsrc#104
Addresses: android/ndk#1856
rib added a commit to rib/cargo-ndk that referenced this issue May 18, 2023
This is an alternative workaround for bbqsrc#92 that's similar to the solution
used in ndk-build except that the `--target=<triple><api-level>` argument
for Clang is injected by using cargo-ndk as a linker wrapper instead of
trying to modify CARGO_ENCODED_RUSTFLAGS.

It turned out to be practically impossible to be able to reliably
set CARGO_ENCODED_RUSTFLAGS without risking trampling over rustflags
that might be configured via Cargo (for example `target.<cfg>.rustflags`
are especially difficult to read outside of cargo itself)

This approach avoids hitting the command line length limitations of the
current workaround and avoids needing temporary hard links or copying
the cargo-ndk binary to the target/ directory.

Even though we've only seen quoting issues with the Windows `.cmd`
wrappers this change to avoid using the wrapper scripts is being
applied consistently for all platforms. E.g. considering the upstream
recommendation to avoid the wrapper scripts if possible:

https://android-review.googlesource.com/c/platform/ndk/+/2134712

Fixes: bbqsrc#92
Fixes: bbqsrc#104
Addresses: android/ndk#1856
bbqsrc pushed a commit that referenced this issue May 22, 2023
This is an alternative workaround for #92 that's similar to the solution
used in ndk-build except that the `--target=<triple><api-level>` argument
for Clang is injected by using cargo-ndk as a linker wrapper instead of
trying to modify CARGO_ENCODED_RUSTFLAGS.

It turned out to be practically impossible to be able to reliably
set CARGO_ENCODED_RUSTFLAGS without risking trampling over rustflags
that might be configured via Cargo (for example `target.<cfg>.rustflags`
are especially difficult to read outside of cargo itself)

This approach avoids hitting the command line length limitations of the
current workaround and avoids needing temporary hard links or copying
the cargo-ndk binary to the target/ directory.

Even though we've only seen quoting issues with the Windows `.cmd`
wrappers this change to avoid using the wrapper scripts is being
applied consistently for all platforms. E.g. considering the upstream
recommendation to avoid the wrapper scripts if possible:

https://android-review.googlesource.com/c/platform/ndk/+/2134712

Fixes: #92
Fixes: #104
Addresses: android/ndk#1856
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants