noloader / cryptopp-cmake

CMake files for Crypto++ project
BSD 3-Clause "New" or "Revised" License
92 stars 68 forks source link

Please add -qxlcompatmacros when using IBM XL C/C++ on PowerPC #27

Closed noloader closed 5 years ago

noloader commented 6 years ago

GCC112 is ppc64-le on the GCC compile farm. It looks like IBM cutover to LLVM for some of its compiler components. XL C/C++ no longer defines __xlc__ and __xlC__ by default. The result is a failed compile as Clang gets into code paths it can't handle even though it defines __GNUC__. Also see Where did XL C/C++ predefined macros go on GCC112? on the cfarm mailing list.

The workaround is to use -qxlcompatmacros for IBM XL C/C++ when available.

The GNUmakefile already has the patch. Autotools will be receiving it shortly. Autotools received the patch.

Please add -qxlcompatmacros to CXXFLAGS with IBM XL C/C++ on PowerPC when available.

noloader commented 6 years ago

@abdes,

If you want to work this problem then login to GCC112 on the compile farm using my username. I added your keys to my authorized_keys file:

ssh noloader@gcc112.fsffrance.org

Then, to test the problem:

CXX=xlC cmake ../

We are effectively sharing my home directory so carve out some workspace of your own. Clone into, say, cryptopp-abdes.

Also, / is mounted read-only so /tmp is not writeable by users. I set TMPDIR=$HOME/tmp in my .bashrc. Put your temp files there if needed.

noloader commented 6 years ago

And here is the error courtesy of LLVM and their stupid tricks:

CXX=xlC cmake ../
...

[ 14%] Building CXX object CMakeFiles/cryptopp-object.dir/chacha.cpp.o
/usr/bin/xlC    -O2 -g -DNDEBUG -fPIC   -o CMakeFiles/cryptopp-object.dir/chacha.cpp.o -c /home/noloader/cryptopp/chacha.cpp
/usr/bin/cmake -E cmake_progress_report /home/noloader/cryptopp/cmake_build/CMakeFiles 30
[ 15%] Building CXX object CMakeFiles/cryptopp-object.dir/cham-simd.cpp.o
/usr/bin/xlC    -O2 -g -DNDEBUG -fPIC   -o CMakeFiles/cryptopp-object.dir/cham-simd.cpp.o -c /home/noloader/cryptopp/cham-simd.cpp
In file included from /home/noloader/cryptopp/cham-simd.cpp:13:
In file included from /home/noloader/cryptopp/adv-simd.h:62:
/home/noloader/cryptopp/ppc-simd.h:443:16: error: use of undeclared identifier
      '__builtin_crypto_vcipher'; did you mean '__builtin_vec_vcipher'?
    return (T1)__builtin_crypto_vcipher((uint64x2_p)state, (uint64x2_p)key);
               ^~~~~~~~~~~~~~~~~~~~~~~~
               __builtin_vec_vcipher
/home/noloader/cryptopp/ppc-simd.h:443:16: note: '__builtin_vec_vcipher'
      declared here
/home/noloader/cryptopp/ppc-simd.h:443:41: error: cannot initialize a parameter
      of type '__attribute__((__vector_size__(16 * sizeof(unsigned char))))
      unsigned char' (vector of 16 'unsigned char' values) with an rvalue of
      type 'uint64x2_p' (vector of 2 'unsigned long long' values)
    return (T1)__builtin_crypto_vcipher((uint64x2_p)state, (uint64x2_p)key);
                                        ^~~~~~~~~~~~~~~~~
/home/noloader/cryptopp/ppc-simd.h:463:16: error: use of undeclared identifier
      '__builtin_crypto_vcipherlast'; did you mean '__builtin_vec_vcipherlast'?
    return (T1)__builtin_crypto_vcipherlast((uint64x2_p)state, (uint64x2_p)key);
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
               __builtin_vec_vcipherlast
/home/noloader/cryptopp/ppc-simd.h:463:16: note: '__builtin_vec_vcipherlast'
      declared here
