Re: Attempt to update ispc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2019-01-22 8:17 a.m., Serge Guelton wrote:
>
> Hi Luya,
>
> Clang does not support the -fstack-clash-protection flag. We used to silently ignore that flag but it's no longer the case.
> Why are you using clang to compile the package? The safe step is to use gcc, ot if clang is needed, to strip -fstack-clash-protection
> from the flags passed to clang, but that's not future-proof (clang may end up supporting that flag).
>
> Hope it helps,
>
> Serge
>

Upstream reason. Trying to build with gcc will fail. See the attacked
CMakeLists.txt from ispc-1.10.0


Luya

#
#  Copyright (c) 2018, Intel Corporation
#  All rights reserved.
#
#  Redistribution and use in source and binary forms, with or without
#  modification, are permitted provided that the following conditions are
#  met:
#
#    * Redistributions of source code must retain the above copyright
#      notice, this list of conditions and the following disclaimer.
#
#    * Redistributions in binary form must reproduce the above copyright
#      notice, this list of conditions and the following disclaimer in the
#      documentation and/or other materials provided with the distribution.
#
#    * Neither the name of Intel Corporation nor the names of its
#      contributors may be used to endorse or promote products derived from
#      this software without specific prior written permission.
#
#
#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
#   IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
#   TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
#   PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
#   OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
#   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
#   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
#   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
#   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
#   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#
# ispc CMakeLists.txt
#
cmake_minimum_required(VERSION 3.8)

if (UNIX)
    set(CMAKE_C_COMPILER "clang")
    set(CMAKE_CXX_COMPILER "clang++")
endif()

set(PROJECT_NAME ispc)
set(ISPC_BUILD TRUE)
project(${PROJECT_NAME})

option(ARM_ENABLED "Enable ARM support" OFF)
option(NVPTX_ENABLED "Enable NVPTX support" OFF)
option(ISPC_INCLUDE_EXAMPLES "Generate build targets for the ISPC examples" ON)
option(ISPC_INCLUDE_TESTS "Generate build targets for the ISPC tests." ON)
option(ISPC_INCLUDE_UTILS "Generate build targets for the utils." ON)
option(ISPC_PREPARE_PACKAGE "Generate build targets for ispc package" OFF)

if (UNIX)
    option(ISPC_STATIC_STDCXX_LINK "Link statically with libstdc++ and libgcc" OFF)
    if (ISPC_PREPARE_PACKAGE AND (NOT APPLE))
        option(ISPC_STATIC_LINK "Link statically" ON)
    else()
        option(ISPC_STATIC_LINK "Link statically" OFF)
    endif()
    option(ISPC_USE_ASAN "Build ispc with address sanitizer instrumentation using clang compiler" OFF)
endif()

# Use solution folders.
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

set(OUTPUT_DEBUG Debug/bin)
set(OUTPUT_RELEASE Release/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin )

if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE "Release")
    message(STATUS "Build type not specified: Use Release by default.")
endif(NOT CMAKE_BUILD_TYPE)

include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/FixWindowsPath.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/LLVMConfig.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Git.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/GenerateBuiltins.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Stdlib.cmake)

find_package(PythonInterp 2.7 REQUIRED)
    if (NOT PYTHONINTERP_FOUND)
        message(FATAL_ERROR "Python interpreter is not found")
    endif()

find_package(BISON 2.4 REQUIRED)
    if (BISON_FOUND)
        set(BISON_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/src/parse.yy)
        set(BISON_CPP_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/parse.cc)
        set(BISON_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/parse.hh
                         ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/parse.output)
        if (WIN32)
            win_path_to_cygwin(${BISON_INPUT} ${BISON_EXECUTABLE} BISON_INPUT)
        endif()
        add_custom_command (
            OUTPUT ${BISON_CPP_OUTPUT} ${BISON_OUTPUT}
            COMMAND ${BISON_EXECUTABLE} -d -t -v
                --output=${BISON_CPP_OUTPUT}
                ${BISON_INPUT}
            COMMENT "Generating parse.cc"
    )
    endif()

