[Openmp-dev] PPC64 patch from Intel's fourth cmake patch
Peyton, Jonathan L
jonathan.l.peyton at intel.com
Wed Aug 6 16:07:37 PDT 2014
C. Bergström, Carlo,
>> ---------
>> using uname to detect the host/target was rejected before. Please use
>> the "cmake" way of detecting things.
>> +EXECUTE_PROCESS( COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE
>> DETECT_ARCH )
>> +EXECUTE_PROCESS( COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE ARCH )
>>
>
>OK. I did some investigation on this and have done it again just now but was not able to find a way of doing this natively in cmake.
>Actually, I found comments about how cmake does not support this natively (may be an old cmake version).
>Can you suggest how to do this? (a link to a web page with an example is fine too).
I have done some research on this topic. You are both right :) . There is a cmakey way to get at uname output, and this particular variable is CMAKE_HOST_SYSTEM_PROCESSOR which
Is defined by uname -p (slightly different but seems to be preferred over uname -m for reasons I'm not sure). You can actually see this in the standard cmake modules located at:
/path/to/cmake_install_root/share/cmake-2.8/Modules/CMakeDetermineSystem.cmake
The problem with using this as an architecture detection mechanism: it is not standard. Some systems will define uname -p as x86_64, amd64, x64, etc. This information is embedded in the kernel, and I was not inclined to try to gather all possible values into a giant if() statement to determine if it was 64 bit x86 architecture (same for 32 bit x86).
So if there is a need to put something like this back in, use the CMAKE_HOST_SYSTEM_PROCESSOR variable because it won't mess up Windows builds that don't even have uname to depend on.
>>I don't see any blockers, but I do have some general feedback.
>>-------------
>>Why would we set 64bit pointer size to 32e - Seems wrong
>>
>>+ if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
>>+ set(arch 32 CACHE STRING "The architecture
>>to build for (32e/32/arm/ppc64). 32e is Intel(R) 64 architecture, 32 is
>>IA-32 architecture")
>>+ else()
>>+ set(arch 32e CACHE STRING "The architecture
>>to build for (32e/32/arm/ppc64). 32e is Intel(R) 64 architecture, 32 is
>>IA-32 architecture")
>>--------
>
>This code was in place before I made my additions. I am surprised that it was not noticed before.
>However, the code seems fine by me: if the size of the void * type is 4, then we assume the arch variable to the default 32 (x86_32). Otherwise, it assumes a 8 bytes void * type and it sets it to default 32e (x86_64).
Yes. This code is mine. Because of the above reasons, I thought "Well, there has to be some default architecture instead of the build system just error-ing out." So I picked x86 architecture as it is the most popular desktop architecture; perhaps I'm biased :). CMAKE_SIZEOF_VOID_P is determined via the compiler you send cmake -DCMAKE_C_COMPILER=<compiler>. I also had the configuration spit out the architecture it believes it is going to build to inform the user.
-- Johnny
More information about the Openmp-dev
mailing list