sfackler/rust-openssl

Cross Compilation on Windows for Android fails

ikeen0807 opened this issue · 0 comments

For some reason I cannot get my project to build openssl-sys. The reason for that are unescaped backslashes in the corresponding Makefile generated in the process. I have no clue on how to fix this. The makefile cannot find the clang.exe inside of the NDK folder, since it includes unescaped backslashes it thinks that the following is the path to my clang.exe:

.../AppData/Local/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/windows-x86_64binclang.exe

I also already spotted the mistake in the Makefile, which is making the build fail:

CROSS_COMPILE=
CC=$(CROSS_COMPILE)C:/Users/kema/AppData/Local/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/windows-x86_64\bin\clang.exe
CXX=$(CROSS_COMPILE)g++
CPPFLAGS=-DANDROID
CFLAGS=-Wall -O3 -fomit-frame-pointer --target=i686-linux-android24 -mstackrealign -O2 -ffunction-sections -fdata-sections -fPIC -gdwarf-2 -fno-omit-frame-pointer -m32
CXXFLAGS=-Wall -O3 --target=i686-linux-android24 -mstackrealign -O2 -ffunction-sections -fdata-sections -fPIC -gdwarf-2 -fno-omit-frame-pointer -m32

As seen above it tries to access the clang.exe via backslashes, which is probably because I am on windows. But I think its expecting unix-like paths.

For further background information in what kind of context this occurs. This is a Tauri 2.0 App and this occurs in the buidling process. Therfore I am using the command "npm run tauri android dev", where I cannot just pass variables into in order to influence the building process for openssl-sys.

I declared the openssl-sys dependency like this: openssl-sys = { version = "0.9.102", features = ["vendored"]}.

This is my configdata.pm dump:
Command line (with current working directory = .):

perl ./Configure --prefix=C:/.../.../.../target/i686-linux-android/debug/build/openssl-sys-edd4ed37b7f9bd7b/out/openssl-build/install --openssldir=/usr/local/ssl no-dso no-shared no-ssl3 no-tests no-comp no-zlib no-zlib-dynamic --libdir=lib no-md2 no-rc5 no-weak-ssl-ciphers no-camellia no-idea no-seed no-stdio linux-elf --target=i686-linux-android24 -mstackrealign -O2 -DANDROID -ffunction-sections -fdata-sections -fPIC -gdwarf-2 -fno-omit-frame-pointer -m32

Perl information:

perl
5.38.2 for x86_64-msys-thread-multi

Enabled features:

afalgeng
argon2
aria
asm
async
autoalginit
autoerrinit
autoload-config
bf
blake2
bulk
cached-fetch
cast
chacha
cmac
cmp
cms
ct
default-thread-pool
deprecated
des
dgram
dh
docs
dsa
dtls
ec
ec2m
ecdh
ecdsa
ecx
engine
err
filenames
gost
http
legacy
md4
mdc2
multiblock
nextprotoneg
ocb
ocsp
padlockeng
pic
pinshared
poly1305
posix-io
psk
quic
rc2
rc4
rdrand
rfc3779
rmd160
scrypt
secure-memory
siphash
siv
sm2
sm2-precomp
sm3
sm4
sock
srp
srtp
sse2
ssl
ssl-trace
static-engine
thread-pool
threads
tls
ts
ui-console
whirlpool
tls1
tls1-method
tls1_1
tls1_1-method
tls1_2
tls1_2-method
tls1_3
dtls1
dtls1-method
dtls1_2
dtls1_2-method

Disabled features:

acvp-tests          [cascade]        OPENSSL_NO_ACVP_TESTS
apps                [cascade]        OPENSSL_NO_APPS
asan                [default]        OPENSSL_NO_ASAN
brotli              [default]        OPENSSL_NO_BROTLI
brotli-dynamic      [default]        OPENSSL_NO_BROTLI_DYNAMIC
buildtest-c++       [default]
camellia            [option]         OPENSSL_NO_CAMELLIA (skip crypto/camellia)
capieng             [cascade]        OPENSSL_NO_CAPIENG
winstore            [not-windows]    OPENSSL_NO_WINSTORE
comp                [option]         OPENSSL_NO_COMP (skip crypto/comp)
crypto-mdebug       [default]        OPENSSL_NO_CRYPTO_MDEBUG
devcryptoeng        [default]        OPENSSL_NO_DEVCRYPTOENG
dso                 [option]         OPENSSL_NO_DSO
dynamic-engine      [cascade]
ec_nistp_64_gcc_128 [default]        OPENSSL_NO_EC_NISTP_64_GCC_128
egd                 [default]        OPENSSL_NO_EGD
external-tests      [default]        OPENSSL_NO_EXTERNAL_TESTS
fips                [default]
fips-securitychecks [cascade]        OPENSSL_NO_FIPS_SECURITYCHECKS
fuzz-afl            [default]        OPENSSL_NO_FUZZ_AFL
fuzz-libfuzzer      [default]        OPENSSL_NO_FUZZ_LIBFUZZER
idea                [option]         OPENSSL_NO_IDEA (skip crypto/idea)
ktls                [default]        OPENSSL_NO_KTLS
loadereng           [cascade]        OPENSSL_NO_LOADERENG
makedepend          [unavailable]
md2                 [option]         OPENSSL_NO_MD2 (skip crypto/md2)
module              [cascade]
msan                [default]        OPENSSL_NO_MSAN
rc5                 [option]         OPENSSL_NO_RC5 (skip crypto/rc5)
sctp                [default]        OPENSSL_NO_SCTP
seed                [option]         OPENSSL_NO_SEED (skip crypto/seed)
shared              [option]
stdio               [option]         OPENSSL_NO_STDIO
tests               [option]         OPENSSL_NO_TESTS
tfo                 [default]        OPENSSL_NO_TFO
trace               [default]        OPENSSL_NO_TRACE
ubsan               [default]        OPENSSL_NO_UBSAN
unit-test           [default]        OPENSSL_NO_UNIT_TEST
uplink              [no uplink_arch] OPENSSL_NO_UPLINK
weak-ssl-ciphers    [option]         OPENSSL_NO_WEAK_SSL_CIPHERS
zlib                [option]         OPENSSL_NO_ZLIB
zlib-dynamic        [option]         OPENSSL_NO_ZLIB_DYNAMIC
zstd                [default]        OPENSSL_NO_ZSTD
zstd-dynamic        [default]        OPENSSL_NO_ZSTD_DYNAMIC
ssl3                [option]         OPENSSL_NO_SSL3
ssl3-method         [default]        OPENSSL_NO_SSL3_METHOD