find_package(FLEX 2.5 REQUIRED)
    if (FLEX_FOUND)
        set(FLEX_INPUT  ${CMAKE_CURRENT_SOURCE_DIR}/src/lex.ll)
        set(FLEX_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lex.cpp)
        if (WIN32)
            win_path_to_cygwin(${FLEX_INPUT} ${FLEX_EXECUTABLE} FLEX_INPUT)
        endif()
        add_custom_command(
            OUTPUT ${FLEX_OUTPUT}
            COMMAND ${FLEX_EXECUTABLE}
                --outfile=${FLEX_OUTPUT}
                ${FLEX_INPUT}
            COMMENT "Generating lex.cpp"
        )
    endif()

set (ISPC_MASKS 1 8 16 32 64)
set (ISPC_TARGETS avx2-i64x4 avx11-i64x4 avx1-i64x4 avx1 avx1-x2 avx11 avx11-x2 avx2 avx2-x2
    sse2 sse2-x2 sse4-8 sse4-16 sse4 sse4-x2
    generic-4 generic-8 generic-16 generic-32 generic-64 generic-1 knl skx)

set(CLANG_LIBRARY_LIST clangFrontend clangDriver clangSerialization clangParse clangSema clangAnalysis clangAST clangBasic clangEdit clangLex)
set(LLVM_COMPONENTS engine ipo bitreader bitwriter instrumentation linker)
# Component "option" was introduced in 3.3 and starting with 3.4 it is required for the link step.
if (${LLVM_VERSION_NUMBER} VERSION_GREATER "3.3.0")
    set(LLVM_COMPONENTS ${LLVM_COMPONENTS} option)
endif()

if (ARM_ENABLED)
    list(APPEND LLVM_COMPONENTS arm)
    list(APPEND ISPC_TARGETS neon-32 neon-16 neon-8)
endif()
if (NVPTX_ENABLED)
    list(APPEND LLVM_COMPONENTS nvptx)
    list(APPEND ISPC_TARGETS nvptx)
endif()
get_llvm_libfiles(LLVM_LIBRARY_LIST ${LLVM_COMPONENTS})
get_llvm_cppflags(LLVM_CPP_FLAGS)

generate_target_builtins(BUILTIN_FILES ${ISPC_TARGETS})
generate_common_builtins(BUILTIN_CPP_FILES)
generate_stdlib(STDLIB_FILES ${ISPC_MASKS})

add_executable(${PROJECT_NAME} ${BUILTIN_FILES} ${BUILTIN_CPP_FILES}
               ${STDLIB_FILES} ${BISON_CPP_OUTPUT} ${FLEX_OUTPUT}
               ${CMAKE_CURRENT_SOURCE_DIR}/stdlib.ispc)

target_sources(${PROJECT_NAME}
    PRIVATE
        "src/ast.cpp"
        "src/ast.h"
        "src/builtins.cpp"
        "src/builtins.h"
        "src/cbackend.cpp"
        "src/ctx.cpp"
        "src/ctx.h"
        "src/decl.cpp"
        "src/decl.h"
        "src/expr.cpp"
        "src/expr.h"
        "src/func.cpp"
        "src/func.h"
        "src/ispc.cpp"
        "src/ispc.h"
        "src/ispc_version.h"
        "src/llvmutil.cpp"
        "src/llvmutil.h"
        "src/main.cpp"
        "src/module.cpp"
        "src/module.h"
        "src/opt.cpp"
        "src/opt.h"
        "src/stmt.cpp"
        "src/stmt.h"
        "src/sym.cpp"
        "src/sym.h"
        "src/type.cpp"
        "src/type.h"
        "src/util.cpp"
        "src/util.h"
        "src/parse.yy"
        "src/lex.ll"
)
# To show stdlib.ispc in VS solution:
if (WIN32)
    set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/stdlib.ispc" PROPERTIES HEADER_FILE_ONLY TRUE)
    source_group("ISPC" FILES "${CMAKE_CURRENT_SOURCE_DIR}/stdlib.ispc")
