[linux-port] Update CMake files. prepare for Linux. (#1312)

This CL makes changes to CMake files in order to:
1- disable things that are not supported on non-Windows platforms.
2- make cross-platform compilation possible.

It also brings back LLVM's config.guess (mirrors:
https://github.com/llvm-mirror/llvm/blob/master/cmake/config.guess)
This commit is contained in:
Ehsan 2018-05-29 15:19:37 -04:00 коммит произвёл GitHub
Родитель f28b030c74
Коммит 37c35f2f6e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
15 изменённых файлов: 1680 добавлений и 25 удалений

Просмотреть файл

@ -1,5 +1,4 @@
# See docs/CMake.html for instructions about how to build LLVM with CMake.
cmake_minimum_required(VERSION 2.8.12.2)
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
@ -93,6 +92,13 @@ endif()
# SPIRV change starts
option(ENABLE_SPIRV_CODEGEN "Enables SPIR-V code generation." OFF)
option(SPIRV_BUILD_TESTS "Build targets for the SPIR-V unit tests." OFF)
# Enable SPIR-V CodeGen for Linux by default.
if(NOT WIN32)
set(ENABLE_SPIRV_CODEGEN ON)
set(SPIRV_BUILD_TESTS ON)
endif()
if (${SPIRV_BUILD_TESTS})
set(ENABLE_SPIRV_CODEGEN ON)
endif()
@ -429,6 +435,7 @@ endif (LLVM_USE_OPROFILE)
# HLSL Change: use 'Unknown' in place of "${LLVM_NATIVE_ARCH}"
message(STATUS "Constructing LLVMBuild project information")
execute_process(
COMMAND ${PYTHON_EXECUTABLE} ${LLVMBUILDTOOL}
--native-target Unknown
@ -590,7 +597,9 @@ endif( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
# enable warnings as errors for debug build
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /WX")
if (WIN32)
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /WX")
endif (WIN32)
include(AddLLVM)
include(TableGen)

1529
autoconf/config.guess поставляемый Executable file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -43,7 +43,7 @@ function(llvm_update_compile_flags name)
if (MSVC)
list(APPEND LLVM_COMPILE_FLAGS "/EHsc")
else (MSVC)
message(ERROR "Unimplemented")
# This is just the default exception handling on Linux
endif (MSVC)
endif (LLVM_ENABLE_EH)
add_definitions(/D_ITERATOR_DEBUG_LEVEL=0)

Просмотреть файл

@ -372,6 +372,15 @@ elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE )
append("-Wall -W -Wno-unused-parameter -Wwrite-strings" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
append("-Wcast-qual" CMAKE_CXX_FLAGS)
# Disable unknown pragma warnings because the output is just too long with them.
append("-Wno-unknown-pragmas" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
# Colorize GCC output even with ninja's stdout redirection.
if (CMAKE_COMPILER_IS_GNUCXX)
append("-fdiagnostics-color" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
append("-std=c++11" CMAKE_CXX_FLAGS)
endif (CMAKE_COMPILER_IS_GNUCXX)
# Turn off missing field initializer warnings for gcc to avoid noise from
# false positives with empty {}. Turn them on otherwise (they're off by
# default for clang).

7
external/CMakeLists.txt поставляемый
Просмотреть файл

@ -21,6 +21,9 @@ if (${ENABLE_SPIRV_CODEGEN})
if (IS_DIRECTORY ${DXC_SPIRV_TOOLS_DIR})
# We only need the library from SPIRV-Tools.
if (NOT WIN32)
add_compile_options(-Wno-covered-switch-default)
endif()
set(SPIRV_SKIP_EXECUTABLES ON CACHE BOOL "Skip building SPIRV-Tools executables")
set(SPIRV_TOOLS_EXTRA_DEFINITIONS /D_ITERATOR_DEBUG_LEVEL=0)
add_subdirectory(${DXC_SPIRV_TOOLS_DIR} EXCLUDE_FROM_ALL)
@ -63,7 +66,9 @@ if (${ENABLE_SPIRV_CODEGEN})
if (IS_DIRECTORY ${DXC_RE2_DIR})
# Avoid exception handling warning from MSVC.
# This add_compile_options() will only affect the current directory and its subdirectories.
add_compile_options(/EHs)
if (WIN32)
add_compile_options(/EHs)
endif()
# Don't build/run re2's tests.
set(RE2_BUILD_TESTING OFF CACHE BOOL "Skip RE2 tests")
add_subdirectory(${DXC_RE2_DIR} EXCLUDE_FROM_ALL)

Просмотреть файл

@ -1,4 +1,4 @@
set(LLVM_LINK_COMPONENTS support)
set(LLVM_LINK_COMPONENTS hlsl support)
set (HLSL_IGNORE_SOURCES
NSAPI.cpp
@ -63,8 +63,10 @@ add_clang_library(clangAST
VTTBuilder.cpp
LINK_LIBS
clangCodeGen
clangBasic
clangLex
clangSema
)
# MERGE REVIEW:

Просмотреть файл

@ -1,4 +1,5 @@
set(LLVM_LINK_COMPONENTS
HLSL # SemaHLSL.cpp references {Has|Get}UnsignedOpcode()
Support
)

Просмотреть файл

@ -31,6 +31,8 @@ add_subdirectory(dxopt)
add_subdirectory(dxl)
add_subdirectory(dxr)
add_subdirectory(dxv)
add_subdirectory(dotnetc)
if (WIN32) # UI powered by .NET
add_subdirectory(dotnetc)
endif (WIN32)
add_subdirectory(dxlib-sample)
# HLSL Change Ends

Просмотреть файл

@ -2,7 +2,9 @@
# This file is distributed under the University of Illinois Open Source License. See LICENSE.TXT for details.
# Builds dxa.exe
find_package(DiaSDK REQUIRED) # Used for constants and declarations.
if (WIN32)
find_package(DiaSDK REQUIRED) # Used for constants and declarations.
endif (WIN32)
set( LLVM_LINK_COMPONENTS
${LLVM_TARGETS_TO_BUILD}
@ -21,7 +23,9 @@ target_link_libraries(dxa
set_target_properties(dxa PROPERTIES VERSION ${CLANG_EXECUTABLE_VERSION})
include_directories(AFTER ${DIASDK_INCLUDE_DIRS})
if (WIN32)
include_directories(AFTER ${DIASDK_INCLUDE_DIRS})
endif (WIN32)
add_dependencies(dxa dxcompiler)

Просмотреть файл

@ -2,7 +2,9 @@
# This file is distributed under the University of Illinois Open Source License. See LICENSE.TXT for details.
# Builds dxc.exe
find_package(DiaSDK REQUIRED) # Used for constants and declarations.
if (WIN32)
find_package(DiaSDK REQUIRED) # Used for constants and declarations.
endif (WIN32)
set( LLVM_LINK_COMPONENTS
${LLVM_TARGETS_TO_BUILD}
@ -28,7 +30,9 @@ endif()
set_target_properties(dxc PROPERTIES VERSION ${CLANG_EXECUTABLE_VERSION})
hlsl_update_product_ver("dxc")
include_directories(AFTER ${DIASDK_INCLUDE_DIRS})
if (WIN32)
include_directories(AFTER ${DIASDK_INCLUDE_DIRS})
endif (WIN32)
add_dependencies(dxc dxcompiler)

Просмотреть файл

@ -1,6 +1,9 @@
# Copyright (C) Microsoft Corporation. All rights reserved.
# This file is distributed under the University of Illinois Open Source License. See LICENSE.TXT for details.
find_package(DiaSDK REQUIRED) # Used for constants and declarations.
if (WIN32)
find_package(DiaSDK REQUIRED) # Used for constants and declarations.
endif (WIN32)
set(LLVM_LINK_COMPONENTS
${LLVM_TARGETS_TO_BUILD}
@ -37,6 +40,7 @@ set(LLVM_LINK_COMPONENTS
vectorize
)
if (WIN32)
set(SOURCES
dxcapi.cpp
dxcassembler.cpp
@ -53,7 +57,28 @@ set(SOURCES
dxcutil.cpp
dxcdisassembler.cpp
dxclinker.cpp
)
)
else ()
set(SOURCES
dxcapi.cpp
dxcassembler.cpp
dxclibrary.cpp
dxcompilerobj.cpp
dxcfilesystem.cpp
dxcontainerbuilder.cpp
dxcutil.cpp
dxcdisassembler.cpp
dxillib.cpp
dxcvalidator.cpp
)
set (HLSL_IGNORE_SOURCES
dxcdia.cpp
DXCompiler.cpp
DXCompiler.rc
DXCompiler.def
dxclinker.cpp
)
endif(WIN32)
set(LIBRARIES
clangIndex
@ -86,14 +111,21 @@ set(GENERATED_HEADERS
)
add_clang_library(dxcompiler SHARED ${SOURCES})
target_link_libraries(dxcompiler PRIVATE ${LIBRARIES} ${DIASDK_LIBRARIES})
# SPIRV change starts
if (ENABLE_SPIRV_CODEGEN)
target_link_libraries(dxcompiler PRIVATE clangSPIRV)
endif (ENABLE_SPIRV_CODEGEN)
# SPIRV change ends
add_dependencies(dxcompiler DxcEtw)
include_directories(AFTER ${LLVM_INCLUDE_DIR}/dxc/Tracing ${DIASDK_INCLUDE_DIRS})
if (WIN32)
target_link_libraries(dxcompiler PRIVATE ${LIBRARIES} ${DIASDK_LIBRARIES})
if (ENABLE_SPIRV_CODEGEN)
target_link_libraries(dxcompiler PRIVATE clangSPIRV)
endif (ENABLE_SPIRV_CODEGEN)
add_dependencies(dxcompiler DxcEtw)
include_directories(AFTER ${LLVM_INCLUDE_DIR}/dxc/Tracing ${DIASDK_INCLUDE_DIRS})
else ()
# No DIASDK or DxcEtw on non-Windows platforms.
target_link_libraries(dxcompiler PRIVATE ${LIBRARIES})
if (ENABLE_SPIRV_CODEGEN)
target_link_libraries(dxcompiler PRIVATE clangSPIRV)
endif (ENABLE_SPIRV_CODEGEN)
include_directories(AFTER ${LLVM_INCLUDE_DIR}/dxc/Tracing)
endif (WIN32)
set_target_properties(dxcompiler
PROPERTIES

Просмотреть файл

@ -2,7 +2,9 @@
# This file is distributed under the University of Illinois Open Source License. See LICENSE.TXT for details.
# Builds dxl.exe
find_package(DiaSDK REQUIRED) # Used for constants and declarations.
if (WIN32)
find_package(DiaSDK REQUIRED) # Used for constants and declarations.
endif (WIN32)
set( LLVM_LINK_COMPONENTS
${LLVM_TARGETS_TO_BUILD}
@ -22,7 +24,9 @@ target_link_libraries(dxl
set_target_properties(dxl PROPERTIES VERSION ${CLANG_EXECUTABLE_VERSION})
include_directories(AFTER ${DIASDK_INCLUDE_DIRS})
if (WIN32)
include_directories(AFTER ${DIASDK_INCLUDE_DIRS})
endif (WIN32)
add_dependencies(dxl dxcompiler)

Просмотреть файл

@ -1,5 +1,6 @@
set(LLVM_OPTIONAL_SOURCES ARCMigrate.cpp) # HLSL Change - ignore file
if (WIN32)
set (HLSL_IGNORE_SOURCES
BuildSystem.cpp
)
@ -43,6 +44,51 @@ set(SOURCES
IndexingContext.h
../../include/clang-c/Index.h
)
else ()
set(SOURCES
# ARCMigrate.cpp # HLSL Change - remove ARCMigrate
CIndex.cpp
CIndexCXX.cpp
CIndexCodeCompletion.cpp
CIndexDiagnostic.cpp
CIndexHigh.cpp
CIndexInclusionStack.cpp
CIndexUSRs.cpp
CIndexer.cpp
CXComment.cpp
CXCursor.cpp
CXCompilationDatabase.cpp
CXLoadedDiagnostic.cpp
CXSourceLocation.cpp
CXStoredDiagnostic.cpp
CXString.cpp
CXType.cpp
IndexBody.cpp
IndexDecl.cpp
IndexTypeSourceInfo.cpp
Indexing.cpp
IndexingContext.cpp
dxcrewriteunused.cpp # HLSL Change
ADDITIONAL_HEADERS
CIndexDiagnostic.h
CIndexer.h
CXCursor.h
CXLoadedDiagnostic.h
CXSourceLocation.h
CXString.h
CXTranslationUnit.h
CXType.h
Index_Internal.h
IndexingContext.h
../../include/clang-c/Index.h
)
set (HLSL_IGNORE_SOURCES
BuildSystem.cpp
dxcisenseimpl.cpp # HLSL Change
)
endif(WIN32)
set(LIBS
clangAST

Просмотреть файл

@ -27,7 +27,7 @@ add_subdirectory(Sema)
add_subdirectory(CodeGen)
# FIXME: libclang unit tests are disabled on Windows due
# to failures, mostly in libclang.VirtualFileOverlay_*.
if(NOT WIN32)
if(NOT WIN32)
add_subdirectory(libclang)
endif()
@ -36,8 +36,10 @@ endif (CLANG_INCLUDE_TESTS) # HLSL Change
# HLSL Change Starts
if (HLSL_INCLUDE_TESTS)
add_subdirectory(HLSL)
add_subdirectory(HLSLHost)
if (WIN32) # These tests require MS specific TAEF and DIA SDK
add_subdirectory(HLSL)
add_subdirectory(HLSLHost)
endif (WIN32)
add_subdirectory(dxc_batch)
endif (HLSL_INCLUDE_TESTS)

Просмотреть файл

@ -25,10 +25,16 @@ target_link_libraries(clang-spirv-tests
clangCodeGen
clangFrontend
clangSPIRV
dxcompiler
effcee
SPIRV-Tools
)
# This is necessary so that the linked dxcompiler is loaded into memory space
# first, and in case dxcompiler.so is loaded via 'dlopen', it resolves to the
# same memory space, and prevents getting two copies of global static variables.
add_dependencies(clang-spirv-tests dxcompiler)
target_include_directories(clang-spirv-tests
PRIVATE ${SPIRV_TOOLS_INCLUDE_DIR} ${DXC_EFFCEE_DIR})