[Beignet] [PATCH] Use matching versions of clang/llvm and libclang/libllvm

Zhigang Gong zhigang.gong at linux.intel.com
Mon Mar 23 22:12:10 PDT 2015


LGTM, will push latter. Thanks.

On Sat, Mar 21, 2015 at 07:34:22AM +0000, Rebecca N. Palmer wrote:
> Compile the OpenCL standard library with the same version of clang
> as will compile OpenCL user code, not plain "clang" (i.e. the
> system default version, which may be different).
> 
> Signed-off-by: Rebecca Palmer <rebecca_palmer at zoho.com>
> 
> diff --git a/CMake/FindLLVM.cmake b/CMake/FindLLVM.cmake
> index e214437..fa13f1d 100644
> --- a/CMake/FindLLVM.cmake
> +++ b/CMake/FindLLVM.cmake
> @@ -23,13 +23,15 @@ else (LLVM_CONFIG_EXECUTABLE)
>    message(FATAL_ERROR "Could NOT find LLVM executable, please add -DLLVM_INSTALL_DIR=/path/to/llvm-config/ in cmake command")
>  endif (LLVM_CONFIG_EXECUTABLE)
> +execute_process(
> +  COMMAND ${LLVM_CONFIG_EXECUTABLE} --version
> +  OUTPUT_VARIABLE LLVM_VERSION
> +  OUTPUT_STRIP_TRAILING_WHITESPACE
> +)
> +string(REGEX REPLACE "([0-9])\\.([0-9]*).*" "\\1\\2" LLVM_VERSION_NODOT ${LLVM_VERSION})
> +string(REGEX REPLACE "([0-9])\\.([0-9]*).*" "\\1.\\2" LLVM_VERSION_NOPATCH ${LLVM_VERSION})
>  if (LLVM_FIND_VERSION_MAJOR AND LLVM_FIND_VERSION_MINOR)
>    SET(LLVM_FIND_VERSION_NODOT "${LLVM_FIND_VERSION_MAJOR}${LLVM_FIND_VERSION_MINOR}")
> -  execute_process(
> -    COMMAND ${LLVM_CONFIG_EXECUTABLE} --version
> -    OUTPUT_VARIABLE LLVM_VERSION
> -  )
> -  string(REGEX REPLACE "([0-9])\\.([0-9]*).*" "\\1\\2 " LLVM_VERSION_NODOT ${LLVM_VERSION})
>    if (LLVM_VERSION_NODOT VERSION_LESS LLVM_FIND_VERSION_NODOT)
>      message(FATAL_ERROR "imcompatible LLVM version ${LLVM_VERSION} required ${LLVM_FIND_VERSION}")
>    else (LLVM_VERSION_NODOT VERSION_LESS LLVM_FIND_VERSION_NODOT)
> @@ -42,6 +44,25 @@ if (LLVM_FIND_VERSION_MAJOR AND LLVM_FIND_VERSION_MINOR)
>    endif (LLVM_VERSION_NODOT VERSION_LESS LLVM_FIND_VERSION_NODOT)
>  endif (LLVM_FIND_VERSION_MAJOR AND LLVM_FIND_VERSION_MINOR)
> +if (LLVM_INSTALL_DIR)
> +  find_program(CLANG_EXECUTABLE
> +               NAMES clang-${LLVM_VERSION_NODOT} clang-${LLVM_VERSION_NOPATCH} clang
> +               PATHS ${LLVM_INSTALL_DIR} NO_DEFAULT_PATH)
> +  find_program(LLVM_AS_EXECUTABLE
> +               NAMES llvm-as-${LLVM_VERSION_NODOT} llvm-as-${LLVM_VERSION_NOPATCH} llvm-as
> +               PATHS ${LLVM_INSTALL_DIR} NO_DEFAULT_PATH)
> +  find_program(LLVM_LINK_EXECUTABLE
> +               NAMES llvm-link-${LLVM_VERSION_NODOT} llvm-link-${LLVM_VERSION_NOPATCH} llvm-link
> +               PATHS ${LLVM_INSTALL_DIR} NO_DEFAULT_PATH)
> +else (LLVM_INSTALL_DIR)
> +  find_program(CLANG_EXECUTABLE
> +               NAMES clang-${LLVM_VERSION_NODOT} clang-${LLVM_VERSION_NOPATCH} clang)
> +  find_program(LLVM_AS_EXECUTABLE
> +               NAMES llvm-as-${LLVM_VERSION_NODOT} llvm-as-${LLVM_VERSION_NOPATCH} llvm-as)
> +  find_program(LLVM_LINK_EXECUTABLE
> +               NAMES llvm-link-${LLVM_VERSION_NODOT} llvm-link-${LLVM_VERSION_NOPATCH} llvm-link)
> +endif (LLVM_INSTALL_DIR)
> +
>  execute_process(
>    COMMAND ${LLVM_CONFIG_EXECUTABLE} --includedir
>    OUTPUT_VARIABLE LLVM_INCLUDE_DIR
> diff --git a/backend/src/libocl/CMakeLists.txt b/backend/src/libocl/CMakeLists.txt
> index 16f00ee..6b825b0 100644
> --- a/backend/src/libocl/CMakeLists.txt
> +++ b/backend/src/libocl/CMakeLists.txt
> @@ -136,7 +136,7 @@ MACRO(ADD_CL_TO_BC_TARGET _file)
>      ADD_CUSTOM_COMMAND(OUTPUT ${output_name}
>  	COMMAND mkdir -p ${OCL_OBJECT_DIR}/
>  	#COMMAND echo ${LLVM_INSTALL_DIR}clang -cc1 ${CLANG_OCL_FLAGS} -I ${LIBOCL_BINARY_DIR}/include/ -emit-llvm-bc -triple spir -o ${output_name} -x cl ${_file}
> -	COMMAND ${LLVM_INSTALL_DIR}clang -cc1 ${CLANG_OCL_FLAGS} -I ${OCL_OBJECT_DIR}/include/ -emit-llvm-bc -triple spir -o ${output_name} -x cl ${_file}
> +	COMMAND ${CLANG_EXECUTABLE} -cc1 ${CLANG_OCL_FLAGS} -I ${OCL_OBJECT_DIR}/include/ -emit-llvm-bc -triple spir -o ${output_name} -x cl ${_file}
>  	DEPENDS ${_file} ${OCL_HEADER_FILES}
>  	COMMENT "Compiling ${_file}"
>  	)
> @@ -175,7 +175,7 @@ MACRO(ADD_LL_TO_BC_TARGET M)
>      ADD_CUSTOM_COMMAND(OUTPUT ${output_name}
>  	COMMAND mkdir -p ${OCL_OBJECT_DIR}/
>  	#COMMAND echo ${LLVM_INSTALL_DIR}llvm-as -o ${output_name} ${srcll_name}
> -	COMMAND ${LLVM_INSTALL_DIR}llvm-as -o ${output_name} ${srcll_name}
> +	COMMAND ${LLVM_AS_EXECUTABLE} -o ${output_name} ${srcll_name}
>  	DEPENDS ${srcll_name}
>  	COMMENT "Compiling ${srcll_name}"
>  	)
> @@ -193,21 +193,21 @@ ENDFOREACH(f)
>  ADD_CUSTOM_COMMAND(OUTPUT ${OCL_OBJECT_DIR}/beignet.bc
>      COMMAND mkdir -p ${LIBOCL_BINARY_DIR}/lib/
>      #COMMAND echo llvm-link -o ${LIBOCL_BINARY_DIR}/lib/beignet.bc ${OCL_BC_FILES}
> -    COMMAND ${LLVM_INSTALL_DIR}llvm-link -o ${OCL_OBJECT_DIR}/beignet.bc ${OCL_BC_FILES}
> +    COMMAND ${LLVM_LINK_EXECUTABLE} -o ${OCL_OBJECT_DIR}/beignet.bc ${OCL_BC_FILES}
>      DEPENDS ${OCL_BC_FILES}
>      COMMENT "Generate the bitcode file: ${OCL_OBJECT_DIR}/beignet.bc"
>      )
>  ADD_CUSTOM_COMMAND(OUTPUT ${OCL_OBJECT_DIR}/beignet.local.pch
>      COMMAND mkdir -p ${OCL_OBJECT_DIR}
> -    COMMAND ${LLVM_INSTALL_DIR}clang -cc1 ${CLANG_OCL_FLAGS} -triple spir -I ${OCL_OBJECT_DIR}/include/ -emit-pch -x cl ${OCL_OBJECT_DIR}/include/ocl.h -o ${OCL_OBJECT_DIR}/beignet.local.pch
> +    COMMAND ${CLANG_EXECUTABLE} -cc1 ${CLANG_OCL_FLAGS} -triple spir -I ${OCL_OBJECT_DIR}/include/ -emit-pch -x cl ${OCL_OBJECT_DIR}/include/ocl.h -o ${OCL_OBJECT_DIR}/beignet.local.pch
>      DEPENDS ${OCL_HEADER_FILES}
>      COMMENT "Generate the pch file: ${OCL_OBJECT_DIR}/beignet.local.pch"
>      )
>  ADD_CUSTOM_COMMAND(OUTPUT ${OCL_OBJECT_DIR}/beignet.pch
>      COMMAND mkdir -p ${OCL_OBJECT_DIR}
> -    COMMAND ${LLVM_INSTALL_DIR}clang -cc1 ${CLANG_OCL_FLAGS} -triple spir -I ${OCL_OBJECT_DIR}/include/ --relocatable-pch -emit-pch -isysroot ${LIBOCL_BINARY_DIR} -x cl ${OCL_OBJECT_DIR}/include/ocl.h -o ${OCL_OBJECT_DIR}/beignet.pch
> +    COMMAND ${CLANG_EXECUTABLE} -cc1 ${CLANG_OCL_FLAGS} -triple spir -I ${OCL_OBJECT_DIR}/include/ --relocatable-pch -emit-pch -isysroot ${LIBOCL_BINARY_DIR} -x cl ${OCL_OBJECT_DIR}/include/ocl.h -o ${OCL_OBJECT_DIR}/beignet.pch
>      DEPENDS ${OCL_HEADER_FILES}
>      COMMENT "Generate the pch file: ${OCL_OBJECT_DIR}/beignet.pch"
>      )
> 
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list