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

error caused by cpu-features.c getting compiled with CXX #926

Closed
pagdot opened this issue Jan 28, 2020 · 1 comment · Fixed by #927
Closed

error caused by cpu-features.c getting compiled with CXX #926

pagdot opened this issue Jan 28, 2020 · 1 comment · Fixed by #927

Comments

@pagdot
Copy link
Contributor

pagdot commented Jan 28, 2020

Crypto++ Issue Report

armv7a-linux-androideabi24-clang++ -DNDEBUG -g2 -O3 -fPIC -pipe -Wall -march=armv7-a -mthumb -mfloat-abi=softfp -funwind-tables -fexceptions -frtti -DANDROID --sysroot=/home/paul/Android/Sdk/ndk/21.0.6113669//toolchains/llvm/prebuilt/linux-x86_64//sysroot -Wa,--noexecstack -I -I -fpermissive -c cpu-features.c
clang++: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
cpu-features.c:222:13: error: assigning to 'const char *' from incompatible type 'void *'
        p = memmem(p, bufend-p, field, fieldlen);
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cpu-features.c:234:10: error: assigning to 'const char *' from incompatible type 'const void *'
    p  = memchr(p, ':', bufend-p);
         ^~~~~~~~~~~~~~~~~~~~~~~~
cpu-features.c:240:9: error: assigning to 'const char *' from incompatible type 'const void *'
    q = memchr(p, '\n', bufend-p);
        ^~~~~~~~~~~~~~~~~~~~~~~~~
cpu-features.c:246:14: error: assigning to 'char *' from incompatible type 'void *'
    result = malloc(len+1);
             ^~~~~~~~~~~~~
cpu-features.c:399:13: error: assigning to 'const char *' from incompatible type 'const void *'
        q = memchr(p, ',', end-p);
            ^~~~~~~~~~~~~~~~~~~~~
cpu-features.c:693:15: error: assigning to 'char *' from incompatible type 'void *'
    cpuinfo = malloc(cpuinfo_len);
  • Fix: Changing compiler in GNUmakefile-cross from CXX to CC
@noloader
Copy link
Collaborator

noloader commented Jan 28, 2020

Thanks @pagdot.

I think the problem here is, we do very little with CC and we don't set CFLAGS since we are a C++ project. I don't want to maintain C projects settings for a C++ project. Also, the compiler folks say to compile everything with the same compiler, so I want to continue to use the C++ compiler.

We need Android to fix their bug. The bug was reported 4 years ago at Android Issue 65641866, Dirty compile when compiling cpu-feature.c with C++ compiler.

I think the way to proceed is, copy cpu-feature.c from the NDK to Crypto++ sources. Then, patch cpu-feature.c so that is builds cleanly. The copy happens in TestScripts/setenv-android.sh.

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

Successfully merging a pull request may close this issue.

2 participants