Skip to content

Commit

Permalink
Use clang 8 to build CUDA in macOS CI (pytorch#8355)
Browse files Browse the repository at this point in the history
* Don't use -faligned-new flag for clang < 9.0

* Select Xcode 8.2 toolchain when building CUDA

* Better comment
  • Loading branch information
yf225 committed Jun 12, 2018
1 parent 78e3259 commit 1f02ebd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 5 additions & 2 deletions .jenkins/pytorch/macos-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ if [[ "${JOB_BASE_NAME}" == *cuda9.2* ]]; then
export CUDA_HOME=/Developer/NVIDIA/CUDA-${CUDA_VERSION}
export NO_CUDA=0

# We need to do this for install_name_tool to be found
export PATH=/Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:$PATH
# Eigen gives "explicit specialization of class must precede its first use" error
# when compiling with Xcode 9.1 toolchain, so we have to use Xcode 8.2 toolchain instead.
export DEVELOPER_DIR=/Library/Developer/CommandLineTools
else
export DEVELOPER_DIR=/Applications/Xcode9.app/Contents/Developer
fi

export MACOSX_DEPLOYMENT_TARGET=10.9
Expand Down
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ if(APPLE)
set(CMAKE_FIND_APPBUNDLE LAST)
endif()

# Get clang version on macOS
if(APPLE)
EXECUTE_PROCESS( COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE clang_full_version_string )
string(REGEX REPLACE "Apple LLVM version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION_STRING ${clang_full_version_string})
MESSAGE( STATUS "CLANG_VERSION_STRING: " ${CLANG_VERSION_STRING} )
endif()

# ---[ Options.
# Note to developers: if you add an option below, make sure you also add it to
# cmake/Summary.cmake so that the summary prints out the option values.
Expand Down Expand Up @@ -232,7 +239,8 @@ if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-result")
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
if ((APPLE AND (NOT ("${CLANG_VERSION_STRING}" VERSION_LESS "9.0")))
OR (CMAKE_COMPILER_IS_GNUCXX AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -faligned-new")
endif()
if ($ENV{WERROR})
Expand Down

0 comments on commit 1f02ebd

Please sign in to comment.