[Bf-committers] Clang errors when compiling the Cycles CUDA kernel in Blender

Sen Haerens sen at senhaerens.be
Mon Feb 10 23:47:43 CET 2014


>> 2014-02-10 21:06 GMT+01:00 Brecht Van Lommel <brechtvanlommel at
pandora.be>:
>>
>>> It should possible to change the CUDA_NVCC_EXECUTABLE variable and add
>>> "-ccbin=/usr/bin/llvm-gcc-4.2".

Ccmake couldn't generate the config when I added that snippet to
CUDA_NVCC_EXECUTABLE.
CUDA_NVCC_FLAGS solved it but then you have to apply a small patch
(attached).

Compiling the kernel in Blender GUI is still broken because the nvcc
arguments are hardcoded in /intern/cycles/device/device_cuda.cpp:324. It
would be nice if it could apply the flags also.

2014-02-10 22:39 GMT+01:00 Jens Verwiebe <info at jensverwiebe.de>:

> See: Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
> Means you have an xcode that only comes with clang ( aka 5.x + )
> For CUDA kernelcompile with clang,you need CUDA 5.5 or higher !
> This is also documented by NVidia.

But there is a special case for 10.8 (Mountain Lion) which is documented:
http://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html#errata-cuda-tools-5-5

If you want to build with CUDA 5.0 and Xcode 5 on 10.8.5.
Nvcc requires: -ccbin=/usr/bin/llvm-gcc-4.2

If you want to build with CUDA 5.5 and Xcode 5 on 10.8.5.
Nvcc requires: -ccbin=/usr/bin/clang

I successfully tested both options.



On Mon, Feb 10, 2014 at 7:28 PM, Sen Haerens <sen at senhaerens.be> wrote:

> The kernel compilation succeeded by adding "-ccbin=/usr/bin/llvm-gcc-4.2"
> argument to nvcc and running manually.
> Could this be specified somewhere in cmake?
>
> It appears to be an issue in Mountain Lion (10.8.5).
>
> https://devtalk.nvidia.com/default/topic/608127/clang-error-on-os-x-10-8-5-samples-/
>
>
>
> On Mon, Feb 10, 2014 at 6:33 PM, Sen Haerens <sen at senhaerens.be> wrote:
>
>> Hi,
>>
>> I'm getting the following Clang errors when trying to compile the Cycles
>> CUDA kernel in Blender.
>>
>> Read new prefs: /Users/sen/Library/Application
>> Support/Blender/2.69/config/userpref.blend
>> found bundled python:
>> /Users/sen/Documents/Sources/blender_master/cmake/bin/blender.app/Contents/MacOS/2.69/python
>> Compiling CUDA kernel ...
>> "/Developer/NVIDIA/CUDA-5.0/bin/nvcc" -arch=sm_21 -m64 --cubin
>> "/Users/sen/Documents/Sources/blender_master/cmake/bin/blender.app/Contents/MacOS/2.69/scripts/addons/cycles/kernel/
>> kernel.cu" -o "/Users/sen/Library/Application
>> Support/Blender/2.69/cache/cycles_kernel_sm21_AB7D0ABB4691DC942DE6785DC3C9ADD1.cubin"
>> --ptxas-options="-v" --maxrregcount=32 --use_fast_math
>> -I"/Users/sen/Documents/Sources/blender_master/cmake/bin/blender.app/Contents/MacOS/2.69/scripts/addons/cycles/kernel"
>> -DNVCC -D__KERNEL_CUDA_VERSION__=50
>> clang: error: unsupported option '-dumpspecs'
>> clang: error: no input files
>> CUDA kernel compilation failed, see console for details.
>>
>> These are my build specs:
>>
>> Blender 2.69 (sub 10)
>> build date: 2014-02-10
>> build time: 18:04:36
>> build commit date: 2014-02-10
>>  build commit time: 16:45
>> build hash: d2b5f0f
>> build platform: Darwin
>>  build type: Release
>> build c flags:  -Wall -Werror=declaration-after-statement
>> -Werror=implicit-function-declaration -Werror=return-type
>> -Wno-tautological-compare -Wno-unknown-pragmas -Wno-char-subscripts
>> -Wstrict-prototypes -Wmissing-prototypes -Wunused-parameter
>>  -mmacosx-version-min=10.6  -msse2  -msse -pipe -funsigned-char
>>  build c++ flags:  -Wall -Wno-tautological-compare -Wno-unknown-pragmas
>> -Wno-char-subscripts -Wno-overloaded-virtual -Wno-sign-compare
>> -Wno-invalid-offsetof  -mmacosx-version-min=10.6 -ftemplate-depth=1024
>>  -msse2  -msse -pipe -funsigned-char
>>  build link flags: -fexceptions -framework CoreServices -framework
>> Foundation -framework IOKit -framework AppKit -framework Cocoa -framework
>> Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio
>> -framework QTKit -liconv
>>  build system: CMake
>>
>> Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
>> Target: x86_64-apple-darwin12.5.0
>> Thread model: posix
>>
>> nvcc: NVIDIA (R) Cuda compiler driver
>> Copyright (c) 2005-2012 NVIDIA Corporation
>> Built on Fri_Sep_28_16:10:16_PDT_2012
>> Cuda compilation tools, release 5.0, V0.2.1221
>>
>> TIA
>>
>
>
>
> --
> Sen Haerens | Sleutelstraat 9 1000 Brussels Belgium
> Tel +32 (0)2 880 90 25 | Cell +32 (0)473 86 50 35
> Vcard http://vcard.senhaerens.be/
>