/home/noloader/cryptopp/ppc-simd.h:463:45: error: cannot initialize a parameter
      of type '__attribute__((__vector_size__(16 * sizeof(unsigned char))))
      unsigned char' (vector of 16 'unsigned char' values) with an rvalue of
      type 'uint64x2_p' (vector of 2 'unsigned long long' values)
    return (T1)__builtin_crypto_vcipherlast((uint64x2_p)state, (uint64x2_p)key);
                                            ^~~~~~~~~~~~~~~~~
/home/noloader/cryptopp/ppc-simd.h:483:16: error: use of undeclared identifier
      '__builtin_crypto_vncipher'; did you mean '__builtin_vec_vncipher'?
    return (T1)__builtin_crypto_vncipher((uint64x2_p)state, (uint64x2_p)key);
               ^~~~~~~~~~~~~~~~~~~~~~~~~
               __builtin_vec_vncipher
/home/noloader/cryptopp/ppc-simd.h:443:16: note: '__builtin_vec_vncipher'
      declared here
    return (T1)__builtin_crypto_vcipher((uint64x2_p)state, (uint64x2_p)key);
               ^
/home/noloader/cryptopp/ppc-simd.h:483:42: error: cannot initialize a parameter
      of type '__attribute__((__vector_size__(16 * sizeof(unsigned char))))
      unsigned char' (vector of 16 'unsigned char' values) with an rvalue of
      type 'uint64x2_p' (vector of 2 'unsigned long long' values)
    return (T1)__builtin_crypto_vncipher((uint64x2_p)state, (uint64x2_p)key);
                                         ^~~~~~~~~~~~~~~~~
