[Beignet] [PATCH] [PATCH]Enable ICC and CLANG compiler for beignet

Zhigang Gong zhigang.gong at linux.intel.com
Wed Aug 27 00:21:12 PDT 2014


This patch LGTM, but I don't have ICC installed on my machine.
Is there anybody can test it with ICC and let us know the result?
Thanks.

On Fri, Aug 22, 2014 at 04:26:37PM +0800, Lv Meng wrote:
> the 'COMPILER' is to choose the detail compiler,the default is GCC.
> Signed-off-by: Lv Meng <meng.lv at intel.com>
> ---
>  CMakeLists.txt         | 38 ++++++++++++++++++++++++----
>  backend/CMakeLists.txt | 67 ++------------------------------------------------
>  utests/CMakeLists.txt  |  4 +++
>  3 files changed, 39 insertions(+), 70 deletions(-)
> 
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index 82dbc8d..442bcda 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -1,3 +1,17 @@
> +# compiler choose,now support ICC,GCC CLANG compiler
> +set (COMPILER "GCC" CACHE INT "Compiler to choose on Linux (GCC,ICC,CLANG)")
> +if (COMPILER STREQUAL "GCC")
> +elseif (COMPILER STREQUAL "CLANG")
> +  set (CMAKE_C_COMPILER   "clang")
> +  set (CMAKE_CXX_COMPILER "clang++")
> +  find_program(CMAKE_AR NAMES llvm-ar)
> +  find_program(CMAKE_LINKER NAMES llvm-ld)
> +elseif (COMPILER STREQUAL "ICC")
> +  find_program(CMAKE_C_COMPILER NAMES icc)
> +  find_program(CMAKE_CXX_COMPILER NAMES icpc)
> +  find_program(CMAKE_AR NAMES xiar)
> +  find_program(CMAKE_LINKER NAMES xild)
> +endif ()
>  
>  CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0)
>  PROJECT(OCL)
> @@ -35,9 +49,6 @@ endif (NOT CMAKE_BUILD_TYPE)
>  set (CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "assure config" FORCE)
>  message(STATUS "Building mode: " ${CMAKE_BUILD_TYPE})
>  
> -SET(CMAKE_CXX_FLAGS_DEBUGO0 "-O0 -g")
> -SET(CMAKE_C_FLAGS_DEBUGO0 "-O0 -g")
> -
>  IF (EMULATE_HSW)
>    SET (USE_FULSIM "true")
>    ADD_DEFINITIONS(-DEMULATE_GEN=75)
> @@ -61,8 +72,25 @@ ELSE (USE_FULSIM)
>    ADD_DEFINITIONS(-DUSE_FULSIM=0)
>  ENDIF (USE_FULSIM)
>  
> -SET(CMAKE_CXX_FLAGS "-Wall -Wno-invalid-offsetof -mfpmath=sse -fno-rtti -Wcast-align -std=c++0x -msse2 -msse3 -mssse3 -msse4.1 ${CMAKE_CXX_FLAGS}")
> -SET(CMAKE_C_FLAGS "-Wall -mfpmath=sse -msse2 -Wcast-align -msse2 -msse3 -mssse3 -msse4.1 ${CMAKE_C_FLAGS}")
> +# compiler flag setting
> +if (COMPILER STREQUAL "GCC")
> +  set (CMAKE_C_CXX_FLAGS "${CMAKE_C_CXX_FLAGS} -funroll-loops -fstrict-aliasing -msse2 -msse3 -mssse3 -msse4.1 -fPIC -Wall -mfpmath=sse -Wcast-align -Wl,-E")
> +elseif (COMPILER STREQUAL "CLANG")
> +  set (CMAKE_C_CXX_FLAGS "${CMAKE_C_CXX_FLAGS} -funroll-loops -fstrict-aliasing -msse2 -msse3 -mssse3 -msse4.1 -fPIC -Wall")
> +elseif (COMPILER STREQUAL "ICC")
> +  set (CMAKE_C_CXX_FLAGS "${CMAKE_C_CXX_FLAGS}  -wd2928 -Wall -fPIC -fstrict-aliasing -fp-model fast -msse4.1 -Wl,-E")
> +endif ()
> +set (CMAKE_CXX_FLAGS "${CMAKE_C_CXX_FLAGS} -std=c++0x -Wno-invalid-offsetof -fno-rtti")
> +set (CMAKE_C_FLAGS "${CMAKE_C_CXX_FLAGS}")
> +set (CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined ${LLVM_LFLAGS}")
> +set (CMAKE_CXX_FLAGS_DEBUG          "-O0 -g -DGBE_DEBUG=1")
> +set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DGBE_DEBUG=1")
> +set (CMAKE_CXX_FLAGS_MINSIZEREL     "-Os -DNDEBUG -DGBE_DEBUG=0")
> +set (CMAKE_CXX_FLAGS_RELEASE        "-O2 -DNDEBUG -DGBE_DEBUG=0")
> +set (CMAKE_C_FLAGS_DEBUG          "-O0 -g -DGBE_DEBUG=1")
> +set (CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DGBE_DEBUG=1")
> +set (CMAKE_C_FLAGS_MINSIZEREL     "-Os -DNDEBUG -DGBE_DEBUG=0")
> +set (CMAKE_C_FLAGS_RELEASE        "-O2 -DNDEBUG -DGBE_DEBUG=0")
>  
>  # Front end stuff we need
>  #INCLUDE(CMake/FindLLVM.cmake)
> diff --git a/backend/CMakeLists.txt b/backend/CMakeLists.txt
> index ca674cf..e19f92d 100644
> --- a/backend/CMakeLists.txt
> +++ b/backend/CMakeLists.txt
> @@ -13,12 +13,6 @@ set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${GBE_CMAKE_DIR}")
>  set (GBE_DEBUG_MEMORY false CACHE bool "Activate the memory debugger")
>  set (GBE_USE_BLOB false CACHE bool "Compile everything from one big file")
>  
> -##############################################################
> -# Compiler
> -##############################################################
> -if (UNIX)
> -  set (COMPILER "GCC" CACHE INT "Compiler to choose on Linux (GCC,ICC,CLANG)")
> -endif (UNIX)
>  
>  # Force Release with debug info
>  if (NOT CMAKE_BUILD_TYPE)
> @@ -34,65 +28,8 @@ else (GBE_DEBUG_MEMORY)
>  endif (GBE_DEBUG_MEMORY)
>  
>  # Hide all symbols and allows the symbols declared as visible to be exported
> -set (CMAKE_C_CXX_FLAGS "-fvisibility=hidden ${CMAKE_C_CXX_FLAGS}")
> -
> -set (CMAKE_C_CXX_FLAGS -DGBE_COMPILER_AVAILABLE=1)
> -
> -if (COMPILER STREQUAL "GCC")
> -  set (CMAKE_C_CXX_FLAGS "${CMAKE_C_CXX_FLAGS} -funroll-loops -Wstrict-aliasing=2 -fstrict-aliasing -msse2 -msse3 -mssse3 -msse4.1 -fPIC -Wall")
> -  set (CMAKE_C_CXX_FLAGS "${CMAKE_C_CXX_FLAGS}  ${LLVM_CFLAGS}")
> -  set (CMAKE_CXX_FLAGS "${CMAKE_C_CXX_FLAGS}  -Wno-invalid-offsetof -fno-rtti -std=c++0x")
> -  set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GBE_DEBUG_MEMORY_FLAG}")
> -  set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GBE_COMPILE_UTESTS_FLAG}")
> -  set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-E")
> -  set (CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined ${LLVM_LFLAGS}")
> -  set (CMAKE_CXX_FLAGS_DEBUG          "-g -DGBE_DEBUG=1")
> -  set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DGBE_DEBUG=1")
> -  set (CMAKE_CXX_FLAGS_MINSIZEREL     "-Os -DNDEBUG -DGBE_DEBUG=0")
> -  set (CMAKE_CXX_FLAGS_RELEASE        "-O2 -DNDEBUG -DGBE_DEBUG=0")
> -  set (CMAKE_C_FLAGS "${CMAKE_C_CXX_FLAGS}")
> -  set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GBE_DEBUG_MEMORY_FLAG}")
> -  set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GBE_COMPILE_UTESTS_FLAG}")
> -  set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-E")
> -  set (CMAKE_C_FLAGS_DEBUG          "-g -DGBE_DEBUG=1")
> -  set (CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DGBE_DEBUG=1")
> -  set (CMAKE_C_FLAGS_MINSIZEREL     "-Os -DNDEBUG -DGBE_DEBUG=0")
> -  set (CMAKE_C_FLAGS_RELEASE        "-O2 -DNDEBUG -DGBE_DEBUG=0")
> -elseif (COMPILER STREQUAL "CLANG")
> -  set (CMAKE_C_COMPILER             "clang")
> -  set (CMAKE_C_FLAGS                "-Wall -std=c99")
> -  set (CMAKE_C_FLAGS_DEBUG          "-g -DGBE_DEBUG=1")
> -  set (CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DGBE_DEBUG=1")
> -  set (CMAKE_C_FLAGS_MINSIZEREL     "-Os -DNDEBUG -DGBE_DEBUG=0")
> -  set (CMAKE_C_FLAGS_RELEASE        "-O2 -DNDEBUG -DGBE_DEBUG=0")
> -  set (CMAKE_CXX_COMPILER             "clang++")
> -  set (CMAKE_CXX_FLAGS "-fstrict-aliasing -msse2 -fPIC -Wall -Wno-format-security -Wno-invalid-offsetof -std=c++0x")
> -  set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GBE_DEBUG_MEMORY_FLAG}")
> -  set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GBE_COMPILE_UTESTS_FLAG}")
> -  set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${VISIBILITY_FLAG}")
> -  set (CMAKE_CXX_FLAGS_DEBUG          "-g -DGBE_DEBUG=1")
> -  set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DGBE_DEBUG=1")
> -  set (CMAKE_CXX_FLAGS_MINSIZEREL     "-Os -DNDEBUG -DGBE_DEBUG=0")
> -  set (CMAKE_CXX_FLAGS_RELEASE        "-O2 -DNDEBUG -DGBE_DEBUG=0")
> -  set (CMAKE_AR      "/usr/bin/llvm-ar")
> -  set (CMAKE_LINKER  "/usr/bin/llvm-ld")
> -  set (CMAKE_NM      "/usr/bin/llvm-nm")
> -  set (CMAKE_OBJDUMP "/usr/bin/llvm-objdump")
> -  set (CMAKE_RANLIB  "ranlib")
> -elseif (COMPILER STREQUAL "ICC")
> -  set (CMAKE_CXX_COMPILER "icpc")
> -  set (CMAKE_C_COMPILER "icc")
> -  set (CMAKE_CXX_FLAGS "-std=c++0x -wd2928 -Wall -fPIC -fstrict-aliasing -fp-model fast -xSSE2")
> -  set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GBE_DEBUG_MEMORY_FLAG}")
> -  set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GBE_COMPILE_UTESTS_FLAG}")
> -  set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${VISIBILITY_FLAG} -Wl,-E")
> -  set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GBE_DEBUG_MODE_FLAG}")
> -  set (CMAKE_CXX_FLAGS_DEBUG "-g -O0 -DGBE_DEBUG=1")
> -  set (CCMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O2 -DGBE_DEBUG=1")
> -  set (CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O2 -DGBE_DEBUG=0")
> -  set (CCMAKE_CXX_FLAGS_MINSIZEREL "-Os -DGBE_DEBUG=0")
> -  set (CMAKE_EXE_LINKER_FLAGS "")
> -endif ()
> +set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LLVM_CFLAGS} ${GBE_DEBUG_MEMORY_FLAG} ${GBE_COMPILE_UTESTS_FLAG} -DGBE_COMPILER_AVAILABLE=1 -fvisibility=hidden")
> +set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LLVM_CFLAGS} ${GBE_DEBUG_MEMORY_FLAG} ${GBE_COMPILE_UTESTS_FLAG} -DGBE_COMPILER_AVAILABLE=1")
>  
>  include_directories (${CMAKE_CURRENT_BINARY_DIR})
>  ##############################################################
> diff --git a/utests/CMakeLists.txt b/utests/CMakeLists.txt
> index 721e6f7..d363c3d 100644
> --- a/utests/CMakeLists.txt
> +++ b/utests/CMakeLists.txt
> @@ -226,6 +226,10 @@ else()
>  SET(UTESTS_REQUIRED_EGL_LIB "")
>  endif()
>  
> +if (COMPILER STREQUAL "CLANG")
> +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-tautological-compare")
> +endif ()
> +
>  ADD_LIBRARY(utests SHARED ${ADDMATHFUNC} ${utests_sources})
>  
>  TARGET_LINK_LIBRARIES(utests cl m ${OPENGL_LIBRARIES} ${UTESTS_REQUIRED_EGL_LIB} ${CMAKE_THREAD_LIBS_INIT})
> -- 
> 1.9.1
> 
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list