noloader / cryptopp-cmake

CMake files for Crypto++ project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CheckCompilerOption is misdetecting PowerPC options

noloader opened this issue · comments

Due to some bad interactions with Clang, GCC and XLC on PowerPC we needed to tighten up some slop in the way we detect PowerPC features. CheckCompilerOption is misdetecting features now because an empty main is not enough. For example, an empty main reports the following on a POWER7 machine with a compiler that lacks POWER8:

-- Performing Test PPC_ALTIVEC_FLAG
-- Performing Test PPC_ALTIVEC_FLAG - Success
-- Option -mcpu=power7 -maltivec
-- Performing Test PPC_POWER7_FLAG
-- Performing Test PPC_POWER7_FLAG - Success
-- Option -mcpu=power8 -maltivec
-- Performing Test PPC_POWER8_FLAG
-- Performing Test PPC_POWER8_FLAG - Success

However, when we go to use POWER8 with a builtin like vec_add then a compile error surfaces.

[ 10%] Building CXX object CMakeFiles/cryptopp-object.dir/blake2s_simd.cpp.o
/home/noloader/cryptopp/blake2b_simd.cpp: In function 'void CryptoPP::BLAKE2_Compress64_POWER8(const byte*, CryptoPP::BLAKE2b_State&)':
/home/noloader/cryptopp/blake2b_simd.cpp:1129:47: error: invalid parameter combination for AltiVec intrinsic
     #define vec_ror_32(x) vec_rl(x, ROR32_MASK)

Fortunately, we have some test programs stashed away in TestPrograms. In fact we can test for almost all features on every platform we support. In this case we can accurately detect the availability:

$ c++ -mcpu=power8 -maltivec TestPrograms/test_ppc_power8.cxx    TestPrograms/test_ppc_power8.cxx: In function 'int main(int, char**)':
TestPrograms/test_ppc_power8.cxx:5:15: error: invalid parameter combination for AltiVec intrinsic
  z=vec_add(z,z);

I think we should be able to cutover cleanly based on my experience with GNUmakefile using the test programs.