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

Test executable fails to build #1

Closed
loganblevins opened this issue Oct 23, 2019 · 10 comments
Closed

Test executable fails to build #1

loganblevins opened this issue Oct 23, 2019 · 10 comments

Comments

@loganblevins
Copy link

Example:

[arm64-v8a] Compile++      : cryptopp_static <= zdeflate.cpp
[arm64-v8a] Compile++      : cryptopp_static <= zinflate.cpp
[arm64-v8a] Compile++      : cryptopp_static <= zlib.cpp
[arm64-v8a] StaticLibrary  : libcryptopp_static.a
[arm64-v8a] Compile        : cpufeatures <= cpu-features.c
[arm64-v8a] StaticLibrary  : libcpufeatures.a
[arm64-v8a] Executable     : cryptest.exe
/Users/logan.blevins/Documents/cryptopp/obj/local/arm64-v8a/libcryptopp_static.a(xed25519.o): In function `CryptoPP::x25519::SecretToPublicKey(unsigned char*, unsigned char const*) const':
/Users/logan.blevins/Documents/cryptopp/xed25519.cpp:145: undefined reference to `CryptoPP::Donna::curve25519_mult(unsigned char*, unsigned char const*)'
/Users/logan.blevins/Documents/cryptopp/obj/local/arm64-v8a/libcryptopp_static.a(xed25519.o): In function `CryptoPP::x25519::BERDecode(CryptoPP::BufferedTransformation&)':
/Users/logan.blevins/Documents/cryptopp/xed25519.cpp:202: undefined reference to `CryptoPP::Donna::curve25519_mult(unsigned char*, unsigned char const*)'
/Users/logan.blevins/Documents/cryptopp/obj/local/arm64-v8a/libcryptopp_static.a(xed25519.o): In function `CryptoPP::x25519::SecretToPublicKey(unsigned char*, unsigned char const*) const':
/Users/logan.blevins/Documents/cryptopp/xed25519.cpp:145: undefined reference to `CryptoPP::Donna::curve25519_mult(unsigned char*, unsigned char const*)'
/Users/logan.blevins/Documents/cryptopp/xed25519.cpp:145: undefined reference to `CryptoPP::Donna::curve25519_mult(unsigned char*, unsigned char const*)'
/Users/logan.blevins/Documents/cryptopp/xed25519.cpp:145: undefined reference to `CryptoPP::Donna::curve25519_mult(unsigned char*, unsigned char const*)'

Using NDK 20 on macOS 10.14.6

@noloader
Copy link
Owner

noloader commented Oct 23, 2019

Thanks @loganblevins,

cryptest.exe should build on all platforms (sans 32-bit iPhone and WatchOS due to some Clang problems).

Are you using Crypto++ Master? Or a release version?

@loganblevins
Copy link
Author

@noloader Building with 8.1 release and following your build instructions with ndk-build as close as possible.

@noloader
Copy link
Owner

noloader commented Oct 23, 2019

@loganblevins,

OK, thanks. That's due to cryptopp-android following Crypto++ Master. We'll add cryptopp-android release zip files with the next library release. (Prior to last week, the Android build was broken so there was no sense in releasing).

Go to Android.mk : 110, and change to the following. You need donna_32.cpp.

ifeq ($(TARGET_ARCH),arm64)
    CRYPTOPP_LIB_FILES := $(filter-out %avx.cpp,$(CRYPTOPP_LIB_FILES))
    CRYPTOPP_LIB_FILES := $(filter-out sse_simd.cpp,$(CRYPTOPP_LIB_FILES))
    # CRYPTOPP_LIB_FILES := $(filter-out donna_32.cpp,$(CRYPTOPP_LIB_FILES))
    CRYPTOPP_LIB_FILES := $(filter-out donna_sse.cpp,$(CRYPTOPP_LIB_FILES))
endif

If you switch to Crypto++ Master, then you will get about a 30% speedup in Integer multiply operations due to Commit 5499cefb8b54. Crypto++ Master does not need the workaround.

(The last commit to this repo, Commit 8b7b93b1773b, was the one the cut-over from 32-bit to 64-bit).

@loganblevins
Copy link
Author

Thank you for your prompt help - really appreciate it.

I had used your zip file on this release: https://github.com/noloader/cryptopp-android/tree/CRYPTOPP_8_1_0 coupled with cryptocpp 8.1 release thinking they'd work hand-in-hand but did not.

Was that incorrect thinking?

@loganblevins
Copy link
Author

loganblevins commented Oct 24, 2019

Alas, it seems the suggestion got me past my prior stumbling block on arm64 yet now have an integer problem on x86_64. I'm happy to switch to 8.2 or even master, but would prefer to build a tagged release for historical purposes.