endif()

# Build definitions
target_compile_definitions(${PROJECT_NAME} PRIVATE ${LLVM_VERSION})
if (UNIX)
    string(TIMESTAMP BUILD_DATE "%Y%m%d")
    target_compile_definitions(${PROJECT_NAME} PRIVATE BUILD_DATE=\"${BUILD_DATE}\"
                            BUILD_VERSION=\"${GIT_COMMIT_HASH}\")
else()
    target_compile_definitions(${PROJECT_NAME} PRIVATE NOMINMAX)
    if (NOT CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
        target_compile_definitions(${PROJECT_NAME} PRIVATE NDEBUG)
    endif()
endif()

if (ARM_ENABLED)
    target_compile_definitions(${PROJECT_NAME} PRIVATE ISPC_ARM_ENABLED)
endif()
if (NVPTX_ENABLED)
    target_compile_definitions(${PROJECT_NAME} PRIVATE ISPC_NVPTX_ENABLED)
endif()

# Include directories
target_include_directories(${PROJECT_NAME} PRIVATE
                           ${LLVM_INCLUDE_DIRS}
                           ${CMAKE_CURRENT_SOURCE_DIR}/src
                           ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR})
# Compile options
if (UNIX)
    target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wno-sign-compare -Wno-unused-function -Werror ${LLVM_CPP_FLAGS})
    set_source_files_properties("src/cbackend.cpp" PROPERTIES COMPILE_FLAGS "-fno-exceptions")
else()
    target_compile_options(${PROJECT_NAME} PRIVATE /W3 /wd4146 /wd4800 /wd4996 /wd4355 /wd4624 /wd4244 /wd4141 /wd4291 /wd4018)
    set_source_files_properties(${FLEX_OUTPUT} PROPERTIES COMPILE_FLAGS "/wd4005 /wd4003")
    set_source_files_properties(${BISON_OUTPUT} PROPERTIES COMPILE_FLAGS "/wd4005 /wd4065")
endif()

if (${LLVM_VERSION_NUMBER} VERSION_GREATER "3.4.0")
    target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
    if (UNIX)
        set_target_properties(${PROJECT_NAME} PROPERTIES CXX_EXTENSIONS OFF)
        target_compile_options(${PROJECT_NAME} PRIVATE -Wno-c99-extensions -Wno-deprecated-register -fno-rtti)
        if (ISPC_USE_ASAN)
            target_compile_options(${PROJECT_NAME} PRIVATE -fsanitize=address)
        endif()
    endif()
endif()

