clMathLibraries / clBLAS

a software library containing BLAS functions written in OpenCL
Apache License 2.0
839 stars 240 forks source link

Only use the "-m32" or "-m64" compiler flags on x86. #222

Closed psyhtest closed 8 years ago

psyhtest commented 8 years ago

The following sets up either the "-m32" or "-m64" compiler flag depending on the pointer size:

        set(CMAKE_C_FLAGS "-m${TARGET_PLATFORM} ${CMAKE_C_FLAGS}")
        set(CMAKE_CXX_FLAGS "-m${TARGET_PLATFORM} ${CMAKE_CXX_FLAGS}")
        set(CMAKE_Fortran_FLAGS "-m${TARGET_PLATFORM} ${CMAKE_Fortran_FLAGS}")

Unfortunately, this appears to be x86 specific.

For example, my local GNU compiler for ARM does not support it:

$ gcc --version
gcc (Gentoo 5.3.0 p1.0, pie-0.6.5) 5.3.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ gcc -dumpmachine
armv7a-hardfloat-linux-gnueabi
$ gcc -m32
gcc: error: unrecognized command line option '-m32'

That's why I propose to use the "-dumpmachine" flag to get the target machine of the GNU compiler first. Then only use the flags if the returned string contains "86" (which matches, for example, both "x86_64" and "i586").

Thanks!