when compiling with cargo build --target armv7-linux-androideabi it is perfectly fine, no issues what so ever, but once i compile with cargo build --target armv7-linux-androideabi --release it throws this error
Ive tried many different linker versions, tried cargo build, cargo ndk -t target build etc and im so confused why its having issues compiling with --release when it compiles just fine without it and when compiling for aarch64-linux-android it has no issues in debug or release mode
the command line argument is quoted, but the linker is invoked through a .cmd shim, which messed up the quotes. it's strange that the debug build actually succeeded. can you try to get the full linker command invoked when building in debug mode?
My suggestion would be invoke clang.exe directly as linker command, and passing --target=armv7a-linux-androideabi22 by cargo instead rely on the cmd shim script.
when I try to manually invoke the ndk "clang.cmd" interactively,
Z:\>rem this succeeded:
Z:\>armv7a-linux-androideabi22-clang.cmd -march=armv7-a -c empty.c
Z:\>rem this also succeeded:
Z:\>armv7a-linux-androideabi22-clang.cmd -march="armv7-a" -c empty.c
Z:\>rem but this fails:
Z:\>armv7a-linux-androideabi22-clang.cmd "-march=armv7-a" -c empty.c
=armv7-a"" was unexpected at this time.
if you check the shim script, it contains following lines:
if "%1" == "-cc1" goto :L
set "_BIN_DIR=" && "%_BIN_DIR%clang.exe" --target=armv7a-linux-androideabi22 %*
if ERRORLEVEL 1 exit /b 1
rem Accommodate a quoted arg0, e.g.: "clang"
the actual offending line is:
if "%1" == "-cc1" goto :L
because %1 is "-march=armv7-a" in this case (note it's quoted), the if command expands to:
if ""-march=armv7-a"" == "-cc1" goto :L
which, due to the obscure quoting rules of cmd, cannot be parsed correctly. in this particular case, you can workaround it by simply get rid of the quote and use an old prefix trick:
if x%1 == xcc1 goto :L
but it's not a general solution, and I'm pretty sure it will break in other situations, such as when "cc1" is passed as first agument (i.e. %1) quoted. but that's the way cmd works.
interestingly enough, in the shim script, they linked to this issue
apparently, some one else also encountered other esoteric problems related to cmd expansion and quotation rules. I wonder why they didn't write their own shim wrapper program (it's stupidly trivial, e.g. scoop use it forever) but instead used cmd all the way
Thank you so much, i spent like 8-10h troubleshooting before making this post and got nowhere but because of you and the notes you left it compiled without a issue, i love so much man for helping and if you would like a donation for helping please let me know i can throw you like $10-$15 for the help