# Link options
if (WIN32)
    if (NOT CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
        set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/OPT:REF /OPT:ICF")
    endif()
endif()

if (ISPC_STATIC_STDCXX_LINK)
    set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++")
endif()

if (ISPC_STATIC_LINK)
    set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-static")
endif()

if (ISPC_USE_ASAN)
    set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-fsanitize=address")
endif()

# Link against Clang libraries
foreach(clangLib ${CLANG_LIBRARY_LIST})
    find_library(${clangLib}Path NAMES ${clangLib} HINTS ${LLVM_LIBRARY_DIRS})
    list(APPEND CLANG_LIBRARY_FULL_PATH_LIST ${${clangLib}Path})
endforeach()
target_link_libraries(${PROJECT_NAME} ${CLANG_LIBRARY_FULL_PATH_LIST})

# Link against LLVM libraries
target_link_libraries(${PROJECT_NAME} ${LLVM_LIBRARY_LIST})
if (WIN32)
    target_link_libraries(${PROJECT_NAME} version.lib shlwapi.lib odbc32.lib odbccp32.lib)
else()
    target_link_libraries(${PROJECT_NAME} pthread dl)
    if (${LLVM_VERSION_NUMBER} VERSION_GREATER "3.4.0")
        target_link_libraries(${PROJECT_NAME} z)
    endif()
    if (APPLE)
        target_link_libraries(${PROJECT_NAME} curses)
    else()
        target_link_libraries(${PROJECT_NAME} tinfo)
        if (${LLVM_VERSION_NUMBER} VERSION_GREATER "3.3.0")
            target_link_libraries(${PROJECT_NAME} curses)
        endif()
    endif()
endif()

# Build target for utility checking host ISA
if (ISPC_INCLUDE_UTILS)
    add_executable(check_isa "")
    target_sources(check_isa PRIVATE check_isa.cpp)
    set_target_properties(check_isa PROPERTIES FOLDER "Utils")
    if (NOT ISPC_PREPARE_PACKAGE)
        install (TARGETS check_isa DESTINATION bin)
    endif()
endif()

if (ISPC_INCLUDE_EXAMPLES AND NOT ISPC_PREPARE_PACKAGE)
    add_subdirectory(examples)
endif()

if (ISPC_INCLUDE_TESTS AND NOT ISPC_PREPARE_PACKAGE)
    add_subdirectory(tests)
endif()

# Install
install (TARGETS ${PROJECT_NAME} DESTINATION bin)
if (ISPC_PREPARE_PACKAGE)
    install (DIRECTORY "${PROJECT_SOURCE_DIR}/examples/" DESTINATION examples)
    install (DIRECTORY "${PROJECT_SOURCE_DIR}/contrib/" DESTINATION contrib)
    install (FILES "${PROJECT_SOURCE_DIR}/LICENSE.txt" DESTINATION .)
    install (FILES "${PROJECT_SOURCE_DIR}/docs/ReleaseNotes.txt" DESTINATION .)
    include(ExternalProject)
    ExternalProject_Add(ispc_web
      GIT_REPOSITORY    https://github.com/ispc/ispc.github.com.git
      PREFIX ispc_web
      SOURCE_DIR ispc_web/repo
      CONFIGURE_COMMAND cmake -E echo "Skipping configure step."
      BUILD_COMMAND cmake -E echo "Skipping build step."
      INSTALL_COMMAND cmake -E echo "Skipping install step."
    )
    ExternalProject_Get_Property(ispc_web SOURCE_DIR)
    set(ISPC_WEB_SOURCE_DIR "${SOURCE_DIR}")
    set(ISPC_DOCS  ${ISPC_WEB_SOURCE_DIR}/faq.html
                   ${ISPC_WEB_SOURCE_DIR}/ispc.html
                   ${ISPC_WEB_SOURCE_DIR}/perfguide.html)

    install(FILES ${ISPC_DOCS} DESTINATION .)
    install(DIRECTORY "${ISPC_WEB_SOURCE_DIR}/css" DESTINATION css)

    # CPack configuration
    if (WIN32)
        set(CPACK_GENERATOR "ZIP")
    else()
        set(CPACK_GENERATOR "TGZ")
    endif()
    set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt")
    # Get ispc version
    file(READ "${CMAKE_CURRENT_SOURCE_DIR}/src/ispc_version.h" ispc_ver)
    string(REGEX MATCH "ISPC_VERSION \"([0-9]*)\.([0-9]*)\.([0-9]*[a-z]*)" _ ${ispc_ver})
    set(CPACK_PACKAGE_VERSION_MAJOR ${CMAKE_MATCH_1})
    set(CPACK_PACKAGE_VERSION_MINOR ${CMAKE_MATCH_2})
    set(CPACK_PACKAGE_VERSION_PATCH ${CMAKE_MATCH_3})
    include(CPack)
endif()
_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Users]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]

  Powered by Linux