-- 
Sen Haerens | Sleutelstraat 9 1000 Brussels Belgium
Tel +32 (0)2 880 90 25 | Cell +32 (0)473 86 50 35
Vcard http://vcard.senhaerens.be/
-------------- next part --------------
diff --git a/intern/cycles/cmake/external_libs.cmake b/intern/cycles/cmake/external_libs.cmake
index 8753ff4..9e5ac5d 100644
--- a/intern/cycles/cmake/external_libs.cmake
+++ b/intern/cycles/cmake/external_libs.cmake
@@ -23,7 +23,7 @@ endif()
 if(WITH_CYCLES_CUDA_BINARIES)
 	find_package(CUDA) # Try to auto locate CUDA toolkit
 	if(CUDA_FOUND)
-		message(STATUS "CUDA nvcc = ${CUDA_NVCC_EXECUTABLE}")
+		message(STATUS "CUDA nvcc = ${CUDA_NVCC_EXECUTABLE} ${CUDA_NVCC_FLAGS}")
 	else()
 		message(STATUS "CUDA compiler not found, disabling WITH_CYCLES_CUDA_BINARIES")
 		set(WITH_CYCLES_CUDA_BINARIES OFF)
diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt
index cbe0d4b..32639df 100644
--- a/intern/cycles/kernel/CMakeLists.txt
+++ b/intern/cycles/kernel/CMakeLists.txt
@@ -172,7 +172,7 @@ if(WITH_CYCLES_CUDA_BINARIES)
 		else()
 			add_custom_command(
 				OUTPUT ${cuda_cubin}
-				COMMAND ${CUDA_NVCC_EXECUTABLE} -arch=${arch} -m${CUDA_BITS} --cubin ${CMAKE_CURRENT_SOURCE_DIR}/kernel.cu -o ${CMAKE_CURRENT_BINARY_DIR}/${cuda_cubin} --ptxas-options="-v" ${cuda_arch_flags} ${cuda_version_flags} ${cuda_math_flags} -I${CMAKE_CURRENT_SOURCE_DIR}/../util -I${CMAKE_CURRENT_SOURCE_DIR}/svm -DCCL_NAMESPACE_BEGIN= -DCCL_NAMESPACE_END= -DNVCC
+				COMMAND ${CUDA_NVCC_EXECUTABLE} ${CUDA_NVCC_FLAGS} -arch=${arch} -m${CUDA_BITS} --cubin ${CMAKE_CURRENT_SOURCE_DIR}/kernel.cu -o ${CMAKE_CURRENT_BINARY_DIR}/${cuda_cubin} --ptxas-options="-v" ${cuda_arch_flags} ${cuda_version_flags} ${cuda_math_flags} -I${CMAKE_CURRENT_SOURCE_DIR}/../util -I${CMAKE_CURRENT_SOURCE_DIR}/svm -DCCL_NAMESPACE_BEGIN= -DCCL_NAMESPACE_END= -DNVCC
 				DEPENDS ${cuda_sources})
 
 			delayed_install("${CMAKE_CURRENT_BINARY_DIR}" "${cuda_cubin}" ${CYCLES_INSTALL_PATH}/lib)


More information about the Bf-committers mailing list