Config target attributes:

AR => "ar",
ARFLAGS => "qc",
CC => "gcc",
CFLAGS => "-Wall -O3 -fomit-frame-pointer",
CXX => "g++",
CXXFLAGS => "-Wall -O3",
HASHBANGPERL => "/usr/bin/env perl",
RANLIB => "ranlib",
RC => "windres",
asm_arch => "x86",
bn_ops => "BN_LLONG",
build_file => "Makefile",
build_scheme => [ "unified", "unix" ],
cflags => "-pthread",
cppflags => "",
cxxflags => "-std=c++11 -pthread",
defines => [ "OPENSSL_BUILDING_OPENSSL" ],
disable => [  ],
dso_ldflags => "-Wl,-z,defs",
dso_scheme => "dlfcn",
enable => [ "afalgeng" ],
ex_libs => "-ldl -pthread",
includes => [  ],
lflags => "",
lib_cflags => "",
lib_cppflags => "-DOPENSSL_USE_NODELETE -DL_ENDIAN",
lib_defines => [  ],
module_cflags => "-fPIC",
module_cxxflags => undef,
module_ldflags => "-Wl,-znodelete -shared -Wl,-Bsymbolic",
perl_platform => "Unix",
perlasm_scheme => "elf",
shared_cflag => "-fPIC",
shared_defflag => "-Wl,--version-script=",
shared_defines => [  ],
shared_ldflag => "-Wl,-znodelete -shared -Wl,-Bsymbolic",
shared_rcflag => "",
shared_sonameflag => "-Wl,-soname=",
shared_target => "linux-shared",
thread_defines => [  ],
thread_scheme => "pthreads",
unistd => "<unistd.h>",

Recorded environment:

AR = C:/Users/.../AppData/Local/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/windows-x86_64\bin\llvm-ar.exe
BUILDFILE =
CC = C:/Users/.../AppData/Local/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/windows-x86_64\bin\clang.exe
CFLAGS =
CPPFLAGS =
CROSS_COMPILE =
CXX =
CXXFLAGS =
HASHBANGPERL =
LDFLAGS = 
LDLIBS =
OPENSSL_LOCAL_CONFIG_DIR =
PERL =
RANLIB = llvm-ranlib
RC =
RCFLAGS =
WINDRES =
__CNF_CFLAGS =
__CNF_CPPDEFINES =
__CNF_CPPFLAGS =
__CNF_CPPINCLUDES =
__CNF_CXXFLAGS =
__CNF_LDFLAGS =
__CNF_LDLIBS =

Makevars:

AR              = C:/Users/.../AppData/Local/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/windows-x86_64\bin\llvm-ar.exe
ARFLAGS         = qc
ASFLAGS         =
CC              = C:/Users/.../AppData/Local/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/windows-x86_64\bin\clang.exe
CFLAGS          = -Wall -O3 -fomit-frame-pointer --target=i686-linux-android24 -mstackrealign -O2 -ffunction-sections -fdata-sections -fPIC -gdwarf-2 -fno-omit-frame-pointer -m32
CPPDEFINES      = ANDROID
CPPFLAGS        =
CPPINCLUDES     =
CXX             = g++
CXXFLAGS        = -Wall -O3 --target=i686-linux-android24 -mstackrealign -O2 -ffunction-sections -fdata-sections -fPIC -gdwarf-2 -fno-omit-frame-pointer -m32
HASHBANGPERL    = /usr/bin/env perl
LDFLAGS         =
LDLIBS          =
PERL            = perl
RANLIB          = llvm-ranlib
RC              = windres
RCFLAGS         =

NOTE: These variables only represent the configuration view. The build file
template may have processed these variables further, please have a look at the
build file for more exact data:
Makefile

build file:

Makefile

build file templates:

Configurations/common0.tmpl
Configurations/unix-Makefile.tmpl