/home/noloader/cryptopp/ppc-simd.h:503:16: error: use of undeclared identifier
      '__builtin_crypto_vncipherlast'; did you mean
      '__builtin_vec_vncipherlast'?
    return (T1)__builtin_crypto_vncipherlast((uint64x2_p)state, (uint64x...
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
               __builtin_vec_vncipherlast
/home/noloader/cryptopp/ppc-simd.h:463:16: note: '__builtin_vec_vncipherlast'
      declared here
    return (T1)__builtin_crypto_vcipherlast((uint64x2_p)state, (uint64x2_p)key);
               ^
/home/noloader/cryptopp/ppc-simd.h:503:46: error: cannot initialize a parameter
      of type '__attribute__((__vector_size__(16 * sizeof(unsigned char))))
      unsigned char' (vector of 16 'unsigned char' values) with an rvalue of
      type 'uint64x2_p' (vector of 2 'unsigned long long' values)
    return (T1)__builtin_crypto_vncipherlast((uint64x2_p)state, (uint64x...
                                             ^~~~~~~~~~~~~~~~~
/home/noloader/cryptopp/ppc-simd.h:527:15: error: use of undeclared identifier
      '__builtin_crypto_vshasigmaw'; did you mean '__builtin_vec_vshasigmaw'?
    return (T)__builtin_crypto_vshasigmaw((uint32x4_p)vec, func, subfunc);
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~
              __builtin_vec_vshasigmaw
/home/noloader/cryptopp/ppc-simd.h:527:15: note: '__builtin_vec_vshasigmaw'
      declared here
/home/noloader/cryptopp/ppc-simd.h:547:15: error: use of undeclared identifier
      '__builtin_crypto_vshasigmad'; did you mean '__builtin_vec_vshasigmad'?
    return (T)__builtin_crypto_vshasigmad((uint64x2_p)vec, func, subfunc);
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~
              __builtin_vec_vshasigmad
/home/noloader/cryptopp/ppc-simd.h:527:15: note: '__builtin_vec_vshasigmad'
      declared here
    return (T)__builtin_crypto_vshasigmaw((uint32x4_p)vec, func, subfunc);
              ^
10 errors generated.
Error while processing /home/noloader/cryptopp/cham-simd.cpp.
make[2]: *** [CMakeFiles/cryptopp-object.dir/cham-simd.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory `/home/noloader/cryptopp/cmake_build'
make[1]: *** [CMakeFiles/cryptopp-object.dir/all] Error 2
make[1]: Leaving directory `/home/noloader/cryptopp/cmake_build'
make: *** [all] Error 2
make failed
noloader commented 6 years ago

@abdes,

I was looking at the CMakeList.txt. There's no XLC code at the moment. If you take the task then you will have a clean slate.

You can find out the flags to use by visiting BASE+SIMD | Arch Options on the wiki. It is most accurate but sometimes out of date.

You can also examine flags by running GNUmakefile.

$ make -j 8
g++ -DNDEBUG -g2 -O3 -fPIC -pthread -pipe -c cryptlib.cpp
g++ -DNDEBUG -g2 -O3 -fPIC -pthread -pipe -c cpu.cpp
...
g++ -DNDEBUG -g2 -O3 -fPIC -pthread -pipe -mcpu=power4 -maltivec -c aria-simd.cpp
...

And:

$ CXX=xlC make -j 8
xlC -DNDEBUG -g2 -O3 -qxlcompatmacros -qrtti -qpic -c cryptlib.cpp
xlC -DNDEBUG -g2 -O3 -qxlcompatmacros -qrtti -qpic -c cpu.cpp
xlC -DNDEBUG -g2 -O3 -qxlcompatmacros -qrtti -qpic -c integer.cpp
...
xlC -DNDEBUG -g2 -O3 -qxlcompatmacros -qrtti -qpic -qarch=pwr8 -qaltivec -c aria-simd.cpp

This may be easier:

$ make -j 8 | grep '\-mcpu'
g++ -DNDEBUG -g2 -O3 -fPIC -pthread -pipe -mcpu=power4 -maltivec -c aria-simd.cpp
g++ -DNDEBUG -g2 -O3 -fPIC -pthread -pipe -mcpu=power4 -maltivec -c blake2-simd.cpp
g++ -DNDEBUG -g2 -O3 -fPIC -pthread -pipe -mcpu=power8 -maltivec -c cham-simd.cpp
g++ -DNDEBUG -g2 -O3 -fPIC -pthread -pipe -mcpu=power8 -maltivec -c gcm-simd.cpp
g++ -DNDEBUG -g2 -O3 -fPIC -pthread -pipe -mcpu=power8 -maltivec -c lea-simd.cpp
g++ -DNDEBUG -g2 -O3 -fPIC -pthread -pipe -mcpu=power8 -maltivec -c ppc-simd.cpp
g++ -DNDEBUG -g2 -O3 -fPIC -pthread -pipe -mcpu=power8 -maltivec -c rijndael-simd.cpp
g++ -DNDEBUG -g2 -O3 -fPIC -pthread -pipe -mcpu=power8 -maltivec -c sha-simd.cpp
g++ -DNDEBUG -g2 -O3 -fPIC -pthread -pipe -mcpu=power8 -maltivec -c shacal2-simd.cpp
g++ -DNDEBUG -g2 -O3 -fPIC -pthread -pipe -mcpu=power8 -maltivec -c simeck-simd.cpp
g++ -DNDEBUG -g2 -O3 -fPIC -pthread -pipe -mcpu=power8 -maltivec -c simon-simd.cpp
g++ -DNDEBUG -g2 -O3 -fPIC -pthread -pipe -mcpu=power8 -maltivec -c sm4-simd.cpp
g++ -DNDEBUG -g2 -O3 -fPIC -pthread -pipe -mcpu=power8 -maltivec -c speck-simd.cpp
abdes commented 6 years ago

There is one bigger thing that needs to be done once and for all: a better platform/compiler detection that works with the cmake 2.8.6. It's a big task but a necessary one to reduce the clutter and the repetitive code in the CmakeLists.txt as of today. It could be something along what is being done in the GnuMakefile. It will need some time (a couple of days and a lot of testing) before it gets integrated into the main branch. I have it on my todo list.

noloader commented 6 years ago

... better platform/compiler detection that works with the cmake 2.8.6.

Yeah, agree. The compiler and platform detection code needs more work. We used to spend hours on it trying to get it right.

If you start messing with it be sure to test MinGW and Cygwin. I think Cygwin was the unusual one. @anonimal and I spent a day or two tracking down a problem with it.

What we really need is a platform agnostic way to get a terminal using the current shell and execute commands. CMake currently lacks it.

noloader commented 5 years ago

Cleared at Commit 4e70020f96a4.