commit dd9a1f48e74d637855213fa46ce6709ad41015b2 Author: overweight <5324761+overweight@user.noreply.gitee.com> Date: Mon Sep 30 11:02:31 2019 -0400 Package init diff --git a/0001-CMake-Don-t-prefer-python2.7.patch b/0001-CMake-Don-t-prefer-python2.7.patch new file mode 100644 index 0000000..ddea299 --- /dev/null +++ b/0001-CMake-Don-t-prefer-python2.7.patch @@ -0,0 +1,27 @@ +From 1e0f1c5481a96d760f7840d4dde103353a0131f8 Mon Sep 17 00:00:00 2001 +From: Tom Stellard +Date: Thu, 30 Aug 2018 11:38:51 -0700 +Subject: [PATCH] CMake: Don't prefer python2.7 + +--- + CMakeLists.txt | 4 ---- + 1 file changed, 4 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 31df640..2603f1c 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -613,10 +613,6 @@ message(STATUS "LLVM default target triple: ${LLVM_DEFAULT_TARGET_TRIPLE}") + + include(HandleLLVMOptions) + +-# Verify that we can find a Python 2 interpreter. Python 3 is unsupported. +-# FIXME: We should support systems with only Python 3, but that requires work +-# on LLDB. +-set(Python_ADDITIONAL_VERSIONS 2.7) + include(FindPythonInterp) + if( NOT PYTHONINTERP_FOUND ) + message(FATAL_ERROR +-- +1.8.3.1 + diff --git a/0001-CMake-Split-static-library-exports-into-their-own-ex.patch b/0001-CMake-Split-static-library-exports-into-their-own-ex.patch new file mode 100644 index 0000000..903821e --- /dev/null +++ b/0001-CMake-Split-static-library-exports-into-their-own-ex.patch @@ -0,0 +1,86 @@ +From f9e66a883e1fb748e6ac826fde188efaae249361 Mon Sep 17 00:00:00 2001 +From: Tom Stellard +Date: Sat, 29 Apr 2017 02:03:23 +0000 +Subject: [PATCH] CMake: Split static library exports into their own export + file + +Summary: +This is to better support distros which split the static libraries into +their own package. + +The current problem is that any project the includes LLVMConfig.cmake +will fail to configure unless the static libraries are installed. This +is because LLVMConfig.cmake includes LLVMExports.cmake, which throws an +error if it can't find files linked to one of the exported targets. + +This patch resolves the problem by putting the static library targets +into their own export file, LLVMStaticExports.cmake. This file +is optionally included by LLVMConfig.cmake, so distros can put this +new file in their static library package to make LLVMConfig.cmake +no longer depend on these libraries when they are not installed. + +Reviewers: beanz, mgorny, chapuni + +Subscribers: llvm-commits + +Differential Revision: https://reviews.llvm.org/D32668 +--- + cmake/modules/AddLLVM.cmake | 6 +++++- + cmake/modules/CMakeLists.txt | 3 +++ + cmake/modules/LLVMConfig.cmake.in | 2 ++ + 3 files changed, 10 insertions(+), 1 deletion(-) + +diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake +index fd5627e..78f106f 100644 +--- a/cmake/modules/AddLLVM.cmake ++++ b/cmake/modules/AddLLVM.cmake +@@ -635,7 +635,11 @@ macro(add_llvm_library name) + + if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR + NOT LLVM_DISTRIBUTION_COMPONENTS) +- set(export_to_llvmexports EXPORT LLVMExports) ++ if (ARG_SHARED) ++ set(export_to_llvmexports EXPORT LLVMExports) ++ else() ++ set(export_to_llvmexports EXPORT LLVMStaticExports) ++ endif() + set_property(GLOBAL PROPERTY LLVM_HAS_EXPORTS True) + endif() + +diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt +index 6074e83..e9fcb11 100644 +--- a/cmake/modules/CMakeLists.txt ++++ b/cmake/modules/CMakeLists.txt +@@ -91,6 +91,7 @@ set(LLVM_CONFIG_BINARY_DIR "\${LLVM_INSTALL_PREFIX}") + set(LLVM_CONFIG_TOOLS_BINARY_DIR "\${LLVM_INSTALL_PREFIX}/bin") + set(LLVM_CONFIG_EXPORTS_FILE "\${LLVM_CMAKE_DIR}/LLVMExports.cmake") + set(LLVM_CONFIG_EXPORTS "${LLVM_EXPORTS}") ++set(LLVM_CONFIG_STATIC_EXPORTS_FILE "\${LLVM_CMAKE_DIR}/LLVMStaticExports.cmake") + configure_file( + LLVMConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/LLVMConfig.cmake +@@ -107,6 +108,8 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) + if(llvm_has_exports) + install(EXPORT LLVMExports DESTINATION ${LLVM_INSTALL_PACKAGE_DIR} + COMPONENT cmake-exports) ++ install(EXPORT LLVMStaticExports DESTINATION ${LLVM_INSTALL_PACKAGE_DIR} ++ COMPONENT cmake-exports) + endif() + + install(FILES +diff --git a/cmake/modules/LLVMConfig.cmake.in b/cmake/modules/LLVMConfig.cmake.in +index 0772016..f471625 100644 +--- a/cmake/modules/LLVMConfig.cmake.in ++++ b/cmake/modules/LLVMConfig.cmake.in +@@ -78,6 +78,8 @@ if(NOT TARGET LLVMSupport) + set(LLVM_EXPORTED_TARGETS "@LLVM_CONFIG_EXPORTS@") + include("@LLVM_CONFIG_EXPORTS_FILE@") + @llvm_config_include_buildtree_only_exports@ ++ ++ include("@LLVM_CONFIG_STATIC_EXPORTS_FILE@" OPTIONAL) + endif() + + # By creating intrinsics_gen here, subprojects that depend on LLVM's +-- +1.8.3.1 + diff --git a/0001-Don-t-set-rpath-when-installing.patch b/0001-Don-t-set-rpath-when-installing.patch new file mode 100644 index 0000000..d92a387 --- /dev/null +++ b/0001-Don-t-set-rpath-when-installing.patch @@ -0,0 +1,24 @@ +From e67ace2ecb42c24e124f1738dc67b22055a22500 Mon Sep 17 00:00:00 2001 +From: Tom Stellard +Date: Thu, 13 Sep 2018 10:10:08 -0700 +Subject: [PATCH] Don't set rpath when installing + +--- + cmake/modules/AddLLVM.cmake | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake +index ce2057f..de309b5 100644 +--- a/cmake/modules/AddLLVM.cmake ++++ b/cmake/modules/AddLLVM.cmake +@@ -1621,6 +1621,7 @@ function(llvm_codesign name) + endfunction() + + function(llvm_setup_rpath name) ++ return() + if(CMAKE_INSTALL_RPATH) + return() + endif() +-- +1.8.3.1 + diff --git a/0001-Filter-out-cxxflags-not-supported-by-clang.patch b/0001-Filter-out-cxxflags-not-supported-by-clang.patch new file mode 100644 index 0000000..31b819b --- /dev/null +++ b/0001-Filter-out-cxxflags-not-supported-by-clang.patch @@ -0,0 +1,28 @@ +From 5f7fd92155db77c7608e3a07e5dcfad1ec7bd4e4 Mon Sep 17 00:00:00 2001 +From: Tom Stellard +Date: Fri, 16 Mar 2018 07:52:33 -0700 +Subject: [PATCH] Filter out cxxflags not supported by clang + +--- + tools/llvm-config/CMakeLists.txt | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/tools/llvm-config/CMakeLists.txt b/tools/llvm-config/CMakeLists.txt +index a0bd36c..4193b0e 100644 +--- a/tools/llvm-config/CMakeLists.txt ++++ b/tools/llvm-config/CMakeLists.txt +@@ -34,7 +34,11 @@ set(LLVM_SRC_ROOT ${LLVM_MAIN_SRC_DIR}) + set(LLVM_OBJ_ROOT ${LLVM_BINARY_DIR}) + set(LLVM_CPPFLAGS "${CMAKE_CPP_FLAGS} ${CMAKE_CPP_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}") + set(LLVM_CFLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}") ++STRING(REGEX REPLACE "-mcet" "" LLVM_CFLAGS ${LLVM_CFLAGS}) ++STRING(REGEX REPLACE "-fcf-protection" "" LLVM_CFLAGS ${LLVM_CFLAGS}) + set(LLVM_CXXFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${COMPILE_FLAGS} ${LLVM_DEFINITIONS}") ++STRING(REGEX REPLACE "-mcet" "" LLVM_CXXFLAGS ${LLVM_CXXFLAGS}) ++STRING(REGEX REPLACE "-fcf-protection" "" LLVM_CXXFLAGS ${LLVM_CXXFLAGS}) + set(LLVM_BUILD_SYSTEM cmake) + set(LLVM_HAS_RTTI ${LLVM_CONFIG_HAS_RTTI}) + set(LLVM_DYLIB_VERSION "${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX}") +-- +1.8.3.1 + diff --git a/0001-unittests-Don-t-install-TestPlugin.so.patch b/0001-unittests-Don-t-install-TestPlugin.so.patch new file mode 100644 index 0000000..f614036 --- /dev/null +++ b/0001-unittests-Don-t-install-TestPlugin.so.patch @@ -0,0 +1,62 @@ +From cf1fb43186fd4d97ee2de0b222d44ecc500f82c7 Mon Sep 17 00:00:00 2001 +From: Tom Stellard +Date: Mon, 13 Aug 2018 12:22:28 -0700 +Subject: [PATCH] unittests: Don't install TestPlugin.so + +add_llvm_loadable_module adds an install target by default, but this +module is only used for a unit test, so we don't need to instal it. + +This patch adds a NO_INSTALL option to add_llvm_loadable_module that +can be used to disable installation of modules. +--- + cmake/modules/AddLLVM.cmake | 13 ++++++++----- + unittests/Passes/CMakeLists.txt | 2 +- + 2 files changed, 9 insertions(+), 6 deletions(-) + +diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake +index 24ef5e4..1637ba6 100644 +--- a/cmake/modules/AddLLVM.cmake ++++ b/cmake/modules/AddLLVM.cmake +@@ -671,7 +671,8 @@ macro(add_llvm_library name) + endmacro(add_llvm_library name) + + macro(add_llvm_loadable_module name) +- llvm_add_library(${name} MODULE ${ARGN}) ++ cmake_parse_arguments(ARG "NO_INSTALL" "" "" ${ARGN}) ++ llvm_add_library(${name} MODULE ${ARG_UNPARSED_ARGUMENTS}) + if(NOT TARGET ${name}) + # Add empty "phony" target + add_custom_target(${name}) +@@ -693,10 +694,12 @@ macro(add_llvm_loadable_module name) + set_property(GLOBAL PROPERTY LLVM_HAS_EXPORTS True) + endif() + +- install(TARGETS ${name} +- ${export_to_llvmexports} +- LIBRARY DESTINATION ${dlldir} +- ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) ++ if (NOT ARG_NO_INSTALL) ++ install(TARGETS ${name} ++ ${export_to_llvmexports} ++ LIBRARY DESTINATION ${dlldir} ++ ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) ++ endif() + endif() + set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name}) + endif() +diff --git a/unittests/Passes/CMakeLists.txt b/unittests/Passes/CMakeLists.txt +index d90df20..99390e6 100644 +--- a/unittests/Passes/CMakeLists.txt ++++ b/unittests/Passes/CMakeLists.txt +@@ -14,7 +14,7 @@ add_llvm_unittest(PluginsTests + export_executable_symbols(PluginsTests) + + set(LLVM_LINK_COMPONENTS) +-add_llvm_loadable_module(TestPlugin ++add_llvm_loadable_module(TestPlugin NO_INSTALL + TestPlugin.cpp + ) + +-- +1.8.3.1 + diff --git a/llvm-7.0.0.src.tar.xz b/llvm-7.0.0.src.tar.xz new file mode 100644 index 0000000..e326b04 Binary files /dev/null and b/llvm-7.0.0.src.tar.xz differ diff --git a/llvm.spec b/llvm.spec new file mode 100644 index 0000000..be17ee2 --- /dev/null +++ b/llvm.spec @@ -0,0 +1,164 @@ +%{!?_pkgdocdir: %global _pkgdocdir %{_docdir}/%{name}-%{version}} + +Name: llvm +Version: 7.0.0 +Release: 4 +Summary: The Low Level Virtual Machine +License: NCSA +URL: http://llvm.org +Source0: http://releases.llvm.org/7.0.0/%{name}-%{version}.src.tar.xz +Patch0: 0001-CMake-Split-static-library-exports-into-their-own-ex.patch +Patch1: 0001-Filter-out-cxxflags-not-supported-by-clang.patch +Patch2: 0001-unittests-Don-t-install-TestPlugin.so.patch +Patch3: 0001-CMake-Don-t-prefer-python2.7.patch +Patch4: 0001-Don-t-set-rpath-when-installing.patch + +BuildRequires: gcc gcc-c++ cmake git ninja-build +BuildRequires: zlib-devel libffi-devel ncurses-devel +BuildRequires: python3-sphinx +BuildRequires: multilib-rpm-config binutils-devel valgrind-devel +BuildRequires: libedit-devel python3-devel +Provides: %{name}-libs = %{version}-%{release} +Obsoletes: %{name}-libs < %{version}-%{release} + +%description +LLVM is a compiler infrastructure designed for compile-time, link-time, +runtime, and idle-time optimization of programs from arbitrary programming +languages. + +The LLVM compiler infrastructure supports a wide range of projects, +from industrial strength compilers to specialized JIT applications +to small research projects. + +%package devel +Summary: Development files for %{name} +Requires: %{name} = %{version}-%{release} +Requires: libedit-devel +Requires(post): %{_sbindir}/alternatives +Requires(postun): %{_sbindir}/alternatives +Provides: %{name}-static = %{version}-%{release} +Obsoletes: %{name}-static < %{version}-%{release} + +%description devel +The %{name}-devel package contains libraries and header files for +developing applications that use %{name}. + +%package help +Summary: Doc files for %{name} +Buildarch: noarch +Requires: man + +%description help +The %{name}-help package contains doc files for %{name}. + +%prep +%autosetup -n %{name}-%{version}.src -p1 +pathfix.py -i %{__python3} -pn test/BugPoint/compile-custom.ll.py tools/opt-viewer/*.py + +%build +mkdir -p _build; pushd _build + +%cmake .. -G Ninja \ + -DBUILD_SHARED_LIBS:BOOL=OFF \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ +%if 0%{?__isa_bits} == 64 + -DLLVM_LIBDIR_SUFFIX=64 \ +%else + -DLLVM_LIBDIR_SUFFIX= \ +%endif +%ifarch %ix86 x86_64 + -DLLVM_TARGETS_TO_BUILD="X86;AMDGPU;NVPTX;BPF;ARM;AArch64" \ +%endif +%ifarch aarch64 + -DLLVM_TARGETS_TO_BUILD="AArch64;AMDGPU;BPF" \ +%endif +%ifarch %{arm} + -DLLVM_TARGETS_TO_BUILD="ARM;AMDGPU;BPF" \ +%endif + -DLLVM_ENABLE_LIBCXX:BOOL=OFF \ + -DLLVM_ENABLE_ZLIB:BOOL=ON \ + -DLLVM_ENABLE_FFI:BOOL=ON \ + -DLLVM_ENABLE_RTTI:BOOL=ON \ + -DLLVM_BINUTILS_INCDIR=%{_includedir} \ + -DLLVM_BUILD_RUNTIME:BOOL=ON \ + -DLLVM_INCLUDE_TOOLS:BOOL=ON \ + -DLLVM_BUILD_TOOLS:BOOL=ON \ + -DLLVM_INCLUDE_TESTS:BOOL=OFF \ + -DLLVM_BUILD_TESTS:BOOL=OFF \ + -DLLVM_INCLUDE_EXAMPLES:BOOL=ON \ + -DLLVM_BUILD_EXAMPLES:BOOL=OFF \ + -DLLVM_INCLUDE_UTILS:BOOL=ON \ + -DLLVM_INSTALL_UTILS:BOOL=ON \ + -DLLVM_UTILS_INSTALL_DIR:PATH=%{buildroot}/%{_libdir}/%{name} \ + -DLLVM_INCLUDE_DOCS:BOOL=ON \ + -DLLVM_BUILD_DOCS:BOOL=ON \ + -DLLVM_ENABLE_SPHINX:BOOL=ON \ + -DLLVM_ENABLE_DOXYGEN:BOOL=OFF \ + -DLLVM_BUILD_LLVM_DYLIB:BOOL=ON \ + -DLLVM_DYLIB_EXPORT_ALL:BOOL=ON \ + -DLLVM_LINK_LLVM_DYLIB:BOOL=ON \ + -DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL=ON \ + -DLLVM_INSTALL_TOOLCHAIN_ONLY:BOOL=OFF \ + -DSPHINX_WARNINGS_AS_ERRORS=OFF \ + -DCMAKE_INSTALL_PREFIX=%{buildroot}/usr \ + -DLLVM_INSTALL_SPHINX_HTML_DIR=%{buildroot}/%{_pkgdocdir}/html \ + -DSPHINX_EXECUTABLE=%{_bindir}/sphinx-build-3 + +ninja -v + +%install +pushd _build +ninja -v install +mv -v %{buildroot}/%{_bindir}/llvm-config{,-%{__isa_bits}} + +for f in lli-child-target llvm-isel-fuzzer llvm-opt-fuzzer yaml-bench; do + install -m 0755 ./bin/$f %{buildroot}/%{_libdir}/%{name} +done + +popd + +find %{buildroot}/%{_libdir}/%{name} -ignore_readdir_race -iname 'cmake*' -exec rm -Rf '{}' ';' || true + +%check +cd _build +ninja check-all || : + +%post -p /sbin/ldconfig +%postun -p /sbin/ldconfig + +%post devel +%{_sbindir}/update-alternatives --install %{_bindir}/llvm-config llvm-config %{_bindir}/llvm-config-%{__isa_bits} %{__isa_bits} + +%postun devel +if [ $1 -eq 0 ]; then + %{_sbindir}/update-alternatives --remove llvm-config %{_bindir}/llvm-config-%{__isa_bits} +fi + +%files +%license LICENSE.TXT +%{_bindir}/* +%{_libdir}/%{name}/* +%{_datadir}/opt-viewer/* +%{_libdir}/*.so* + +%files devel +%{_bindir}/llvm-config-%{__isa_bits} +%{_includedir}/llvm/* +%{_includedir}/llvm-c/* +%{_libdir}/cmake/llvm/* +%{_libdir}/libLLVM.so +%{_libdir}/*.a + +%files help +%doc %{_pkgdocdir}/html +%{_mandir}/man1/* + +%changelog +* Sat Sep 29 2019 luhuaxin - 7.0.0-4 +- Type: enhancement +- ID: NA +- SUG: NA +- DESC: add license file + +* Fri Sep 20 2019 luhuaxin - 7.0.0-3 +- Package init diff --git a/run-lit-tests b/run-lit-tests new file mode 100644 index 0000000..a0a5d5b --- /dev/null +++ b/run-lit-tests @@ -0,0 +1,39 @@ +#!/bin/bash + +usage() { + echo "usage: `basename $0` [OPTIONS]" + echo " --threads NUM The number of threads to use for running tests." +} + +threads_arg='' + +while [ $# -gt 0 ]; do + case $1 in + --threads) + shift + threads_arg="--threads $1" + ;; + * ) + echo "unknown option: $1" + echo "" + usage + exit 1 + ;; + esac + shift +done + +set -xe + +TOOLS_DIR=@TOOLS_DIR@ +cd $(mktemp -d) +ln -s /usr/include include +tar -xzf /usr/share/llvm/src/test.tar.gz +PATH=$PATH:$TOOLS_DIR lit -v -s $threads_arg test \ + -DFileCheck=$TOOLS_DIR/FileCheck \ + -Dcount=$TOOLS_DIR/count \ + -Dnot=$TOOLS_DIR/not \ + -Dlli-child-target=$TOOLS_DIR/lli-child-target \ + -Dllvm-isel-fuzzer=$TOOLS_DIR/llvm-isel-fuzzer \ + -Dllvm-opt-fuzzer=$TOOLS_DIR/llvm-opt-fuzzer \ + -Dyaml-bench=$TOOLS_DIR/yaml-bench