[x86_64] Compile++      : cryptopp_static <= integer.cpp
rm -f /Users/logan.blevins/Documents/cryptopp/obj/local/x86_64/objs/cryptopp_static/integer.o
/Users/logan.blevins/Documents/screen-monitoring/.icebox/androidNDK/android-ndk-r20/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ -MMD -MP -MF /Users/logan.blevins/Documents/cryptopp/obj/local/x86_64/objs/cryptopp_static/integer.o.d -target x86_64-none-linux-android23 -fdata-sections -ffunction-sections -fstack-protector-strong -funwind-tables -no-canonical-prefixes  --sysroot /Users/logan.blevins/Documents/screen-monitoring/.icebox/androidNDK/android-ndk-r20/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -g -Wno-invalid-command-line-argument -Wno-unused-command-line-argument  -fno-addrsig -fno-exceptions -fno-rtti -fPIC -O2 -DNDEBUG  -I/Users/logan.blevins/Documents/screen-monitoring/.icebox/androidNDK/android-ndk-r20/sources/android/cpufeatures -I/Users/logan.blevins/Documents/screen-monitoring/.icebox/androidNDK/android-ndk-r20/sources/cxx-stl/llvm-libc++/include -I/Users/logan.blevins/Documents/screen-monitoring/.icebox/androidNDK/android-ndk-r20/sources/cxx-stl/llvm-libc++/../llvm-libc++abi/include -I/Users/logan.blevins/Documents/cryptopp -std=c++11    -DANDROID  -nostdinc++ -Wa,--noexecstack -Wformat -Werror=format-security -Wall -frtti -fexceptions  -c  /Users/logan.blevins/Documents/cryptopp/integer.cpp -o /Users/logan.blevins/Documents/cryptopp/obj/local/x86_64/objs/cryptopp_static/integer.o
/Users/logan.blevins/Documents/cryptopp/integer.cpp:650:2: error: unknown token in expression
        INTEL_NOPREFIX
        ^
/Users/logan.blevins/Documents/cryptopp/cpu.h:46:25: note: expanded from macro 'INTEL_NOPREFIX'
        #define INTEL_NOPREFIX ".intel_syntax;"
                               ^
<inline asm>:1:20: note: instantiated into assembly here
        .intel_syntax;neg %rcx;
                          ^
/Users/logan.blevins/Documents/cryptopp/integer.cpp:653:2: error: unknown token in expression
        AS2(    mov             %0,[%3+8*%1])
        ^
/Users/logan.blevins/Documents/cryptopp/cpu.h:812:20: note: expanded from macro 'AS2'
        #define AS2(x, y) GNU_AS2(x, y)
                          ^
/Users/logan.blevins/Documents/cryptopp/cpu.h:802:24: note: expanded from macro 'GNU_AS2'
        #define GNU_AS2(x, y) #x ", " #y ";" NEW_LINE
                              ^
<scratch space>:58:2: note: expanded from here
"mov %0"
 ^
...

@noloader
Copy link
Owner

noloader commented Oct 24, 2019

[x86_64] Compile++      : cryptopp_static <= integer.cpp
rm -f /Users/logan.blevins/Documents/cryptopp/obj/local/x86_64/objs/cryptopp_static/integer.o
/Users/logan.blevins/Documents/screen-monitoring/.icebox/androidNDK/android-ndk-r20/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ -MMD -MP -MF /Users/logan.blevins/Documents/cryptopp/obj/local/x86_64/objs/cryptopp_static/integer.o.d -target x86_64-none-linux-android23 -fdata-sections -ffunction-sections -fstack-protector-strong -funwind-tables -no-canonical-prefixes  --sysroot /Users/logan.blevins/Documents/screen-monitoring/.icebox/androidNDK/android-ndk-r20/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -g -Wno-invalid-command-line-argument -Wno-unused-command-line-argument  -fno-addrsig -fno-exceptions -fno-rtti -fPIC -O2 -DNDEBUG  -I/Users/logan.blevins/Documents/screen-monitoring/.icebox/androidNDK/android-ndk-r20/sources/android/cpufeatures -I/Users/logan.blevins/Documents/screen-monitoring/.icebox/androidNDK/android-ndk-r20/sources/cxx-stl/llvm-libc++/include -I/Users/logan.blevins/Documents/screen-monitoring/.icebox/androidNDK/android-ndk-r20/sources/cxx-stl/llvm-libc++/../llvm-libc++abi/include -I/Users/logan.blevins/Documents/cryptopp -std=c++11    -DANDROID  -nostdinc++ -Wa,--noexecstack -Wformat -Werror=format-security -Wall -frtti -fexceptions  -c  /Users/logan.blevins/Documents/cryptopp/integer.cpp -o /Users/logan.blevins/Documents/cryptopp/obj/local/x86_64/objs/cryptopp_static/integer.o
/Users/logan.blevins/Documents/cryptopp/integer.cpp:650:2: error: unknown token in expression
        INTEL_NOPREFIX
        ^
...

I think Crypto++ 8.1 has the old monolithic config.h.

You may need this in your config.h. It is present but commented-out:

#define CRYPTOPP_DISABLE_MIXED_ASM 1

I also added a section on the wiki at Android.mk | Problems. But I've got a feeling it is like trying to put out a fire with a wet sponge.

@noloader
Copy link
Owner

noloader commented Oct 24, 2019

@loganblevins,

Here's a script that will build Crypto++ 8.2 for Android...

Redacted. See the Comment 546494926.

@loganblevins
Copy link
Author

I have yet to try a new version. Prior we depended on 5.6.5 and after experiencing a mysterious, uncaught runtime exception on 8.1, we moved back to the original 5.6.5 for now. Thought it would be a problem to build 5.6.5 on NDK 20 though did have success on all but x86_64.

noloader added a commit that referenced this issue Oct 25, 2019
@noloader
Copy link
Owner

noloader commented Oct 25, 2019

@loganblevins,

You were right. From a policies and procedures point of view we need to supply something that builds against a release zip.

I added a cryptopp82 directory with the cryptopp-android.sh script ported to 8.2. I also added a top level heading Crypto++ 8.2 to the README. You are named in the README. If you don't want credit then please speak up.

I'm deleting the manual procedure a few comments up.

Thanks for pointing that out.

@loganblevins
Copy link
Author

Thank you for ongoing help - really appreciate it.

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

2 participants