From 9a942b15771786b61f66fd6011b30beab8f4eb8f Mon Sep 17 00:00:00 2001 From: Marcin Krol Date: Fri, 14 Jul 2023 17:36:56 +0200 Subject: [PATCH] - merged 16.0.6 from PLD --- cmake-buildtype.patch | 15 +- cmake-utils-path-override.patch | 11 + compiler-rt-paths.patch | 19 + llvm-flang.patch | 13 + llvm-libexecdir.patch | 22 + llvm-polly-update.patch | 52 --- llvm-selective_bindings.patch | 11 + llvm-tld.patch | 96 ++-- llvm.spec | 801 ++++++++++++++++++++++++-------- llvm12-build_fixes.patch | 481 +++++++++++++++++++ x32-compiler-rt.patch | 12 + x32-gcc-toolchain.patch | 48 +- 12 files changed, 1253 insertions(+), 328 deletions(-) create mode 100644 cmake-utils-path-override.patch create mode 100644 compiler-rt-paths.patch create mode 100644 llvm-flang.patch create mode 100644 llvm-libexecdir.patch delete mode 100644 llvm-polly-update.patch create mode 100644 llvm-selective_bindings.patch create mode 100644 llvm12-build_fixes.patch create mode 100644 x32-compiler-rt.patch diff --git a/cmake-buildtype.patch b/cmake-buildtype.patch index 5dbe193..e0d7410 100644 --- a/cmake-buildtype.patch +++ b/cmake-buildtype.patch @@ -1,8 +1,7 @@ -allow CMAKE_BUILD_TYPE=PLD - ---- llvm-3.8.0.src/CMakeLists.txt~ 2016-01-13 21:03:44.000000000 +0200 -+++ llvm-3.8.0.src/CMakeLists.txt 2016-10-01 15:54:42.749630541 +0300 -@@ -174,11 +174,6 @@ +diff -urNp -x '*.orig' llvm-11.0.1.src.org/CMakeLists.txt llvm-11.0.1.src/CMakeLists.txt +--- llvm-11.0.1.src.org/CMakeLists.txt 2021-03-25 22:28:14.616795886 +0100 ++++ llvm-11.0.1.src/CMakeLists.txt 2021-03-25 22:28:19.786759915 +0100 +@@ -264,11 +264,6 @@ endif() string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) @@ -11,6 +10,6 @@ allow CMAKE_BUILD_TYPE=PLD - message(FATAL_ERROR "Invalid value for CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") -endif() - - set(LLVM_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)" ) - - # They are used as destination of target generators. + # LLVM_INSTALL_PACKAGE_DIR needs to be declared prior to adding the tools + # subdirectory in order to have the value available for llvm-config. + include(GNUInstallPackageDir) diff --git a/cmake-utils-path-override.patch b/cmake-utils-path-override.patch new file mode 100644 index 0000000..9886089 --- /dev/null +++ b/cmake-utils-path-override.patch @@ -0,0 +1,11 @@ +--- llvm-15.0.2.src/CMakeLists.txt.orig 2022-10-15 23:14:23.474649716 +0200 ++++ llvm-15.0.2.src/CMakeLists.txt 2022-10-15 23:16:11.530931066 +0200 +@@ -231,7 +231,7 @@ + "at least 3.20.0 now to avoid issues in the future!") + endif() + +-set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) ++set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake CACHE STRING "Path to CMake modules shared between projects") + include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake + NO_POLICY_SCOPE) + diff --git a/compiler-rt-paths.patch b/compiler-rt-paths.patch new file mode 100644 index 0000000..44c385e --- /dev/null +++ b/compiler-rt-paths.patch @@ -0,0 +1,19 @@ +--- llvm-14.0.4.src/projects/compiler-rt/cmake/base-config-ix.cmake.orig 2022-05-25 00:02:58.000000000 +0200 ++++ llvm-14.0.4.src/projects/compiler-rt/cmake/base-config-ix.cmake 2022-05-31 12:22:26.076246743 +0200 +@@ -109,13 +109,13 @@ + set(COMPILER_RT_INSTALL_LIBRARY_DIR "${default_install_path}" CACHE PATH + "Path where built compiler-rt libraries should be installed.") + endif() +-extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" "${CMAKE_INSTALL_BINDIR}") ++extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" "bin") + set(COMPILER_RT_INSTALL_BINARY_DIR "${default_install_path}" CACHE PATH + "Path where built compiler-rt executables should be installed.") +-extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" "${CMAKE_INSTALL_INCLUDEDIR}") ++extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" "include") + set(COMPILER_RT_INSTALL_INCLUDE_DIR "${default_install_path}" CACHE PATH + "Path where compiler-rt headers should be installed.") +-extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" "${CMAKE_INSTALL_DATADIR}") ++extend_path(default_install_path "${COMPILER_RT_INSTALL_PATH}" "share") + set(COMPILER_RT_INSTALL_DATA_DIR "${default_install_path}" CACHE PATH + "Path where compiler-rt data files should be installed.") + diff --git a/llvm-flang.patch b/llvm-flang.patch new file mode 100644 index 0000000..059aaa6 --- /dev/null +++ b/llvm-flang.patch @@ -0,0 +1,13 @@ +--- llvm-16.0.6.src/tools/flang/CMakeLists.txt.orig 2023-06-28 14:50:26.517107272 +0200 ++++ llvm-16.0.6.src/tools/flang/CMakeLists.txt 2023-06-28 15:58:45.176490482 +0200 +@@ -204,8 +204,8 @@ else() + set(FLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) + endif() + +- set(MLIR_MAIN_SRC_DIR ${LLVM_MAIN_SRC_DIR}/../mlir ) # --src-root +- set(MLIR_INCLUDE_DIR ${MLIR_MAIN_SRC_DIR}/include ) # --includedir ++ set(MLIR_MAIN_SRC_DIR ${LLVM_MAIN_SRC_DIR}/tools/mlir ) # --src-root ++ set(MLIR_INCLUDE_DIR ${MLIR_MAIN_SRC_DIR}/include ) # --includedir + set(MLIR_TABLEGEN_OUTPUT_DIR ${CMAKE_BINARY_DIR}/tools/mlir/include) + include_directories(SYSTEM ${MLIR_INCLUDE_DIR}) + include_directories(SYSTEM ${MLIR_TABLEGEN_OUTPUT_DIR}) diff --git a/llvm-libexecdir.patch b/llvm-libexecdir.patch new file mode 100644 index 0000000..38b50e5 --- /dev/null +++ b/llvm-libexecdir.patch @@ -0,0 +1,22 @@ +--- llvm-14.0.4.src/tools/clang/tools/scan-build-py/CMakeLists.txt.orig 2022-05-25 00:02:58.000000000 +0200 ++++ llvm-14.0.4.src/tools/clang/tools/scan-build-py/CMakeLists.txt 2022-05-31 12:44:17.819410412 +0200 +@@ -72,7 +72,7 @@ + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libexec/${lib}) + list(APPEND Depends ${CMAKE_BINARY_DIR}/libexec/${lib}) + install(PROGRAMS libexec/${lib} +- DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}" ++ DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/clang-analyzer" + COMPONENT scan-build-py) + endforeach() + +--- llvm-14.0.4.src/tools/clang/tools/scan-build/CMakeLists.txt.orig 2022-05-25 00:02:58.000000000 +0200 ++++ llvm-14.0.4.src/tools/clang/tools/scan-build/CMakeLists.txt 2022-05-31 12:43:50.736232980 +0200 +@@ -61,7 +61,7 @@ + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libexec/${LibexecFile}) + list(APPEND Depends ${CMAKE_BINARY_DIR}/libexec/${LibexecFile}) + install(PROGRAMS libexec/${LibexecFile} +- DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}" ++ DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/clang-analyzer" + COMPONENT scan-build) + endforeach() + diff --git a/llvm-polly-update.patch b/llvm-polly-update.patch deleted file mode 100644 index e7c2f5f..0000000 --- a/llvm-polly-update.patch +++ /dev/null @@ -1,52 +0,0 @@ ---- llvm-3.5.0.src/tools/polly/lib/Transform/Pocc.cpp.orig 2014-06-28 10:59:45.000000000 +0200 -+++ llvm-3.5.0.src/tools/polly/lib/Transform/Pocc.cpp 2014-10-03 22:56:19.591962149 +0200 -@@ -238,8 +238,6 @@ - } - - void Pocc::printScop(raw_ostream &OS) const { -- std::unique_ptr stdoutBuffer; -- std::unique_ptr stderrBuffer; - - OS << "Command line: "; - -@@ -249,20 +247,20 @@ - - OS << "\n"; - -- if (std::error_code ec = -- MemoryBuffer::getFile(PlutoStdout.str(), stdoutBuffer)) -- OS << "Could not open pocc stdout file: " + ec.message() << "\n"; -+ ErrorOr> stdoutResult = MemoryBuffer::getFile(PlutoStdout.str()); -+ if (!stdoutResult) -+ OS << "Could not open pocc stdout file: " + stdoutResult.getError().message() << "\n"; - else { -- OS << "pocc stdout: " << stdoutBuffer->getBufferIdentifier() << "\n"; -- OS << stdoutBuffer->getBuffer() << "\n"; -+ OS << "pocc stdout: " << stdoutResult.get()->getBufferIdentifier() << "\n"; -+ OS << stdoutResult.get()->getBuffer() << "\n"; - } - -- if (std::error_code ec = -- MemoryBuffer::getFile(PlutoStderr.str(), stderrBuffer)) -- OS << "Could not open pocc stderr file: " + ec.message() << "\n"; -+ ErrorOr> stderrResult = MemoryBuffer::getFile(PlutoStderr.str()); -+ if (!stderrResult) -+ OS << "Could not open pocc stderr file: " + stderrResult.getError().message() << "\n"; - else { - OS << "pocc stderr: " << PlutoStderr << "\n"; -- OS << stderrBuffer->getBuffer() << "\n"; -+ OS << stderrResult.get()->getBuffer() << "\n"; - } - } - ---- llvm-3.5.0.src/tools/polly/autoconf/configure.ac.orig 2014-04-11 11:47:45.000000000 +0200 -+++ llvm-3.5.0.src/tools/polly/autoconf/configure.ac 2014-10-06 16:37:55.052037462 +0200 -@@ -93,7 +93,7 @@ - - dnl Check that we have libpluto. - saved_CXXFLAGS=$CXXFLAGS --CXXFLAGS="$CXXFLAGS $gmp_inc $isl_inc" -+CXXFLAGS="$CXXFLAGS $gmp_inc $isl_inc -std=c++0x" - find_lib_and_headers([pluto], [pluto/libpluto.h], [pluto]) - CXXFLAGS=$saved_CXXFLAGS - AS_IF([test "x$pluto_found" = "xyes"], diff --git a/llvm-selective_bindings.patch b/llvm-selective_bindings.patch new file mode 100644 index 0000000..ae836af --- /dev/null +++ b/llvm-selective_bindings.patch @@ -0,0 +1,11 @@ +--- llvm-13.0.0.src/cmake/config-ix.cmake.orig 2021-09-24 18:18:10.000000000 +0200 ++++ llvm-13.0.0.src/cmake/config-ix.cmake 2021-11-08 11:27:55.475562698 +0100 +@@ -625,7 +625,7 @@ + set(LLVM_BINDINGS "") + include(FindOCaml) + include(AddOCaml) +-if(WIN32 OR NOT LLVM_ENABLE_BINDINGS) ++if(WIN32 OR NOT LLVM_ENABLE_BINDINGS OR (DEFINED LLVM_BINDINGS_LIST AND NOT "ocaml" IN_LIST LLVM_BINDINGS_LIST)) + message(STATUS "OCaml bindings disabled.") + else() + find_package(OCaml) diff --git a/llvm-tld.patch b/llvm-tld.patch index 645d8cd..9eb33c4 100644 --- a/llvm-tld.patch +++ b/llvm-tld.patch @@ -1,34 +1,17 @@ ---- llvm-5.0.0.src.orig/tools/clang/lib/Driver/ToolChains/Gnu.cpp 2016-08-18 19:56:48.000000000 +0200 -+++ llvm-5.0.0.src/tools/clang/lib/Driver/ToolChains/Gnu.cpp 2016-11-03 12:18:35.000000000 +0100 -@@ -1498,6 +1498,7 @@ - - static const char *const X86_64LibDirs[] = {"/lib64", "/lib"}; - static const char *const X86_64Triples[] = { -+ "x86_64-tld-linux", - "x86_64-linux-gnu", "x86_64-unknown-linux-gnu", - "x86_64-pc-linux-gnu", "x86_64-redhat-linux6E", - "x86_64-redhat-linux", "x86_64-suse-linux", -@@ -1558,6 +1559,7 @@ - static const char *const X32LibDirs[] = {"/libx32"}; - static const char *const X86LibDirs[] = {"/lib32", "/lib"}; - static const char *const X86Triples[] = { -+ "i686-tld-linux", - "i686-linux-gnu", "i686-pc-linux-gnu", "i486-linux-gnu", - "i386-linux-gnu", "i386-redhat-linux6E", "i686-redhat-linux", - "i586-redhat-linux", "i386-redhat-linux", "i586-suse-linux", ---- llvm-5.0.0.src/tools/clang/include/clang/Driver/Distro.h.orig 2017-05-04 14:46:38.000000000 +0200 -+++ llvm-5.0.0.src/tools/clang/include/clang/Driver/Distro.h 2017-12-01 22:44:57.785429043 +0100 -@@ -27,6 +27,7 @@ - // in this enum, because some tests are done by integer comparison against +diff -urNp -x '*.orig' llvm-11.0.1.src.org/tools/clang/include/clang/Driver/Distro.h llvm-11.0.1.src/tools/clang/include/clang/Driver/Distro.h +--- llvm-11.0.1.src.org/tools/clang/include/clang/Driver/Distro.h 2020-12-18 20:57:38.000000000 +0100 ++++ llvm-11.0.1.src/tools/clang/include/clang/Driver/Distro.h 2021-03-25 22:27:39.173689051 +0100 +@@ -28,6 +28,7 @@ public: // the first and last known member in the family, e.g. IsRedHat(). + AlpineLinux, ArchLinux, + TLDLinux, DebianLenny, DebianSqueeze, DebianWheezy, -@@ -114,6 +115,10 @@ - return DistroVal >= UbuntuHardy && DistroVal <= UbuntuArtful; - } +@@ -132,6 +133,10 @@ public: + + bool IsGentoo() const { return DistroVal == Gentoo; } + bool IsTLD() { + return DistroVal == TLDLinux; @@ -37,11 +20,12 @@ /// @} }; ---- llvm-5.0.0.src/tools/clang/lib/Driver/Distro.cpp.orig 2017-05-04 14:46:38.000000000 +0200 -+++ llvm-5.0.0.src/tools/clang/lib/Driver/Distro.cpp 2017-12-01 22:47:15.155427475 +0100 -@@ -129,6 +129,9 @@ - if (VFS.exists("/etc/arch-release")) - return Distro::ArchLinux; +diff -urNp -x '*.orig' llvm-11.0.1.src.org/tools/clang/lib/Driver/Distro.cpp llvm-11.0.1.src/tools/clang/lib/Driver/Distro.cpp +--- llvm-11.0.1.src.org/tools/clang/lib/Driver/Distro.cpp 2020-12-18 20:57:38.000000000 +0100 ++++ llvm-11.0.1.src/tools/clang/lib/Driver/Distro.cpp 2021-03-25 22:27:39.173689051 +0100 +@@ -165,6 +165,9 @@ static Distro::DistroType DetectDistro(l + if (VFS.exists("/etc/gentoo-release")) + return Distro::Gentoo; + if (VFS.exists("/etc/tld-release")) + return Distro::TLDLinux; @@ -49,9 +33,37 @@ return Distro::UnknownDistro; } ---- llvm-5.0.0.src/tools/clang/lib/Driver/ToolChains/Linux.cpp.orig 2017-12-01 22:14:03.462116884 +0100 -+++ llvm-5.0.0.src/tools/clang/lib/Driver/ToolChains/Linux.cpp 2017-12-01 22:51:38.678757801 +0100 -@@ -210,7 +210,7 @@ +diff -urNp -x '*.orig' llvm-11.0.1.src.org/tools/clang/lib/Driver/ToolChains/Gnu.cpp llvm-11.0.1.src/tools/clang/lib/Driver/ToolChains/Gnu.cpp +--- llvm-11.0.1.src.org/tools/clang/lib/Driver/ToolChains/Gnu.cpp 2020-12-18 20:57:38.000000000 +0100 ++++ llvm-11.0.1.src/tools/clang/lib/Driver/ToolChains/Gnu.cpp 2021-03-25 22:27:39.173689051 +0100 +@@ -2048,6 +2048,7 @@ void Generic_GCC::GCCInstallationDetecto + // lists should shrink over time. Please don't add more elements to *Triples. + static const char *const AArch64LibDirs[] = {"/lib64", "/lib"}; + static const char *const AArch64Triples[] = { ++ "aarch64-tld-linux", + "aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-redhat-linux", + "aarch64-suse-linux"}; + static const char *const AArch64beLibDirs[] = {"/lib"}; +@@ -2072,6 +2077,7 @@ void Generic_GCC::GCCInstallationDetecto + + static const char *const X86_64LibDirs[] = {"/lib64", "/lib"}; + static const char *const X86_64Triples[] = { ++ "x86_64-tld-linux", "amd64-tld-linux", + "x86_64-linux-gnu", "x86_64-unknown-linux-gnu", + "x86_64-pc-linux-gnu", "x86_64-redhat-linux6E", + "x86_64-redhat-linux", "x86_64-suse-linux", +@@ -2081,6 +2087,7 @@ void Generic_GCC::GCCInstallationDetecto + static const char *const X32LibDirs[] = {"/libx32", "/lib"}; + static const char *const X86LibDirs[] = {"/lib32", "/lib"}; + static const char *const X86Triples[] = { ++ "i686-tld-linux", + "i586-linux-gnu", "i686-linux-gnu", "i686-pc-linux-gnu", + "i386-redhat-linux6E", "i686-redhat-linux", "i386-redhat-linux", + "i586-suse-linux", "i686-montavista-linux", "i686-gnu", +diff -urNp -x '*.orig' llvm-11.0.1.src.org/tools/clang/lib/Driver/ToolChains/Linux.cpp llvm-11.0.1.src/tools/clang/lib/Driver/ToolChains/Linux.cpp +--- llvm-11.0.1.src.org/tools/clang/lib/Driver/ToolChains/Linux.cpp 2020-12-18 20:57:38.000000000 +0100 ++++ llvm-11.0.1.src/tools/clang/lib/Driver/ToolChains/Linux.cpp 2021-03-25 22:27:39.173689051 +0100 +@@ -226,7 +226,7 @@ Linux::Linux(const Driver &D, const llvm ExtraOpts.push_back("now"); } @@ -60,21 +72,3 @@ Triple.isAndroid()) { ExtraOpts.push_back("-z"); ExtraOpts.push_back("relro"); -@@ -232,7 +232,7 @@ - // Android loader does not support .gnu.hash until API 23. - // Hexagon linker/loader does not support .gnu.hash - if (!IsMips && !IsHexagon) { -- if (Distro.IsRedhat() || Distro.IsOpenSUSE() || Distro.IsAlpineLinux() || -+ if (Distro.IsRedhat() || Distro.IsOpenSUSE() || Distro.IsAlpineLinux() || Distro.IsTLD() || - (Distro.IsUbuntu() && Distro >= Distro::UbuntuMaverick) || - (IsAndroid && !Triple.isAndroidVersionLT(23))) - ExtraOpts.push_back("--hash-style=gnu"); -@@ -241,7 +241,7 @@ - ExtraOpts.push_back("--hash-style=both"); - } - -- if (Distro.IsRedhat() && Distro != Distro::RHEL5 && Distro != Distro::RHEL6) -+ if ((Distro.IsRedhat() && Distro != Distro::RHEL5 && Distro != Distro::RHEL6) || Distro.IsTLD()) - ExtraOpts.push_back("--no-add-needed"); - - #ifdef ENABLE_LINKER_BUILD_ID diff --git a/llvm.spec b/llvm.spec index 86b05a0..6727ebf 100644 --- a/llvm.spec +++ b/llvm.spec @@ -4,87 +4,158 @@ # # TODO: # - move and package: -# %{_datadir}/clang/bash-autocomplete.sh # %{_datadir}/clang/clang-format-sublime.py - sublime plugin # %{_datadir}/clang/clang-format.el - clang tools emacs integration # %{_datadir}/clang/clang-include-fixer.el # %{_datadir}/clang/clang-rename.el # - no content in doc package (it used to contain parts of clang apidocs and some examples) # - system isl in polly? +# - dependencies and files for lua module +# %{_libdir}/lua/5.3/lldb.so +# - figure out whether we need obj.MLIRCAPIIR files +# - cmake dependencies mess (LLVMExports.cmake appears to require all -devels): +# with llvm-devel and spirv-tools-devel installed but without llvm-mlir (or other packages): +# $ cat CMakeLists.txt +# find_package(LLVM) +# find_package(SPIRV-Tools) +# $ cmake -B build +# ... +# The imported target "mlir-tblgen" references the file +# +# "/usr/bin/mlir-tblgen" +# +# but this file does not exist. Possible reasons include: +# ... # # Conditional build: -%bcond_without lldb # LLDB debugger -%bcond_without polly # Polly cache-locality optimization, auto-parallelism and vectorization -%bcond_without rt # compiler-rt libraries -%bcond_without multilib # compiler-rt multilib libraries -%bcond_with ocaml # OCaml binding -%bcond_without doc # HTML docs and man pages -%bcond_with apidocs # doxygen docs (HUGE, so they are not built by default) -%bcond_with tests # run tests +%bcond_without lldb # LLDB debugger +%bcond_without mlir # MLIR libraries and tools (required for Flang) +%bcond_with flang # Flang (Fortran18) compiler (heavy memory requirements during build) +%bcond_without polly # Polly cache-locality optimization, auto-parallelism and vectorization +%bcond_without rt # compiler-rt libraries +%bcond_without multilib # compiler-rt multilib libraries +%bcond_without ocaml # OCaml binding +%bcond_without z3 # Z3 constraint solver support in Clang Static Analyzer +%bcond_without doc # HTML docs and man pages +%bcond_without target_aarch64 # AArch64 target support +%bcond_without target_amdgpu # AMDGPU target support +%bcond_without target_arm # ARM target support +%bcond_without target_avr # AVR target support +%bcond_without target_bpf # BPF target support +%bcond_without target_hexagon # Hexagon target support +%bcond_without target_lanai # Lanai target support +%bcond_without target_loongarch # LoongArch target support +%bcond_without target_mips # Mips target support +%bcond_without target_msp430 # MSP430 target support +%bcond_without target_nvptx # NVPTX target support +%bcond_without target_powerpc # PowerPC target support +%bcond_without target_riscv # RISCV target support +%bcond_without target_sparc # Sparc target support +%bcond_without target_systemz # SystemZ target support +%bcond_without target_ve # VE target support +%bcond_without target_webassembly # WebAssembly target support +%bcond_without target_x86 # X86 target support +%bcond_without target_xcore # XCore target support +%bcond_with cxxmodules # C++20 modules (requires support in bootstrap compiler) +%bcond_with apidocs # doxygen docs (HUGE, so they are not built by default) +%bcond_with tests # run tests +%bcond_with lowmem # lower memory requirements # No ocaml on other arches or no native ocaml (required for ocaml-ctypes) %ifnarch %{ix86} %{x8664} %{arm} aarch64 ppc sparc sparcv9 %undefine with_ocaml %endif +%ifarch armv3l %{armv4} %{armv5} %{armv6} +%undefine with_rt +%endif + +%ifarch i386 i486 armv3l %{armv4} %{armv5} %{armv6} +%define with_libatomic 1 +%endif + +%define targets_to_build %{?with_target_aarch64:AArch64;}%{?with_target_amdgpu:AMDGPU;}%{?with_target_arm:ARM;}%{?with_target_avr:AVR;}%{?with_target_bpf:BPF;}%{?with_target_hexagon:Hexagon;}%{?with_target_lanai:Lanai;}%{?with_target_loongarch:LoongArch;}%{?with_target_mips:Mips;}%{?with_target_msp430:MSP430;}%{?with_target_nvptx:NVPTX;}%{?with_target_powerpc:PowerPC;}%{?with_target_riscv:RISCV;}%{?with_target_sparc:Sparc;}%{?with_target_systemz:SystemZ;}%{?with_target_ve:VE;}%{?with_target_webassembly:WebAssembly;}%{?with_target_x86:X86;}%{?with_target_xcore:XCore;} + +%if %{without mlir} +%undefine with_flang +%endif + Summary: The Low Level Virtual Machine (An Optimizing Compiler Infrastructure) Summary(pl.UTF-8): Niskopoziomowa maszyna wirtualna (infrastruktura kompilatora optymalizującego) Name: llvm -Version: 8.0.1 +Version: 16.0.6 Release: 1 -License: University of Illinois/NCSA Open Source License +License: Apache 2.0 with LLVM exceptions Group: Development/Languages -#Source0Download: http://releases.llvm.org/download.html -Source0: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/llvm-%{version}.src.tar.xz -# Source0-md5: 9a3b63df01c52556f7afb5617934e79e -Source1: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/cfe-%{version}.src.tar.xz -# Source1-md5: 28db72b57ca99307259773e4ac74a6d3 +#Source0Download: https://github.com/llvm/llvm-project/releases/ +Source0: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/%{name}-%{version}.src.tar.xz +# Source0-md5: 7d986cda69719a35bd5ecb266fcf1f65 +Source1: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/clang-%{version}.src.tar.xz +# Source1-md5: 70053a666251fdcabc466ea4a0275972 Source2: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/compiler-rt-%{version}.src.tar.xz -# Source2-md5: c251e582862f9fcc880802f8f2920096 +# Source2-md5: 79eb1121d4990a6585787e6b68361afe Source3: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/lldb-%{version}.src.tar.xz -# Source3-md5: c2777536fe0d4151c6aa30773f51af20 +# Source3-md5: 89ab2812e99d35fae6a0141bb57b9b1d Source4: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/polly-%{version}.src.tar.xz -# Source4-md5: 1ef3f82d49d0fb00fa92ce6e1b095da1 +# Source4-md5: 540613f9eaffb7bd05dfd77b52e6a4e2 Source5: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/clang-tools-extra-%{version}.src.tar.xz -# Source5-md5: b7c55438f792a1d5698696100a8731e0 +# Source5-md5: 775a93a7b168101f544dbfed23ac4aaa Source6: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/lld-%{version}.src.tar.xz -# Source6-md5: ee4fe10c625bbc66b1055c5d33017daf +# Source6-md5: 9c9530a0853624a869917853a2da2bd1 +Source7: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/flang-%{version}.src.tar.xz +# Source7-md5: 988186ce1f8629f924660e350a57e000 +Source8: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/mlir-%{version}.src.tar.xz +# Source8-md5: 9c9dac6bd7fdaf682f60fabca839c578 +Source9: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/cmake-%{version}.src.tar.xz +# Source9-md5: b7830bb90e376c90a43c2c190a0a5ffa Patch1: %{name}-tld.patch Patch3: x32-gcc-toolchain.patch Patch4: cmake-buildtype.patch Patch5: %{name}-ocaml-shared.patch -URL: http://llvm.org/ +Patch6: %{name}-flang.patch +Patch7: llvm12-build_fixes.patch +Patch8: %{name}-selective_bindings.patch +Patch9: %{name}-libexecdir.patch +Patch10: compiler-rt-paths.patch +Patch11: cmake-utils-path-override.patch +Patch12: x32-compiler-rt.patch +URL: https://llvm.org/ BuildRequires: bash +BuildRequires: binutils-devel BuildRequires: bison -BuildRequires: cmake >= 3.4.3 +BuildRequires: cmake >= 3.13.4 BuildRequires: flex -BuildRequires: gcc >= 5:3.4 -# gcc4 might be installed, but not current __cc -%if "%(echo %{cc_version} | cut -d. -f1,2)" < "3.4" -BuildRequires: __cc >= 3.4 -%endif BuildRequires: groff +%{?with_libatomic:BuildRequires: libatomic-devel} BuildRequires: libedit-devel BuildRequires: libltdl-devel -BuildRequires: libstdc++-devel >= 5:3.4 +BuildRequires: libpfm-devel +BuildRequires: libstdc++-devel >= 6:5 +BuildRequires: libxml2-devel >= 2 BuildRequires: ncurses-devel %if %{with ocaml} BuildRequires: ocaml >= 4.00.0 BuildRequires: ocaml-ctypes-devel >= 0.4 BuildRequires: ocaml-findlib BuildRequires: ocaml-ocamldoc -BuildRequires: ocaml-ounit >= 2 +%{?with_tests:BuildRequires: ocaml-ounit >= 2} %endif BuildRequires: perl-base >= 1:5.6 BuildRequires: perl-tools-pod -BuildRequires: python >= 1:2.7 -BuildRequires: rpm >= 4.5-87 +BuildRequires: python3 >= 1:3 +BuildRequires: python3-PyYAML +BuildRequires: python3-modules +BuildRequires: python3-pygments >= 2.0 +BuildRequires: rpm-build >= 4.6 BuildRequires: rpm-pythonprov -BuildRequires: rpmbuild(macros) >= 1.734 +BuildRequires: rpmbuild(macros) >= 2.007 %{?with_doc:BuildRequires: sphinx-pdg} BuildRequires: tar >= 1:1.22 +BuildRequires: xar-devel >= 1.6 BuildRequires: xz +%{?with_z3:BuildRequires: z3-devel >= 4.7.1} BuildRequires: zlib-devel +BuildRequires: zstd-devel %if %{with apidocs} BuildRequires: doxygen BuildRequires: graphviz @@ -95,30 +166,35 @@ BuildRequires: tcl-devel %endif %if %{with rt} && %{with multilib} %ifarch %{x8664} -BuildRequires: gcc-c++-multilib -BuildRequires: libstdc++-multilib-devel +BuildRequires: gcc-c++-multilib-32 +BuildRequires: glibc-devel(ix86) +BuildRequires: libstdc++-multilib-32-devel %endif %ifarch x32 -BuildRequires: gcc-c++-multilib +BuildRequires: gcc-c++-multilib-32 +BuildRequires: gcc-c++-multilib-64 +BuildRequires: glibc-devel(ix86) BuildRequires: glibc-devel(x86_64) -BuildRequires: libstdc++-multilib-devel +BuildRequires: libstdc++-multilib-32-devel +BuildRequires: libstdc++-multilib-64-devel %endif %endif %if %{with lldb} BuildRequires: epydoc -%ifarch i386 i486 -BuildRequires: libatomic-devel -%endif BuildRequires: libxml2-devel >= 2 +BuildRequires: lua-devel BuildRequires: ncurses-ext-devel -BuildRequires: python-devel >= 2 +BuildRequires: python3-devel >= 1:3.2 +%{?with_doc:BuildRequires: python3-recommonmark} BuildRequires: swig-python >= 3.0.11 +BuildRequires: xz-devel %endif %if %{with polly} #BuildRequires: gmp-devel or imath-devel (private copy in polly/lib/External/isl/imath) # private copy in polly/lib/External/isl -#BuildRequires: isl-devel >= 0.18 +#BuildRequires: isl-devel >= 0.22.1 #TODO (bcond): cuda-devel (with POLLY_ENABLE_GPGPU_CODEGEN=ON) +%{?with_target_nvptx:BuildRequires: ocl-icd-libOpenCL-devel} %endif %if %{with ocaml} BuildConflicts: llvm-ocaml @@ -129,10 +205,17 @@ Requires: %{name}-libs = %{version}-%{release} ExcludeArch: ppc64 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) -%define abi 8 +%define abi 16 %define _sysconfdir /etc/%{name} %define specflags_ppc -fno-var-tracking-assignments + +# objcopy: BFD (GNU Binutils) 2.32 assertion fail format.c:459 +# objcopy: error: .../libLLVM-8.so(.debug_gnu_pubtypes) is too large (0x1ceee347 bytes) +# objcopy: .../libLLVM-8.so[.debug_gnu_pubtypes]: memory exhausted +%ifarch x32 +%define _enable_debug_packages 0 +%endif # ix86 and x32 - the same issue as https://llvm.org/bugs/show_bug.cgi?id=27237 # use -gsplit-dwarf only when building packages with debuginfo # to avoid excessive disk space usage @@ -181,8 +264,13 @@ Biblioteki współdzielone LLVM-a. Summary: Static libraries and header files for LLVM Summary(pl.UTF-8): Biblioteki statyczne i pliki nagłówkowe dla LLVM-a Group: Development/Languages -Requires: %{name}-libs = %{version}-%{release} +Requires: %{name}-libs%{?_isa} = %{version}-%{release} +%{?with_libatomic:Requires: libatomic-devel} Requires: libstdc++-devel >= 6:3.4 +Requires: ncurses-devel +%{?with_z3:Requires: z3-devel} +Requires: zlib-devel +Requires: zstd-devel %description devel This package contains static libraries and header files needed to @@ -210,6 +298,7 @@ Summary: API documentation for LLVM Summary(pl.UTF-8): Dokumentacja API LLVM-a Group: Development/Languages Requires: %{name}-doc = %{version}-%{release} +BuildArch: noarch %description apidocs API documentation for the LLVM compiler infrastructure. @@ -217,11 +306,39 @@ API documentation for the LLVM compiler infrastructure. %description apidocs -l pl.UTF-8 Dokumentacja API infrastruktury kompilatorów LLVM. +%package mlir +Summary: LLVM Multi-Level Intermediate Representation libraries and tools +Summary(pl.UTF-8): Biblioteki i narzędzia wielopoziomowej reprezentacji pośredniej LLVM +Group: Development/Tools +URL: https://mlir.llvm.org/ +Requires: %{name} = %{version}-%{release} + +%description mlir +LLVM Multi-Level Intermediate Representation libraries and tools. + +%description mlir -l pl.UTF-8 +Biblioteki i narzędzia wielopoziomowej reprezentacji pośredniej LLVM. + +%package mlir-devel +Summary: LLVM Multi-Level Intermediate Representation development files +Summary(pl.UTF-8): Pliki do programowania z użyciem wielopoziomowej reprezentacji pośredniej LLVM +Group: Development/Tools +URL: https://mlir.llvm.org/ +Requires: %{name}-devel = %{version}-%{release} +Requires: %{name}-mlir = %{version}-%{release} + +%description mlir-devel +LLVM Multi-Level Intermediate Representation development files. + +%description mlir-devel -l pl.UTF-8 +Pliki do programowania z użyciem wielopoziomowej reprezentacji +pośredniej LLVM. + %package polly Summary: Polyhedral optimizations for LLVM Summary(pl.UTF-8): Optymalizacje wielościanowe dla LLVM-a Group: Development/Tools -URL: http://polly.llvm.org/ +URL: https://polly.llvm.org/ Requires: %{name} = %{version}-%{release} %description polly @@ -240,7 +357,7 @@ do analizy i optymalizacji wzorców dostępu do pamięci przez program. Summary: Header files for LLVM Polly optimization infrastructure Summary(pl.UTF-8): Pliki nagłówkowe infrastruktury optymalizacji LLVM-a Polly Group: Development/Libraries -URL: http://polly.llvm.org/ +URL: https://polly.llvm.org/ Requires: %{name}-devel = %{version}-%{release} Requires: %{name}-polly = %{version}-%{release} @@ -253,8 +370,8 @@ Pliki nagłówkowe infrastruktury optymalizacji LLVM-a Polly. %package -n clang Summary: A C language family frontend for LLVM Summary(pl.UTF-8): Frontend LLVM-a do języków z rodziny C -License: NCSA Group: Development/Languages +URL: https://clang.llvm.org/ Requires: %{name} = %{version}-%{release} Requires: clang-libs = %{version}-%{release} @@ -276,22 +393,11 @@ LLVM do języków C, C++, Objective C i Objective C++. Narzędzia są budowane jako biblioteki i zaprojektowane z myślą o swobodnym łączeniu i rozszerzaniu. -%package -n clang-libs -Summary: Clang shared libraries -Summary(pl.UTF-8): Biblioteki współdzielone Clanga -Group: Libraries - -%description -n clang-libs -Clang shared libraries. - -%description -n clang-libs -l pl.UTF-8 -Biblioteki współdzielone Clanga. - %package -n clang-multilib Summary: A C language family frontend for LLVM - 32-bit support Summary(pl.UTF-8): Frontend LLVM-a do języków z rodziny C - obsługa binariów 32-bitowych -License: NCSA Group: Development/Languages +URL: https://clang.llvm.org/ Requires: clang = %{version}-%{release} %description -n clang-multilib @@ -318,34 +424,26 @@ i rozszerzaniu. Ten pakiet zawiera rozszerzenie kompilatora C o obsługę tworzenia programów 32-bitowych na maszynie 64-bitowej. -%package -n clang-analyzer -Summary: A source code analysis framework -Summary(pl.UTF-8): Szkielet do analizy kodu źródłowego -License: NCSA -Group: Development/Languages -Requires: clang = %{version}-%{release} -# not picked up automatically since files are currently not instaled -# in standard Python hierarchies yet -Requires: python +%package -n clang-libs +Summary: Clang shared libraries +Summary(pl.UTF-8): Biblioteki współdzielone Clanga +Group: Libraries +URL: https://clang.llvm.org/ -%description -n clang-analyzer -The Clang Static Analyzer consists of both a source code analysis -framework and a standalone tool that finds bugs in C and Objective-C -programs. The standalone tool is invoked from the command-line, and is -intended to run in tandem with a build of a project or code base. +%description -n clang-libs +Clang shared libraries. -%description -n clang-analyzer -l pl.UTF-8 -Clang Static Analyzer składa się ze szkieletu do analizy kodu -źródłowego oraz samodzielnego narzędzia znajdującego błędy w -programach w C i C++. Narzędzie jest wywoływane z linii poleceń, z -myślą o uruchamianiu wraz z kompilacją projektu lub kodu. +%description -n clang-libs -l pl.UTF-8 +Biblioteki współdzielone Clanga. %package -n clang-devel Summary: Header files for Clang Summary(pl.UTF-8): Pliki nagłówkowe Clanga Group: Development/Languages +URL: https://clang.llvm.org/ Requires: %{name}-devel = %{version}-%{release} Requires: clang = %{version}-%{release} +%{?with_polly:Requires: llvm-polly-devel = %{version}-%{release}} %description -n clang-devel This package contains header files for the Clang compiler. @@ -356,8 +454,10 @@ Ten pakiet zawiera pliki nagłówkowe kompilatora Clang. %package -n clang-doc Summary: Documentation for Clang Summary(pl.UTF-8): Dokumentacja do Clanga +URL: https://clang.llvm.org/ Group: Documentation Requires: %{name} = %{version}-%{release} +BuildArch: noarch %description -n clang-doc Documentation for the Clang compiler front-end. @@ -368,8 +468,10 @@ Dokumentacja do frontendu kompilatora Clang. %package -n clang-apidocs Summary: API documentation for Clang Summary(pl.UTF-8): Dokumentacja API Clanga +URL: https://clang.llvm.org/ Group: Development/Languages Requires: clang-doc = %{version}-%{release} +BuildArch: noarch %description -n clang-apidocs API documentation for the Clang compiler. @@ -377,11 +479,33 @@ API documentation for the Clang compiler. %description -n clang-apidocs -l pl.UTF-8 Dokumentacja API kompilatora Clang. +%package -n clang-analyzer +Summary: A source code analysis framework +Summary(pl.UTF-8): Szkielet do analizy kodu źródłowego +Group: Development/Languages +URL: https://clang-analyzer.llvm.org/ +Requires: clang = %{version}-%{release} +# not picked up automatically since files are currently not instaled +# in standard Python hierarchies yet +Requires: python3 + +%description -n clang-analyzer +The Clang Static Analyzer consists of both a source code analysis +framework and a standalone tool that finds bugs in C and Objective-C +programs. The standalone tool is invoked from the command-line, and is +intended to run in tandem with a build of a project or code base. + +%description -n clang-analyzer -l pl.UTF-8 +Clang Static Analyzer składa się ze szkieletu do analizy kodu +źródłowego oraz samodzielnego narzędzia znajdującego błędy w +programach w C i C++. Narzędzie jest wywoływane z linii poleceń, z +myślą o uruchamianiu wraz z kompilacją projektu lub kodu. + %package -n clang-tools-extra Summary: Extra tools for Clang Summary(pl.UTF-8): Dodatkowe narzędzia do kompilatora Clang Group: Development/Tools -URL: http://clang.llvm.org/docs/ClangTools.html +URL: https://clang.llvm.org/docs/ClangTools.html Requires: clang = %{version}-%{release} %description -n clang-tools-extra @@ -390,11 +514,54 @@ Extra tools for Clang. %description -n clang-tools-extra -l pl.UTF-8 Dodatkowe narzędzia do kompilatora Clang. +%package -n bash-completion-clang +Summary: Bash completion for clang command +Summary(pl.UTF-8): Bashowe dopełnianie składni polecenia clang +Group: Applications/Shells +Requires: bash-completion >= 1:2.0 +Requires: clang = %{version}-%{release} +BuildArch: noarch + +%description -n bash-completion-clang +Bash completion for clang command. + +%description -n bash-completion-clang -l pl.UTF-8 +Bashowe dopełnianie składni polecenia clang. + +%package -n flang +Summary: Fortran frontend for LLVM +Summary(pl.UTF-8): Frontend LLVM-a do Fortranu +Group: Development/Languages +URL: http://flang.llvm.org/ +Requires: %{name}-mlir = %{version}-%{release} + +%description -n flang +Flang is a ground-up implementation of a Fortran front end written in +modern C++. + +%description -n flang -l pl.UTF-8 +Flang to napisana od podstaw we współczesnym C++ implementacja +frontendu do Fortranu. + +%package -n flang-devel +Summary: Fortran frontend for LLVM - development files +Summary(pl.UTF-8): Frontend LLVM-a do Fortranu - pliki programistyczne +Group: Development/Languages +URL: http://flang.llvm.org/ +Requires: %{name}-mlir-devel = %{version}-%{release} +Requires: flang-devel = %{version}-%{release} + +%description -n flang-devel +Development files for LLVM Fortran frontend. + +%description -n flang-devel -l pl.UTF-8 +Pliki prosramistyczne frontendu LLVM do Fortranu. + %package -n lld Summary: The LLVM linker Summary(pl.UTF-8): Konsolidator z projektu LLVM Group: Development/Libraries -URL: http://lld.llvm.org/ +URL: https://lld.llvm.org/ Requires: %{name} = %{version}-%{release} %description -n lld @@ -408,8 +575,9 @@ konsolidujących. Summary: Development files for LLD linker tools Summary(pl.UTF-8): Pliki programistyczne narzędzi konsolidujących LLD Group: Development/Tools -URL: http://lld.llvm.org/ +URL: https://lld.llvm.org/ Requires: %{name}-devel = %{version}-%{release} +Requires: xar-devel >= 1.6 %description -n lld-devel Development files for LLD linker tools. @@ -421,9 +589,9 @@ Pliki programistyczne narzędzi konsolidujących LLD. Summary: Next generation high-performance debugger Summary(pl.UTF-8): Wydajny debugger nowej generacji Group: Development/Debuggers -URL: http://lldb.llvm.org/ +URL: https://lldb.llvm.org/ Requires: %{name} = %{version}-%{release} -Requires: python-six +Requires: python3-six %description -n lldb LLDB is a next generation, high-performance debugger. It is built as a @@ -441,7 +609,7 @@ disasembler LLVM. Summary: Development files for LLDB debugger Summary(pl.UTF-8): Pliki programistyczne debuggera LLDB Group: Development/Libraries -URL: http://lldb.llvm.org/ +URL: https://lldb.llvm.org/ Requires: %{name}-devel = %{version}-%{release} Requires: clang-devel = %{version}-%{release} Requires: lldb = %{version}-%{release} @@ -487,6 +655,7 @@ Summary: Documentation for LLVM's OCaml binding Summary(pl.UTF-8): Dokumentacja wiązania OCamla do LLVM-a Group: Documentation Requires: %{name}-ocaml = %{version}-%{release} +BuildArch: noarch %description ocaml-doc HTML documentation for LLVM's OCaml binding. @@ -521,28 +690,50 @@ Clang format and rename integration for Vim. Integracja narzędzi Clang do formatowania i zmiany nazw z Vimem. %prep -%setup -q -n %{name}-%{version}.src -a1 %{?with_rt:-a2} %{?with_lldb:-a3} %{?with_polly:-a4} -a5 -a6 -%{__mv} cfe-%{version}.src tools/clang +%setup -q -n %{name}-%{version}.src -a1 %{?with_rt:-a2} %{?with_lldb:-a3} %{?with_polly:-a4} -a5 -a6 %{?with_flang:-a7} %{?with_mlir:-a8} -a9 +%{__mv} clang-%{version}.src tools/clang %{?with_rt:%{__mv} compiler-rt-%{version}.src projects/compiler-rt} %{?with_lldb:%{__mv} lldb-%{version}.src tools/lldb} %{?with_polly:%{__mv} polly-%{version}.src tools/polly} %{__mv} clang-tools-extra-%{version}.src tools/clang/tools/extra %{__mv} lld-%{version}.src tools/lld +%if %{with flang} +%{__mv} flang-%{version}.src tools/flang +%endif +%if %{with mlir} +%{__mv} mlir-%{version}.src tools/mlir +%endif +%{__mv} cmake-%{version}.src cmake-utils %patch1 -p1 %patch3 -p1 %patch4 -p1 %patch5 -p1 +%if %{with flang} +%patch6 -p1 +%endif +%patch7 -p1 +%patch8 -p1 +%patch9 -p1 +%if %{with rt} +%patch10 -p1 +%patch12 -p1 +%endif +%patch11 -p1 -grep -rl /usr/bin/env tools utils | xargs sed -i -e '1{ - s,^#!.*bin/env python,#!%{__python}, +grep -rl /usr/bin/env projects tools utils | xargs sed -i -e '1{ + s,^#!.*bin/env python3\?,#!%{__python3}, s,^#!.*bin/env perl,#!%{__perl}, }' find -name '*.py' -print0 | xargs -0 sed -i -e '1{ - s,^#!.*bin/python.*,#!%{__python}, + s,^#!.*bin/python.*,#!%{__python3}, }' +%if %{with flang} +%{__sed} -i -e '1s,/usr/bin/env bash,/bin/bash,' tools/flang/tools/f18/flang-to-external-fc.in +%endif + %build install -d build @@ -551,31 +742,62 @@ install -d build cd build CPPFLAGS="%{rpmcppflags} -D_FILE_OFFSET_BITS=64" -%cmake \ -%if "%{_lib}" == "lib64" - -DLLVM_LIBDIR_SUFFIX:STRING=64 \ +%if %{with lowmem} +export CFLAGS="%{rpmcflags} -NDEBUG -g0" +export CXXFLAGS="%{rpmcxxflags} -NDEBUG -g0" +if echo 'int main(){}' | %{__cc} -x c %{rpmldflags} -Wl,--reduce-memory-overheads -o /dev/null - > /dev/null 2>&1; then +export LDFLAGS="%{rpmldflags} -Wl,--reduce-memory-overheads" +fi %endif -%if "%{_lib}" == "libx32" - -DLLVM_LIBDIR_SUFFIX:STRING=x32 \ + +%cmake .. \ + -DBUILD_SHARED_LIBS:BOOL=OFF \ + -DENABLE_LINKER_BUILD_ID:BOOL=ON \ + -DLLVM_COMMON_CMAKE_UTILS="%{_builddir}/%{buildsubdir}/cmake-utils" \ + -DLLVM_BINDINGS_LIST:LIST="%{?with_ocaml:ocaml}" \ + -DLLVM_BINUTILS_INCDIR:STRING=%{_includedir} \ + -DLLVM_BUILD_LLVM_DYLIB:BOOL=ON \ + -DLLVM_ENABLE_ASSERTIONS:BOOL=OFF \ + -DLLVM_INSTALL_PACKAGE_DIR=%(realpath -m "--relative-to=%{_prefix}" "%{_libdir}/cmake/llvm") \ + -DLLVM_TOOLS_INSTALL_DIR=%(realpath -m "--relative-to=%{_prefix}" "%{_bindir}") \ +%ifarch %{arm} + -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR:BOOL=ON \ %endif %if %{with apidocs} -DLLVM_ENABLE_DOXYGEN:BOOL=ON \ %endif + %{?with_cxxmodules:-DLLVM_ENABLE_MODULES:BOOL=ON} \ + -DLLVM_ENABLE_PIC:BOOL=ON \ + -DLLVM_ENABLE_RTTI:BOOL=ON \ %if %{with doc} -DLLVM_ENABLE_SPHINX:BOOL=ON \ - -DSPHINX_WARNINGS_AS_ERRORS=OFF \ %endif - -DLLVM_ENABLE_ASSERTIONS:BOOL=OFF \ - -DLLVM_ENABLE_CXX1Y:BOOL=ON \ - -DLLVM_ENABLE_RTTI:BOOL=ON \ - -DLLVM_ENABLE_PIC:BOOL=ON \ - -DLLVM_BINDINGS_LIST:LIST="%{?with_ocaml:ocaml}" \ - -DLLVM_BUILD_LLVM_DYLIB:BOOL=ON \ + -DLLVM_INCLUDE_BENCHMARKS:BOOL=OFF \ + %{?with_z3:-DLLVM_ENABLE_Z3_SOLVER:BOOL=ON} \ +%if "%{_lib}" == "lib64" + -DLLVM_LIBDIR_SUFFIX:STRING=64 \ +%endif +%if "%{_lib}" == "libx32" + -DLLVM_LIBDIR_SUFFIX:STRING=x32 \ +%endif -DLLVM_LINK_LLVM_DYLIB:BOOL=ON \ - -DBUILD_SHARED_LIBS:BOOL=OFF \ - -DENABLE_LINKER_BUILD_ID:BOOL=ON \ - -DLLVM_BINUTILS_INCDIR:STRING=%{_includedir} \ - ../ + -DLLVM_TARGET_ARCH:STRING=%{_target_base_arch} \ + -DLLVM_DEFAULT_TARGET_TRIPLE:STRING=%{_target_platform} \ +%if %{with lowmem} + -DLLVM_PARALLEL_LINK_JOBS:STRING=1 \ +%endif + -DLLVM_TARGETS_TO_BUILD="%{targets_to_build}" \ + -DLLVM_INCLUDE_TESTS:BOOL=OFF \ +%if %{with polly} + %{cmake_on_off target_nvptx POLLY_ENABLE_GPGPU_CODEGEN} \ +%endif + -DSPHINX_WARNINGS_AS_ERRORS=OFF \ +%if %{with rt} + -DCOMPILER_RT_INCLUDE_TESTS:BOOL=OFF \ +%ifarch x32 + -DCOMPILER_RT_BUILD_MEMPROF:BOOL=OFF +%endif +%endif %{__make} \ VERBOSE=1 \ @@ -595,11 +817,15 @@ CPPFLAGS="%{rpmcppflags} -D_FILE_OFFSET_BITS=64" %{__make} -C tools/clang/docs docs-clang-html %{__make} -C tools/clang/docs docs-clang-man %{__make} -C tools/lld/docs docs-lld-html +%if %{with lldb} +# workaround failed import of _lldb +cp -pnL %{_lib}/liblldb.so tools/lldb/docs/lldb/_lldb.so %{__make} \ LD_LIBRARY_PATH=$(pwd)/%{_lib} \ - -C tools/lldb/docs lldb-python-doc + -C tools/lldb/docs lldb-python-doc-package %{__make} -C tools/lldb/docs lldb-cpp-doc %endif +%endif %install rm -rf $RPM_BUILD_ROOT @@ -608,17 +834,15 @@ rm -rf $RPM_BUILD_ROOT DESTDIR=$RPM_BUILD_ROOT # only some .pyc files are created by make install -%py_comp $RPM_BUILD_ROOT%{py_sitedir} -%py_ocomp $RPM_BUILD_ROOT%{py_sitedir} - -# Adjust static analyzer installation -# http://clang-analyzer.llvm.org/installation#OtherPlatforms -install -d $RPM_BUILD_ROOT%{_libdir}/scan-build -%{__mv} $RPM_BUILD_ROOT%{_prefix}/libexec/c??-analyzer $RPM_BUILD_ROOT%{_libdir}/scan-build -%{__sed} -i -e 's,/\.\./libexec/,/../%{_lib}/scan-build/,' $RPM_BUILD_ROOT%{_bindir}/scan-build -%py_comp $RPM_BUILD_ROOT%{_datadir}/scan-view -%py_ocomp $RPM_BUILD_ROOT%{_datadir}/scan-view -%py_postclean %{_datadir}/scan-view +%py3_comp $RPM_BUILD_ROOT%{py3_sitedir} +%py3_ocomp $RPM_BUILD_ROOT%{py3_sitedir} + +# Adjust static analyzer installation (see -libexecdir patch) +abs_ca_libexecdir="%{_libexecdir}/clang-analyzer" +rel_ca_libexecdir="${abs_ca_libexecdir#%{_prefix}}" +%{__sed} -i -e "s,/\.\./libexec/,/..${rel_ca_libexecdir}/," $RPM_BUILD_ROOT%{_bindir}/scan-build +%py3_comp $RPM_BUILD_ROOT%{_datadir}/scan-view +%py3_ocomp $RPM_BUILD_ROOT%{_datadir}/scan-view # not installed by cmake buildsystem install build/bin/pp-trace $RPM_BUILD_ROOT%{_bindir} @@ -626,7 +850,7 @@ install build/bin/pp-trace $RPM_BUILD_ROOT%{_bindir} %if %{with doc} cp -p build/docs/man/*.1 $RPM_BUILD_ROOT%{_mandir}/man1 # these tools are not installed -%{__rm} $RPM_BUILD_ROOT%{_mandir}/man1/{FileCheck,llvm-build}.1 +%{__rm} $RPM_BUILD_ROOT%{_mandir}/man1/{FileCheck,clang-tblgen,lldb-tblgen}.1 # make links echo '.so llvm-ar.1' > $RPM_BUILD_ROOT%{_mandir}/man1/llvm-ranlib.1 %endif @@ -650,16 +874,29 @@ for f in LICENSE.TXT NOTES.txt README.txt; do ln tools/clang/$f clang-docs done -%{__rm} $RPM_BUILD_ROOT%{_bindir}/{c-index-test,llvm-c-test} +install -d $RPM_BUILD_ROOT%{bash_compdir} +%{__mv} $RPM_BUILD_ROOT%{_datadir}/clang/bash-autocomplete.sh $RPM_BUILD_ROOT%{bash_compdir}/clang + +%{__rm} $RPM_BUILD_ROOT%{_bindir}/c-index-test # not this OS %{__rm} $RPM_BUILD_ROOT%{_datadir}/clang/clang-format-bbedit.applescript -# use system six -%{__rm} $RPM_BUILD_ROOT%{py_sitedir}/six.py* # it seems it is used internally by an extra clang tool %{__rm} $RPM_BUILD_ROOT%{_libdir}/libfindAllSymbols.a +%if %{with mlir} +%{__rm} -r $RPM_BUILD_ROOT%{_libdir}/objects-TLD +%endif # disable completeness check incompatible with split packaging -%{__sed} -i -e '/^foreach(target .*IMPORT_CHECK_TARGETS/,/^endforeach/d; /^unset(_IMPORT_CHECK_TARGETS)/d' $RPM_BUILD_ROOT%{_libdir}/cmake/llvm/LLVMExports.cmake +%{__sed} -i -e '/^foreach(target .*IMPORT_CHECK_TARGETS/,/^endforeach/d; /^unset(_IMPORT_CHECK_TARGETS)/d' \ + $RPM_BUILD_ROOT%{_libdir}/cmake/clang/ClangTargets.cmake \ +%if %{with flang} + $RPM_BUILD_ROOT%{_libdir}/cmake/flang/FlangTargets.cmake \ +%endif + $RPM_BUILD_ROOT%{_libdir}/cmake/lld/LLDTargets.cmake \ + $RPM_BUILD_ROOT%{_libdir}/cmake/llvm/LLVMExports.cmake \ +%if %{with mlir} + $RPM_BUILD_ROOT%{_libdir}/cmake/mlir/MLIRTargets.cmake +%endif %clean rm -rf $RPM_BUILD_ROOT @@ -667,6 +904,9 @@ rm -rf $RPM_BUILD_ROOT %post libs -p /sbin/ldconfig %postun libs -p /sbin/ldconfig +%post mlir -p /sbin/ldconfig +%postun mlir -p /sbin/ldconfig + %post -n clang-libs -p /sbin/ldconfig %postun -n clang-libs -p /sbin/ldconfig @@ -680,9 +920,12 @@ rm -rf $RPM_BUILD_ROOT %attr(755,root,root) %{_bindir}/dsymutil %attr(755,root,root) %{_bindir}/llc %attr(755,root,root) %{_bindir}/lli +%attr(755,root,root) %{_bindir}/llvm-addr2line %attr(755,root,root) %{_bindir}/llvm-ar %attr(755,root,root) %{_bindir}/llvm-as %attr(755,root,root) %{_bindir}/llvm-bcanalyzer +%attr(755,root,root) %{_bindir}/llvm-bitcode-strip +%attr(755,root,root) %{_bindir}/llvm-c-test %attr(755,root,root) %{_bindir}/llvm-cat %attr(755,root,root) %{_bindir}/llvm-cfi-verify %attr(755,root,root) %{_bindir}/llvm-cov @@ -690,94 +933,135 @@ rm -rf $RPM_BUILD_ROOT %attr(755,root,root) %{_bindir}/llvm-cxxdump %attr(755,root,root) %{_bindir}/llvm-cxxfilt %attr(755,root,root) %{_bindir}/llvm-cxxmap +%attr(755,root,root) %{_bindir}/llvm-debuginfo-analyzer +%attr(755,root,root) %{_bindir}/llvm-debuginfod +%attr(755,root,root) %{_bindir}/llvm-debuginfod-find %attr(755,root,root) %{_bindir}/llvm-diff %attr(755,root,root) %{_bindir}/llvm-dis %attr(755,root,root) %{_bindir}/llvm-dlltool %attr(755,root,root) %{_bindir}/llvm-dwarfdump +%attr(755,root,root) %{_bindir}/llvm-dwarfutil %attr(755,root,root) %{_bindir}/llvm-dwp -%attr(755,root,root) %{_bindir}/llvm-elfabi %attr(755,root,root) %{_bindir}/llvm-exegesis %attr(755,root,root) %{_bindir}/llvm-extract +%attr(755,root,root) %{_bindir}/llvm-gsymutil +%attr(755,root,root) %{_bindir}/llvm-ifs +%attr(755,root,root) %{_bindir}/llvm-install-name-tool +%attr(755,root,root) %{_bindir}/llvm-jitlink %attr(755,root,root) %{_bindir}/llvm-lib +%attr(755,root,root) %{_bindir}/llvm-libtool-darwin %attr(755,root,root) %{_bindir}/llvm-link +%attr(755,root,root) %{_bindir}/llvm-lipo %attr(755,root,root) %{_bindir}/llvm-lto %attr(755,root,root) %{_bindir}/llvm-lto2 %attr(755,root,root) %{_bindir}/llvm-mc %attr(755,root,root) %{_bindir}/llvm-mca +%attr(755,root,root) %{_bindir}/llvm-ml %attr(755,root,root) %{_bindir}/llvm-modextract %attr(755,root,root) %{_bindir}/llvm-mt %attr(755,root,root) %{_bindir}/llvm-nm %attr(755,root,root) %{_bindir}/llvm-objcopy %attr(755,root,root) %{_bindir}/llvm-objdump %attr(755,root,root) %{_bindir}/llvm-opt-report +%attr(755,root,root) %{_bindir}/llvm-otool %attr(755,root,root) %{_bindir}/llvm-pdbutil %attr(755,root,root) %{_bindir}/llvm-profdata +%attr(755,root,root) %{_bindir}/llvm-profgen %attr(755,root,root) %{_bindir}/llvm-ranlib %attr(755,root,root) %{_bindir}/llvm-rc %attr(755,root,root) %{_bindir}/llvm-readelf %attr(755,root,root) %{_bindir}/llvm-readobj +%attr(755,root,root) %{_bindir}/llvm-reduce +%attr(755,root,root) %{_bindir}/llvm-remark-size-diff +%attr(755,root,root) %{_bindir}/llvm-remarkutil %attr(755,root,root) %{_bindir}/llvm-rtdyld +%attr(755,root,root) %{_bindir}/llvm-sim %attr(755,root,root) %{_bindir}/llvm-size %attr(755,root,root) %{_bindir}/llvm-split %attr(755,root,root) %{_bindir}/llvm-strip %attr(755,root,root) %{_bindir}/llvm-stress %attr(755,root,root) %{_bindir}/llvm-strings %attr(755,root,root) %{_bindir}/llvm-symbolizer +%attr(755,root,root) %{_bindir}/llvm-tapi-diff %attr(755,root,root) %{_bindir}/llvm-tblgen +%attr(755,root,root) %{_bindir}/llvm-tli-checker %attr(755,root,root) %{_bindir}/llvm-undname +%attr(755,root,root) %{_bindir}/llvm-windres %attr(755,root,root) %{_bindir}/llvm-xray -%attr(755,root,root) %{_bindir}/obj2yaml %attr(755,root,root) %{_bindir}/opt %attr(755,root,root) %{_bindir}/sancov %attr(755,root,root) %{_bindir}/sanstats +%attr(755,root,root) %{_bindir}/tblgen-lsp-server %attr(755,root,root) %{_bindir}/verify-uselistorder -%attr(755,root,root) %{_bindir}/yaml2obj %if %{with doc} %{_mandir}/man1/bugpoint.1* %{_mandir}/man1/dsymutil.1* %{_mandir}/man1/lit.1* %{_mandir}/man1/llc.1* %{_mandir}/man1/lli.1* +%{_mandir}/man1/llvm-addr2line.1* %{_mandir}/man1/llvm-ar.1* %{_mandir}/man1/llvm-as.1* %{_mandir}/man1/llvm-bcanalyzer.1* %{_mandir}/man1/llvm-cov.1* +%{_mandir}/man1/llvm-cxxfilt.1* %{_mandir}/man1/llvm-cxxmap.1* +%{_mandir}/man1/llvm-debuginfo-analyzer.1* %{_mandir}/man1/llvm-diff.1* %{_mandir}/man1/llvm-dis.1* %{_mandir}/man1/llvm-dwarfdump.1* +%{_mandir}/man1/llvm-dwarfutil.1* %{_mandir}/man1/llvm-exegesis.1* %{_mandir}/man1/llvm-extract.1* +%{_mandir}/man1/llvm-ifs.1* +%{_mandir}/man1/llvm-install-name-tool.1* %{_mandir}/man1/llvm-lib.1* +%{_mandir}/man1/llvm-libtool-darwin.1* %{_mandir}/man1/llvm-link.1* +%{_mandir}/man1/llvm-lipo.1* +%{_mandir}/man1/llvm-locstats.1* %{_mandir}/man1/llvm-mca.1* %{_mandir}/man1/llvm-nm.1* +%{_mandir}/man1/llvm-objcopy.1* %{_mandir}/man1/llvm-objdump.1* +%{_mandir}/man1/llvm-opt-report.1* +%{_mandir}/man1/llvm-otool.1* %{_mandir}/man1/llvm-pdbutil.1* %{_mandir}/man1/llvm-profdata.1* +%{_mandir}/man1/llvm-profgen.1* %{_mandir}/man1/llvm-ranlib.1* +%{_mandir}/man1/llvm-readelf.1* %{_mandir}/man1/llvm-readobj.1* +%{_mandir}/man1/llvm-remark-size-diff.1* +%{_mandir}/man1/llvm-remarkutil.1* +%{_mandir}/man1/llvm-size.1* %{_mandir}/man1/llvm-stress.1* +%{_mandir}/man1/llvm-strings.1* +%{_mandir}/man1/llvm-strip.1* %{_mandir}/man1/llvm-symbolizer.1* +%{_mandir}/man1/llvm-tblgen.1* +%{_mandir}/man1/llvm-tli-checker.1* %{_mandir}/man1/opt.1* %{_mandir}/man1/tblgen.1* %endif %files libs %defattr(644,root,root,755) +%attr(755,root,root) %{_libdir}/LLVMgold.so %attr(755,root,root) %{_libdir}/libLLVM-%{abi}.so # non-soname symlink %attr(755,root,root) %{_libdir}/libLLVM-%{version}.so -%attr(755,root,root) %ghost %{_libdir}/libLTO.so.8 -%attr(755,root,root) %{_libdir}/LLVMgold.so -%attr(755,root,root) %{_libdir}/libOptRemarks.so.8 +%attr(755,root,root) %{_libdir}/libLTO.so.16 +%attr(755,root,root) %{_libdir}/libRemarks.so.16 +%attr(755,root,root) %{_libdir}/libclang-cpp.so.16 %files devel %defattr(644,root,root,755) %attr(755,root,root) %{_bindir}/llvm-config %attr(755,root,root) %{_libdir}/libLLVM.so %attr(755,root,root) %{_libdir}/libLTO.so -%attr(755,root,root) %{_libdir}/libOptRemarks.so +%attr(755,root,root) %{_libdir}/libRemarks.so +%attr(755,root,root) %{_libdir}/libclang-cpp.so %{_libdir}/libLLVM*.a %{_includedir}/llvm %{_includedir}/llvm-c @@ -795,17 +1079,52 @@ rm -rf $RPM_BUILD_ROOT %doc apidoc/* %endif +%if %{with mlir} +%files mlir +%defattr(644,root,root,755) +%attr(755,root,root) %{_bindir}/mlir-cpu-runner +%attr(755,root,root) %{_bindir}/mlir-linalg-ods-yaml-gen +%attr(755,root,root) %{_bindir}/mlir-lsp-server +%attr(755,root,root) %{_bindir}/mlir-opt +%attr(755,root,root) %{_bindir}/mlir-pdll +%attr(755,root,root) %{_bindir}/mlir-pdll-lsp-server* +%attr(755,root,root) %{_bindir}/mlir-reduce +%attr(755,root,root) %{_bindir}/mlir-tblgen +%attr(755,root,root) %{_bindir}/mlir-translate +%attr(755,root,root) %{_libdir}/libMLIR.so.16 +%attr(755,root,root) %{_libdir}/libmlir_async_runtime.so.16 +%attr(755,root,root) %{_libdir}/libmlir_c_runner_utils.so.16 +%attr(755,root,root) %{_libdir}/libmlir_float16_utils.so.16 +%attr(755,root,root) %{_libdir}/libmlir_runner_utils.so.16 +%if %{with doc} +%{_mandir}/man1/mlir-tblgen.1* +%endif + +%files mlir-devel +%defattr(644,root,root,755) +%attr(755,root,root) %{_libdir}/libMLIR.so +%attr(755,root,root) %{_libdir}/libmlir_async_runtime.so +%attr(755,root,root) %{_libdir}/libmlir_c_runner_utils.so +%attr(755,root,root) %{_libdir}/libmlir_float16_utils.so +%attr(755,root,root) %{_libdir}/libmlir_runner_utils.so +%{_libdir}/libMLIR*.a +%{_includedir}/mlir +%{_includedir}/mlir-c +%{_libdir}/cmake/mlir +%endif + %if %{with polly} %files polly %defattr(644,root,root,755) -%doc tools/polly/{CREDITS.txt,LICENSE.txt,README} tools/polly/www/{bugs,changelog,contributors}.html +%doc tools/polly/{CREDITS.txt,LICENSE.TXT,README} tools/polly/www/{bugs,changelog,contributors}.html %attr(755,root,root) %{_libdir}/LLVMPolly.so +%{?with_target_nvptx:%attr(755,root,root) %{_libdir}/libGPURuntime.so} %files polly-devel %defattr(644,root,root,755) %{_libdir}/libPolly.a %{_libdir}/libPollyISL.a -%{_libdir}/libPollyPPCG.a +%{?with_target_nvptx:%{_libdir}/libPollyPPCG.a} %{_includedir}/polly %{_libdir}/cmake/polly %endif @@ -813,95 +1132,124 @@ rm -rf $RPM_BUILD_ROOT %files -n clang %defattr(644,root,root,755) %doc clang-docs/{LICENSE.TXT,NOTES.txt,README.txt} %{?with_tests:clang-testlog.txt} +%attr(755,root,root) %{_bindir}/amdgpu-arch %attr(755,root,root) %{_bindir}/clang %attr(755,root,root) %{_bindir}/clang++ %attr(755,root,root) %{_bindir}/clang-%{abi} %attr(755,root,root) %{_bindir}/clang-check %attr(755,root,root) %{_bindir}/clang-cl %attr(755,root,root) %{_bindir}/clang-cpp +%attr(755,root,root) %{_bindir}/clang-doc %attr(755,root,root) %{_bindir}/clang-format -%attr(755,root,root) %{_bindir}/clang-import-test +%attr(755,root,root) %{_bindir}/clang-linker-wrapper %attr(755,root,root) %{_bindir}/clang-offload-bundler +%attr(755,root,root) %{_bindir}/clang-offload-packager +%attr(755,root,root) %{_bindir}/clang-pseudo +%attr(755,root,root) %{_bindir}/clang-repl +%attr(755,root,root) %{_bindir}/clang-tblgen %attr(755,root,root) %{_bindir}/git-clang-format +%attr(755,root,root) %{_bindir}/nvptx-arch %dir %{_libdir}/clang -%dir %{_libdir}/clang/%{version} -%{_libdir}/clang/%{version}/include +%dir %{_libdir}/clang/%{abi} +%{_libdir}/clang/%{abi}/include %if %{with rt} -%ifarch %{ix86} %{x8664} -%dir %{_libdir}/clang/%{version}/lib -%dir %{_libdir}/clang/%{version}/lib/linux -%dir %{_libdir}/clang/%{version}/share +%ifarch %{x8664} x32 aarch64 +%dir %{_libdir}/clang/%{abi}/bin +%attr(755,root,root) %{_libdir}/clang/%{abi}/bin/hwasan_symbolize +%endif +%ifarch %{ix86} %{x8664} aarch64 %{armv7} +%dir %{_libdir}/clang/%{abi}/lib +%dir %{_libdir}/clang/%{abi}/lib/*-linux* +%dir %{_libdir}/clang/%{abi}/share %endif %ifarch x32 %if %{with multilib} -%dir %{_libdir}/clang/%{version}/lib -%dir %{_libdir}/clang/%{version}/lib/linux -%dir %{_libdir}/clang/%{version}/share +%dir %{_libdir}/clang/%{abi}/lib +%dir %{_libdir}/clang/%{abi}/lib/*-linux* +%dir %{_libdir}/clang/%{abi}/share %endif %endif %ifarch %{ix86} -%{_libdir}/clang/%{version}/lib/linux/libclang_rt.*-i*86.a -%attr(755,root,root) %{_libdir}/clang/%{version}/lib/linux/libclang_rt.*-i*86.so +%{_libdir}/clang/%{abi}/lib/i*86-*linux/clang_rt.*.o +%{_libdir}/clang/%{abi}/lib/i*86-*linux/libclang_rt.*.a +%attr(755,root,root) %{_libdir}/clang/%{abi}/lib/i*86-*linux/libclang_rt.*.so %endif %ifarch %{x8664} -%{_libdir}/clang/%{version}/lib/linux/libclang_rt.*-x86_64.a -%attr(755,root,root) %{_libdir}/clang/%{version}/lib/linux/libclang_rt.*-x86_64.so -%{_libdir}/clang/%{version}/lib/linux/libclang_rt.*-x86_64.a.syms +%{_libdir}/clang/%{abi}/lib/x86_64-*linux/clang_rt.*.o +%{_libdir}/clang/%{abi}/lib/x86_64-*linux/libclang_rt.*.a +%attr(755,root,root) %{_libdir}/clang/%{abi}/lib/x86_64-*linux/libclang_rt.*.so +%{_libdir}/clang/%{abi}/lib/x86_64-*linux/libclang_rt.*.a.syms +%{_libdir}/clang/%{abi}/lib/x86_64-*linux/liborc_rt.a +%endif +%ifarch aarch64 +%{_libdir}/clang/%{abi}/lib/aarch64-*linux/clang_rt.*.o +%{_libdir}/clang/%{abi}/lib/aarch64-*linux/libclang_rt.*.a +%attr(755,root,root) %{_libdir}/clang/%{abi}/lib/aarch64-*linux/libclang_rt.*.so +%{_libdir}/clang/%{abi}/lib/aarch64-*linux/libclang_rt.*.a.syms +%{_libdir}/clang/%{abi}/lib/aarch64-*linux/liborc_rt.a +%endif +%ifarch %{armv7} +%ifarch %{arm32_with_hf} +%{_libdir}/clang/%{abi}/lib/arm-*linux%{_gnu}hf/clang_rt.*.o +%{_libdir}/clang/%{abi}/lib/arm-*linux%{_gnu}hf/libclang_rt.*.a +%attr(755,root,root) %{_libdir}/clang/%{abi}/lib/arm-*linux%{_gnu}hf/libclang_rt.*.so +%{_libdir}/clang/%{abi}/lib/arm-*linux%{_gnu}hf/libclang_rt.*.a.syms +%{_libdir}/clang/%{abi}/lib/arm-*linux%{_gnu}hf/liborc_rt.a +%else +%{_libdir}/clang/%{abi}/lib/arm-*linux%{_gnu}/clang_rt.*.o +%{_libdir}/clang/%{abi}/lib/arm-*linux%{_gnu}/libclang_rt.*.a +%attr(755,root,root) %{_libdir}/clang/%{abi}/lib/arm-*linux%{_gnu}/libclang_rt.*.so +%{_libdir}/clang/%{abi}/lib/arm-*linux%{_gnu}/libclang_rt.*.a.syms +%{_libdir}/clang/%{abi}/lib/arm-*linux%{_gnu}/liborc_rt.a +%endif %endif %ifarch %{ix86} %{x8664} %{arm} aarch64 mips mips64 ppc64 -%{_libdir}/clang/%{version}/share/asan_blacklist.txt +%{_libdir}/clang/%{abi}/share/asan_ignorelist.txt %endif -%ifarch %{ix86} %{x8664} mips64 -%{_libdir}/clang/%{version}/share/cfi_blacklist.txt +%ifarch %{ix86} %{x8664} mips64 aarch64 %{armv7} +%{_libdir}/clang/%{abi}/share/cfi_ignorelist.txt %endif %ifarch %{x8664} aarch64 mips64 -%{_libdir}/clang/%{version}/share/dfsan_abilist.txt -%{_libdir}/clang/%{version}/share/msan_blacklist.txt +%{_libdir}/clang/%{abi}/share/dfsan_abilist.txt +%{_libdir}/clang/%{abi}/share/msan_ignorelist.txt %endif %ifarch %{x8664} aarch64 -%{_libdir}/clang/%{version}/share/hwasan_blacklist.txt +%{_libdir}/clang/%{abi}/share/hwasan_ignorelist.txt %endif %ifarch x32 %if %{with multilib} -%{_libdir}/clang/%{version}/share/asan_blacklist.txt -%{_libdir}/clang/%{version}/share/cfi_blacklist.txt -%{_libdir}/clang/%{version}/share/dfsan_abilist.txt -%{_libdir}/clang/%{version}/share/msan_blacklist.txt -%{_libdir}/clang/%{version}/share/hwasan_blacklist.txt +%{_libdir}/clang/%{abi}/share/asan_ignorelist.txt +%{_libdir}/clang/%{abi}/share/cfi_ignorelist.txt +%{_libdir}/clang/%{abi}/share/dfsan_abilist.txt +%{_libdir}/clang/%{abi}/share/msan_ignorelist.txt +%{_libdir}/clang/%{abi}/share/hwasan_ignorelist.txt %endif %endif %endif %dir %{_datadir}/clang %{_datadir}/clang/clang-format-diff.py -%files -n clang-libs -%defattr(644,root,root,755) -%attr(755,root,root) %{_libdir}/libclang.so.%{abi} - %if %{with rt} && %{with multilib} %ifarch %{x8664} x32 %files -n clang-multilib %defattr(644,root,root,755) -%{_libdir}/clang/%{version}/lib/linux/libclang_rt.*-i386.a -%attr(755,root,root) %{_libdir}/clang/%{version}/lib/linux/libclang_rt.*-i386.so +%{_libdir}/clang/%{abi}/lib/i386-*linux/clang_rt.*.o +%{_libdir}/clang/%{abi}/lib/i386-*linux/libclang_rt.*.a +%attr(755,root,root) %{_libdir}/clang/%{abi}/lib/i386-*linux/libclang_rt.*.so %endif %ifarch x32 -%{_libdir}/clang/%{version}/lib/linux/libclang_rt.*-x86_64.a -%attr(755,root,root) %{_libdir}/clang/%{version}/lib/linux/libclang_rt.*-x86_64.so -%{_libdir}/clang/%{version}/lib/linux/libclang_rt.*-x86_64.a.syms +%{_libdir}/clang/%{abi}/lib/x86_64-*linux/clang_rt.*.o +%{_libdir}/clang/%{abi}/lib/x86_64-*linux/libclang_rt.*.a +%attr(755,root,root) %{_libdir}/clang/%{abi}/lib/x86_64-*linux/libclang_rt.*.so +%{_libdir}/clang/%{abi}/lib/x86_64-*linux/libclang_rt.*.a.syms +%{_libdir}/clang/%{abi}/lib/x86_64-*linux/liborc_rt.a %endif %endif -%files -n clang-analyzer +%files -n clang-libs %defattr(644,root,root,755) -%attr(755,root,root) %{_bindir}/scan-build -%attr(755,root,root) %{_bindir}/scan-view -%{_datadir}/scan-build -%{_datadir}/scan-view -%{_mandir}/man1/scan-build.1* -%dir %{_libdir}/scan-build -%attr(755,root,root) %{_libdir}/scan-build/c++-analyzer -%attr(755,root,root) %{_libdir}/scan-build/ccc-analyzer +%attr(755,root,root) %{_libdir}/libclang.so.16 +%attr(755,root,root) %{_libdir}/libclang.so.*.*.* %files -n clang-devel %defattr(644,root,root,755) @@ -909,6 +1257,7 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/libclang*.a %{_includedir}/clang %{_includedir}/clang-c +%{_includedir}/clang-tidy %{_libdir}/cmake/clang %files -n clang-doc @@ -921,17 +1270,42 @@ rm -rf $RPM_BUILD_ROOT %doc clang-apidoc/* %endif +%files -n clang-analyzer +%defattr(644,root,root,755) +%dir %{_libexecdir}/clang-analyzer +# perl tools +%attr(755,root,root) %{_bindir}/scan-build +%attr(755,root,root) %{_libexecdir}/clang-analyzer/c++-analyzer +%attr(755,root,root) %{_libexecdir}/clang-analyzer/ccc-analyzer +%{_datadir}/scan-build +%{_mandir}/man1/scan-build.1* +# python tools +%attr(755,root,root) %{_bindir}/analyze-build +%attr(755,root,root) %{_bindir}/intercept-build +%attr(755,root,root) %{_bindir}/scan-build-py +%attr(755,root,root) %{_bindir}/scan-view +%attr(755,root,root) %{_libexecdir}/clang-analyzer/analyze-c++ +%attr(755,root,root) %{_libexecdir}/clang-analyzer/analyze-cc +%attr(755,root,root) %{_libexecdir}/clang-analyzer/intercept-c++ +%attr(755,root,root) %{_libexecdir}/clang-analyzer/intercept-cc +%{_prefix}/%{_lib}/libear +%{_prefix}/%{_lib}/libscanbuild +%{_datadir}/scan-view + %files -n clang-tools-extra %defattr(644,root,root,755) %doc tools/clang/tools/extra/{CODE_OWNERS.TXT,README.txt} %attr(755,root,root) %{_bindir}/clang-apply-replacements %attr(755,root,root) %{_bindir}/clang-change-namespace %attr(755,root,root) %{_bindir}/clang-extdef-mapping +%attr(755,root,root) %{_bindir}/clang-include-cleaner %attr(755,root,root) %{_bindir}/clang-include-fixer +%attr(755,root,root) %{_bindir}/clang-move %attr(755,root,root) %{_bindir}/clang-query %attr(755,root,root) %{_bindir}/clang-refactor %attr(755,root,root) %{_bindir}/clang-rename %attr(755,root,root) %{_bindir}/clang-reorder-fields +%attr(755,root,root) %{_bindir}/clang-scan-deps %attr(755,root,root) %{_bindir}/clang-tidy %attr(755,root,root) %{_bindir}/clangd %attr(755,root,root) %{_bindir}/diagtool @@ -939,11 +1313,53 @@ rm -rf $RPM_BUILD_ROOT %attr(755,root,root) %{_bindir}/hmaptool %attr(755,root,root) %{_bindir}/modularize %attr(755,root,root) %{_bindir}/pp-trace +%attr(755,root,root) %{_bindir}/run-clang-tidy %{_datadir}/clang/clang-include-fixer.py %{_datadir}/clang/clang-tidy-diff.py -%{_datadir}/clang/run-clang-tidy.py %{_datadir}/clang/run-find-all-symbols.py +%files -n bash-completion-clang +%defattr(644,root,root,755) +%{bash_compdir}/clang + +%if %{with flang} +%files -n flang +%defattr(644,root,root,755) +%doc tools/flang/{LICENSE.TXT,README.md} +%attr(755,root,root) %{_bindir}/bbc +%attr(755,root,root) %{_bindir}/f18-parse-demo +%attr(755,root,root) %{_bindir}/fir-opt +%attr(755,root,root) %{_bindir}/flang-new +%attr(755,root,root) %{_bindir}/flang-to-external-fc +%attr(755,root,root) %{_bindir}/tco +%dir %{_includedir}/flang +%{_includedir}/flang/Version.inc +%{_includedir}/flang/__fortran_*.mod +%{_includedir}/flang/ieee_*.mod +%{_includedir}/flang/iso_*.mod +%{_includedir}/flang/omp_lib*.mod + +%files -n flang-devel +%defattr(644,root,root,755) +%{_libdir}/libFIR*.a +%{_libdir}/libHLFIR*.a +%{_libdir}/libFortran*.a +%{_libdir}/libflangFrontend*.a +%{_includedir}/flang/Common +%{_includedir}/flang/Decimal +%{_includedir}/flang/Evaluate +%{_includedir}/flang/Frontend +%{_includedir}/flang/FrontendTool +%{_includedir}/flang/Lower +%{_includedir}/flang/Optimizer +%{_includedir}/flang/Parser +%{_includedir}/flang/Runtime +%{_includedir}/flang/Semantics +%{_includedir}/flang/Tools +%{_includedir}/flang/ISO_Fortran_binding.h +%{_libdir}/cmake/flang +%endif + %files -n lld %defattr(644,root,root,755) %doc tools/lld/{LICENSE.TXT,README.md} @@ -957,34 +1373,37 @@ rm -rf $RPM_BUILD_ROOT %defattr(644,root,root,755) %{_libdir}/liblld[ACDEHMRWXY]*.a %{_includedir}/lld +%{_libdir}/cmake/lld %if %{with lldb} %files -n lldb %defattr(644,root,root,755) %attr(755,root,root) %{_bindir}/lldb %attr(755,root,root) %{_bindir}/lldb-argdumper -%attr(755,root,root) %{_bindir}/lldb-mi +%attr(755,root,root) %{_bindir}/lldb-instr %attr(755,root,root) %{_bindir}/lldb-server -%attr(755,root,root) %{_bindir}/lldb-test %attr(755,root,root) %{_bindir}/lldb-vscode %attr(755,root,root) %{_libdir}/liblldb.so.%{version} -%attr(755,root,root) %ghost %{_libdir}/liblldb.so.8 -%attr(755,root,root) %ghost %{_libdir}/liblldbIntelFeatures.so.8 -%dir %{py_sitedir}/lldb -%attr(755,root,root) %{py_sitedir}/lldb/lldb-argdumper -%{py_sitedir}/lldb/formatters -%{py_sitedir}/lldb/runtime -%{py_sitedir}/lldb/utils -%{py_sitedir}/lldb/__init__.py[co] -%{py_sitedir}/lldb/embedded_interpreter.py[co] -%attr(755,root,root) %{py_sitedir}/lldb/_lldb.so -%attr(755,root,root) %{py_sitedir}/readline.so +%attr(755,root,root) %ghost %{_libdir}/liblldb.so.16 +%attr(755,root,root) %ghost %{_libdir}/liblldbIntelFeatures.so.16 +%dir %{py3_sitedir}/lldb +%attr(755,root,root) %{py3_sitedir}/lldb/lldb-argdumper +%{py3_sitedir}/lldb/formatters +%{py3_sitedir}/lldb/utils +%{py3_sitedir}/lldb/__init__.py +%{py3_sitedir}/lldb/__pycache__ +%{py3_sitedir}/lldb/embedded_interpreter.py +%dir %{py3_sitedir}/lldb/plugins +%{py3_sitedir}/lldb/plugins/__pycache__ +%{py3_sitedir}/lldb/plugins/__init__.py +%{py3_sitedir}/lldb/plugins/scripted_platform.py +%{py3_sitedir}/lldb/plugins/scripted_process.py +%attr(755,root,root) %{py3_sitedir}/lldb/_lldb.cpython-*.so %files -n lldb-devel %defattr(644,root,root,755) %attr(755,root,root) %{_libdir}/liblldb.so %attr(755,root,root) %{_libdir}/liblldbIntelFeatures.so -%{_libdir}/liblldb*.a %{_includedir}/lldb %endif @@ -1001,6 +1420,8 @@ rm -rf $RPM_BUILD_ROOT %defattr(644,root,root,755) %{_libdir}/ocaml/llvm/libllvm*.a %{_libdir}/ocaml/llvm/llvm*.a +%{_libdir}/ocaml/llvm/llvm*.cmt +%{_libdir}/ocaml/llvm/llvm*.cmti %{_libdir}/ocaml/llvm/llvm*.cmx %{_libdir}/ocaml/llvm/llvm*.cmxa %{_libdir}/ocaml/llvm/llvm*.mli diff --git a/llvm12-build_fixes.patch b/llvm12-build_fixes.patch new file mode 100644 index 0000000..804f032 --- /dev/null +++ b/llvm12-build_fixes.patch @@ -0,0 +1,481 @@ +diff -urN llvm-12.0.0.src.orig/tools/lld/MachO/mach-o/compact_unwind_encoding.h llvm-12.0.0.src/tools/lld/MachO/mach-o/compact_unwind_encoding.h +--- llvm-12.0.0.src.orig/tools/lld/MachO/mach-o/compact_unwind_encoding.h 1970-01-01 01:00:00.000000000 +0100 ++++ llvm-12.0.0.src/tools/lld/MachO/mach-o/compact_unwind_encoding.h 2021-04-16 16:24:55.701577683 +0200 +@@ -0,0 +1,477 @@ ++//===------------------ mach-o/compact_unwind_encoding.h ------------------===// ++// ++// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. ++// See https://llvm.org/LICENSE.txt for license information. ++// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception ++// ++// ++// Darwin's alternative to DWARF based unwind encodings. ++// ++//===----------------------------------------------------------------------===// ++ ++ ++#ifndef __COMPACT_UNWIND_ENCODING__ ++#define __COMPACT_UNWIND_ENCODING__ ++ ++#include ++ ++// ++// Compilers can emit standard DWARF FDEs in the __TEXT,__eh_frame section ++// of object files. Or compilers can emit compact unwind information in ++// the __LD,__compact_unwind section. ++// ++// When the linker creates a final linked image, it will create a ++// __TEXT,__unwind_info section. This section is a small and fast way for the ++// runtime to access unwind info for any given function. If the compiler ++// emitted compact unwind info for the function, that compact unwind info will ++// be encoded in the __TEXT,__unwind_info section. If the compiler emitted ++// DWARF unwind info, the __TEXT,__unwind_info section will contain the offset ++// of the FDE in the __TEXT,__eh_frame section in the final linked image. ++// ++// Note: Previously, the linker would transform some DWARF unwind infos into ++// compact unwind info. But that is fragile and no longer done. ++ ++ ++// ++// The compact unwind endoding is a 32-bit value which encoded in an ++// architecture specific way, which registers to restore from where, and how ++// to unwind out of the function. ++// ++typedef uint32_t compact_unwind_encoding_t; ++ ++ ++// architecture independent bits ++enum { ++ UNWIND_IS_NOT_FUNCTION_START = 0x80000000, ++ UNWIND_HAS_LSDA = 0x40000000, ++ UNWIND_PERSONALITY_MASK = 0x30000000, ++}; ++ ++ ++ ++ ++// ++// x86 ++// ++// 1-bit: start ++// 1-bit: has lsda ++// 2-bit: personality index ++// ++// 4-bits: 0=old, 1=ebp based, 2=stack-imm, 3=stack-ind, 4=DWARF ++// ebp based: ++// 15-bits (5*3-bits per reg) register permutation ++// 8-bits for stack offset ++// frameless: ++// 8-bits stack size ++// 3-bits stack adjust ++// 3-bits register count ++// 10-bits register permutation ++// ++enum { ++ UNWIND_X86_MODE_MASK = 0x0F000000, ++ UNWIND_X86_MODE_EBP_FRAME = 0x01000000, ++ UNWIND_X86_MODE_STACK_IMMD = 0x02000000, ++ UNWIND_X86_MODE_STACK_IND = 0x03000000, ++ UNWIND_X86_MODE_DWARF = 0x04000000, ++ ++ UNWIND_X86_EBP_FRAME_REGISTERS = 0x00007FFF, ++ UNWIND_X86_EBP_FRAME_OFFSET = 0x00FF0000, ++ ++ UNWIND_X86_FRAMELESS_STACK_SIZE = 0x00FF0000, ++ UNWIND_X86_FRAMELESS_STACK_ADJUST = 0x0000E000, ++ UNWIND_X86_FRAMELESS_STACK_REG_COUNT = 0x00001C00, ++ UNWIND_X86_FRAMELESS_STACK_REG_PERMUTATION = 0x000003FF, ++ ++ UNWIND_X86_DWARF_SECTION_OFFSET = 0x00FFFFFF, ++}; ++ ++enum { ++ UNWIND_X86_REG_NONE = 0, ++ UNWIND_X86_REG_EBX = 1, ++ UNWIND_X86_REG_ECX = 2, ++ UNWIND_X86_REG_EDX = 3, ++ UNWIND_X86_REG_EDI = 4, ++ UNWIND_X86_REG_ESI = 5, ++ UNWIND_X86_REG_EBP = 6, ++}; ++ ++// ++// For x86 there are four modes for the compact unwind encoding: ++// UNWIND_X86_MODE_EBP_FRAME: ++// EBP based frame where EBP is push on stack immediately after return address, ++// then ESP is moved to EBP. Thus, to unwind ESP is restored with the current ++// EPB value, then EBP is restored by popping off the stack, and the return ++// is done by popping the stack once more into the pc. ++// All non-volatile registers that need to be restored must have been saved ++// in a small range in the stack that starts EBP-4 to EBP-1020. The offset/4 ++// is encoded in the UNWIND_X86_EBP_FRAME_OFFSET bits. The registers saved ++// are encoded in the UNWIND_X86_EBP_FRAME_REGISTERS bits as five 3-bit entries. ++// Each entry contains which register to restore. ++// UNWIND_X86_MODE_STACK_IMMD: ++// A "frameless" (EBP not used as frame pointer) function with a small ++// constant stack size. To return, a constant (encoded in the compact ++// unwind encoding) is added to the ESP. Then the return is done by ++// popping the stack into the pc. ++// All non-volatile registers that need to be restored must have been saved ++// on the stack immediately after the return address. The stack_size/4 is ++// encoded in the UNWIND_X86_FRAMELESS_STACK_SIZE (max stack size is 1024). ++// The number of registers saved is encoded in UNWIND_X86_FRAMELESS_STACK_REG_COUNT. ++// UNWIND_X86_FRAMELESS_STACK_REG_PERMUTATION constains which registers were ++// saved and their order. ++// UNWIND_X86_MODE_STACK_IND: ++// A "frameless" (EBP not used as frame pointer) function large constant ++// stack size. This case is like the previous, except the stack size is too ++// large to encode in the compact unwind encoding. Instead it requires that ++// the function contains "subl $nnnnnnnn,ESP" in its prolog. The compact ++// encoding contains the offset to the nnnnnnnn value in the function in ++// UNWIND_X86_FRAMELESS_STACK_SIZE. ++// UNWIND_X86_MODE_DWARF: ++// No compact unwind encoding is available. Instead the low 24-bits of the ++// compact encoding is the offset of the DWARF FDE in the __eh_frame section. ++// This mode is never used in object files. It is only generated by the ++// linker in final linked images which have only DWARF unwind info for a ++// function. ++// ++// The permutation encoding is a Lehmer code sequence encoded into a ++// single variable-base number so we can encode the ordering of up to ++// six registers in a 10-bit space. ++// ++// The following is the algorithm used to create the permutation encoding used ++// with frameless stacks. It is passed the number of registers to be saved and ++// an array of the register numbers saved. ++// ++//uint32_t permute_encode(uint32_t registerCount, const uint32_t registers[6]) ++//{ ++// uint32_t renumregs[6]; ++// for (int i=6-registerCount; i < 6; ++i) { ++// int countless = 0; ++// for (int j=6-registerCount; j < i; ++j) { ++// if ( registers[j] < registers[i] ) ++// ++countless; ++// } ++// renumregs[i] = registers[i] - countless -1; ++// } ++// uint32_t permutationEncoding = 0; ++// switch ( registerCount ) { ++// case 6: ++// permutationEncoding |= (120*renumregs[0] + 24*renumregs[1] ++// + 6*renumregs[2] + 2*renumregs[3] ++// + renumregs[4]); ++// break; ++// case 5: ++// permutationEncoding |= (120*renumregs[1] + 24*renumregs[2] ++// + 6*renumregs[3] + 2*renumregs[4] ++// + renumregs[5]); ++// break; ++// case 4: ++// permutationEncoding |= (60*renumregs[2] + 12*renumregs[3] ++// + 3*renumregs[4] + renumregs[5]); ++// break; ++// case 3: ++// permutationEncoding |= (20*renumregs[3] + 4*renumregs[4] ++// + renumregs[5]); ++// break; ++// case 2: ++// permutationEncoding |= (5*renumregs[4] + renumregs[5]); ++// break; ++// case 1: ++// permutationEncoding |= (renumregs[5]); ++// break; ++// } ++// return permutationEncoding; ++//} ++// ++ ++ ++ ++ ++// ++// x86_64 ++// ++// 1-bit: start ++// 1-bit: has lsda ++// 2-bit: personality index ++// ++// 4-bits: 0=old, 1=rbp based, 2=stack-imm, 3=stack-ind, 4=DWARF ++// rbp based: ++// 15-bits (5*3-bits per reg) register permutation ++// 8-bits for stack offset ++// frameless: ++// 8-bits stack size ++// 3-bits stack adjust ++// 3-bits register count ++// 10-bits register permutation ++// ++enum { ++ UNWIND_X86_64_MODE_MASK = 0x0F000000, ++ UNWIND_X86_64_MODE_RBP_FRAME = 0x01000000, ++ UNWIND_X86_64_MODE_STACK_IMMD = 0x02000000, ++ UNWIND_X86_64_MODE_STACK_IND = 0x03000000, ++ UNWIND_X86_64_MODE_DWARF = 0x04000000, ++ ++ UNWIND_X86_64_RBP_FRAME_REGISTERS = 0x00007FFF, ++ UNWIND_X86_64_RBP_FRAME_OFFSET = 0x00FF0000, ++ ++ UNWIND_X86_64_FRAMELESS_STACK_SIZE = 0x00FF0000, ++ UNWIND_X86_64_FRAMELESS_STACK_ADJUST = 0x0000E000, ++ UNWIND_X86_64_FRAMELESS_STACK_REG_COUNT = 0x00001C00, ++ UNWIND_X86_64_FRAMELESS_STACK_REG_PERMUTATION = 0x000003FF, ++ ++ UNWIND_X86_64_DWARF_SECTION_OFFSET = 0x00FFFFFF, ++}; ++ ++enum { ++ UNWIND_X86_64_REG_NONE = 0, ++ UNWIND_X86_64_REG_RBX = 1, ++ UNWIND_X86_64_REG_R12 = 2, ++ UNWIND_X86_64_REG_R13 = 3, ++ UNWIND_X86_64_REG_R14 = 4, ++ UNWIND_X86_64_REG_R15 = 5, ++ UNWIND_X86_64_REG_RBP = 6, ++}; ++// ++// For x86_64 there are four modes for the compact unwind encoding: ++// UNWIND_X86_64_MODE_RBP_FRAME: ++// RBP based frame where RBP is push on stack immediately after return address, ++// then RSP is moved to RBP. Thus, to unwind RSP is restored with the current ++// EPB value, then RBP is restored by popping off the stack, and the return ++// is done by popping the stack once more into the pc. ++// All non-volatile registers that need to be restored must have been saved ++// in a small range in the stack that starts RBP-8 to RBP-2040. The offset/8 ++// is encoded in the UNWIND_X86_64_RBP_FRAME_OFFSET bits. The registers saved ++// are encoded in the UNWIND_X86_64_RBP_FRAME_REGISTERS bits as five 3-bit entries. ++// Each entry contains which register to restore. ++// UNWIND_X86_64_MODE_STACK_IMMD: ++// A "frameless" (RBP not used as frame pointer) function with a small ++// constant stack size. To return, a constant (encoded in the compact ++// unwind encoding) is added to the RSP. Then the return is done by ++// popping the stack into the pc. ++// All non-volatile registers that need to be restored must have been saved ++// on the stack immediately after the return address. The stack_size/8 is ++// encoded in the UNWIND_X86_64_FRAMELESS_STACK_SIZE (max stack size is 2048). ++// The number of registers saved is encoded in UNWIND_X86_64_FRAMELESS_STACK_REG_COUNT. ++// UNWIND_X86_64_FRAMELESS_STACK_REG_PERMUTATION constains which registers were ++// saved and their order. ++// UNWIND_X86_64_MODE_STACK_IND: ++// A "frameless" (RBP not used as frame pointer) function large constant ++// stack size. This case is like the previous, except the stack size is too ++// large to encode in the compact unwind encoding. Instead it requires that ++// the function contains "subq $nnnnnnnn,RSP" in its prolog. The compact ++// encoding contains the offset to the nnnnnnnn value in the function in ++// UNWIND_X86_64_FRAMELESS_STACK_SIZE. ++// UNWIND_X86_64_MODE_DWARF: ++// No compact unwind encoding is available. Instead the low 24-bits of the ++// compact encoding is the offset of the DWARF FDE in the __eh_frame section. ++// This mode is never used in object files. It is only generated by the ++// linker in final linked images which have only DWARF unwind info for a ++// function. ++// ++ ++ ++// ARM64 ++// ++// 1-bit: start ++// 1-bit: has lsda ++// 2-bit: personality index ++// ++// 4-bits: 4=frame-based, 3=DWARF, 2=frameless ++// frameless: ++// 12-bits of stack size ++// frame-based: ++// 4-bits D reg pairs saved ++// 5-bits X reg pairs saved ++// DWARF: ++// 24-bits offset of DWARF FDE in __eh_frame section ++// ++enum { ++ UNWIND_ARM64_MODE_MASK = 0x0F000000, ++ UNWIND_ARM64_MODE_FRAMELESS = 0x02000000, ++ UNWIND_ARM64_MODE_DWARF = 0x03000000, ++ UNWIND_ARM64_MODE_FRAME = 0x04000000, ++ ++ UNWIND_ARM64_FRAME_X19_X20_PAIR = 0x00000001, ++ UNWIND_ARM64_FRAME_X21_X22_PAIR = 0x00000002, ++ UNWIND_ARM64_FRAME_X23_X24_PAIR = 0x00000004, ++ UNWIND_ARM64_FRAME_X25_X26_PAIR = 0x00000008, ++ UNWIND_ARM64_FRAME_X27_X28_PAIR = 0x00000010, ++ UNWIND_ARM64_FRAME_D8_D9_PAIR = 0x00000100, ++ UNWIND_ARM64_FRAME_D10_D11_PAIR = 0x00000200, ++ UNWIND_ARM64_FRAME_D12_D13_PAIR = 0x00000400, ++ UNWIND_ARM64_FRAME_D14_D15_PAIR = 0x00000800, ++ ++ UNWIND_ARM64_FRAMELESS_STACK_SIZE_MASK = 0x00FFF000, ++ UNWIND_ARM64_DWARF_SECTION_OFFSET = 0x00FFFFFF, ++}; ++// For arm64 there are three modes for the compact unwind encoding: ++// UNWIND_ARM64_MODE_FRAME: ++// This is a standard arm64 prolog where FP/LR are immediately pushed on the ++// stack, then SP is copied to FP. If there are any non-volatile registers ++// saved, then are copied into the stack frame in pairs in a contiguous ++// range right below the saved FP/LR pair. Any subset of the five X pairs ++// and four D pairs can be saved, but the memory layout must be in register ++// number order. ++// UNWIND_ARM64_MODE_FRAMELESS: ++// A "frameless" leaf function, where FP/LR are not saved. The return address ++// remains in LR throughout the function. If any non-volatile registers ++// are saved, they must be pushed onto the stack before any stack space is ++// allocated for local variables. The stack sized (including any saved ++// non-volatile registers) divided by 16 is encoded in the bits ++// UNWIND_ARM64_FRAMELESS_STACK_SIZE_MASK. ++// UNWIND_ARM64_MODE_DWARF: ++// No compact unwind encoding is available. Instead the low 24-bits of the ++// compact encoding is the offset of the DWARF FDE in the __eh_frame section. ++// This mode is never used in object files. It is only generated by the ++// linker in final linked images which have only DWARF unwind info for a ++// function. ++// ++ ++ ++ ++ ++ ++//////////////////////////////////////////////////////////////////////////////// ++// ++// Relocatable Object Files: __LD,__compact_unwind ++// ++//////////////////////////////////////////////////////////////////////////////// ++ ++// ++// A compiler can generated compact unwind information for a function by adding ++// a "row" to the __LD,__compact_unwind section. This section has the ++// S_ATTR_DEBUG bit set, so the section will be ignored by older linkers. ++// It is removed by the new linker, so never ends up in final executables. ++// This section is a table, initially with one row per function (that needs ++// unwind info). The table columns and some conceptual entries are: ++// ++// range-start pointer to start of function/range ++// range-length ++// compact-unwind-encoding 32-bit encoding ++// personality-function or zero if no personality function ++// lsda or zero if no LSDA data ++// ++// The length and encoding fields are 32-bits. The other are all pointer sized. ++// ++// In x86_64 assembly, these entry would look like: ++// ++// .section __LD,__compact_unwind,regular,debug ++// ++// #compact unwind for _foo ++// .quad _foo ++// .set L1,LfooEnd-_foo ++// .long L1 ++// .long 0x01010001 ++// .quad 0 ++// .quad 0 ++// ++// #compact unwind for _bar ++// .quad _bar ++// .set L2,LbarEnd-_bar ++// .long L2 ++// .long 0x01020011 ++// .quad __gxx_personality ++// .quad except_tab1 ++// ++// ++// Notes: There is no need for any labels in the the __compact_unwind section. ++// The use of the .set directive is to force the evaluation of the ++// range-length at assembly time, instead of generating relocations. ++// ++// To support future compiler optimizations where which non-volatile registers ++// are saved changes within a function (e.g. delay saving non-volatiles until ++// necessary), there can by multiple lines in the __compact_unwind table for one ++// function, each with a different (non-overlapping) range and each with ++// different compact unwind encodings that correspond to the non-volatiles ++// saved at that range of the function. ++// ++// If a particular function is so wacky that there is no compact unwind way ++// to encode it, then the compiler can emit traditional DWARF unwind info. ++// The runtime will use which ever is available. ++// ++// Runtime support for compact unwind encodings are only available on 10.6 ++// and later. So, the compiler should not generate it when targeting pre-10.6. ++ ++ ++ ++ ++//////////////////////////////////////////////////////////////////////////////// ++// ++// Final Linked Images: __TEXT,__unwind_info ++// ++//////////////////////////////////////////////////////////////////////////////// ++ ++// ++// The __TEXT,__unwind_info section is laid out for an efficient two level lookup. ++// The header of the section contains a coarse index that maps function address ++// to the page (4096 byte block) containing the unwind info for that function. ++// ++ ++#define UNWIND_SECTION_VERSION 1 ++struct unwind_info_section_header ++{ ++ uint32_t version; // UNWIND_SECTION_VERSION ++ uint32_t commonEncodingsArraySectionOffset; ++ uint32_t commonEncodingsArrayCount; ++ uint32_t personalityArraySectionOffset; ++ uint32_t personalityArrayCount; ++ uint32_t indexSectionOffset; ++ uint32_t indexCount; ++ // compact_unwind_encoding_t[] ++ // uint32_t personalities[] ++ // unwind_info_section_header_index_entry[] ++ // unwind_info_section_header_lsda_index_entry[] ++}; ++ ++struct unwind_info_section_header_index_entry ++{ ++ uint32_t functionOffset; ++ uint32_t secondLevelPagesSectionOffset; // section offset to start of regular or compress page ++ uint32_t lsdaIndexArraySectionOffset; // section offset to start of lsda_index array for this range ++}; ++ ++struct unwind_info_section_header_lsda_index_entry ++{ ++ uint32_t functionOffset; ++ uint32_t lsdaOffset; ++}; ++ ++// ++// There are two kinds of second level index pages: regular and compressed. ++// A compressed page can hold up to 1021 entries, but it cannot be used ++// if too many different encoding types are used. The regular page holds ++// 511 entries. ++// ++ ++struct unwind_info_regular_second_level_entry ++{ ++ uint32_t functionOffset; ++ compact_unwind_encoding_t encoding; ++}; ++ ++#define UNWIND_SECOND_LEVEL_REGULAR 2 ++struct unwind_info_regular_second_level_page_header ++{ ++ uint32_t kind; // UNWIND_SECOND_LEVEL_REGULAR ++ uint16_t entryPageOffset; ++ uint16_t entryCount; ++ // entry array ++}; ++ ++#define UNWIND_SECOND_LEVEL_COMPRESSED 3 ++struct unwind_info_compressed_second_level_page_header ++{ ++ uint32_t kind; // UNWIND_SECOND_LEVEL_COMPRESSED ++ uint16_t entryPageOffset; ++ uint16_t entryCount; ++ uint16_t encodingsPageOffset; ++ uint16_t encodingsCount; ++ // 32-bit entry array ++ // encodings array ++}; ++ ++#define UNWIND_INFO_COMPRESSED_ENTRY_FUNC_OFFSET(entry) (entry & 0x00FFFFFF) ++#define UNWIND_INFO_COMPRESSED_ENTRY_ENCODING_INDEX(entry) ((entry >> 24) & 0xFF) ++ ++ ++ ++#endif ++ diff --git a/x32-compiler-rt.patch b/x32-compiler-rt.patch new file mode 100644 index 0000000..3940b37 --- /dev/null +++ b/x32-compiler-rt.patch @@ -0,0 +1,12 @@ +--- llvm-15.0.2.src/projects/compiler-rt/cmake/Modules/CompilerRTUtils.cmake.orig 2022-10-04 11:29:17.000000000 +0200 ++++ llvm-15.0.2.src/projects/compiler-rt/cmake/Modules/CompilerRTUtils.cmake 2022-10-16 22:33:08.014906010 +0200 +@@ -478,7 +478,8 @@ + + function(get_compiler_rt_target arch variable) + string(FIND ${COMPILER_RT_DEFAULT_TARGET_TRIPLE} "-" dash_index) +- string(SUBSTRING ${COMPILER_RT_DEFAULT_TARGET_TRIPLE} ${dash_index} -1 triple_suffix) ++ string(SUBSTRING ${COMPILER_RT_DEFAULT_TARGET_TRIPLE} ${dash_index} -1 triple_suffix_with_abi) ++ string(REPLACE "-gnux32" "" triple_suffix ${triple_suffix_with_abi}) + string(SUBSTRING ${COMPILER_RT_DEFAULT_TARGET_TRIPLE} 0 ${dash_index} triple_cpu) + if(COMPILER_RT_DEFAULT_TARGET_ONLY) + # Use exact spelling when building only for the target specified to CMake. diff --git a/x32-gcc-toolchain.patch b/x32-gcc-toolchain.patch index 701d570..b551b90 100644 --- a/x32-gcc-toolchain.patch +++ b/x32-gcc-toolchain.patch @@ -1,37 +1,31 @@ ---- llvm-5.0.0.src/tools/clang/lib/Driver/ToolChains/Gnu.cpp~ 2015-07-26 12:48:18.000000000 +0200 -+++ llvm-5.0.0.src/tools/clang/lib/Driver/ToolChains/Gnu.cpp 2015-07-26 17:44:56.883613971 +0200 -@@ -1312,6 +1312,9 @@ - "x86_64-slackware-linux", "x86_64-linux-android", - "x86_64-unknown-linux"}; - static const char *const X32LibDirs[] = {"/libx32"}; +--- llvm-13.0.0.src/tools/clang/lib/Driver/ToolChains/Gnu.cpp.orig 2021-10-25 20:48:42.045696956 +0200 ++++ llvm-13.0.0.src/tools/clang/lib/Driver/ToolChains/Gnu.cpp 2021-10-25 20:56:43.802012798 +0200 +@@ -2113,8 +2113,9 @@ + "x86_64-manbo-linux-gnu", "x86_64-linux-gnu", + "x86_64-slackware-linux", "x86_64-unknown-linux", + "x86_64-amazon-linux"}; +- static const char *const X32Triples[] = {"x86_64-linux-gnux32", +- "x86_64-pc-linux-gnux32"}; + static const char *const X32Triples[] = { + "x86_64-pld-linux-gnux32", "amd64-pld-linux-gnux32", + "x86_64-linux-gnux32", "x86_64-unknown-linux-gnux32", "x86_64-pc-linux-gnux32"}; + static const char *const X32LibDirs[] = {"/libx32", "/lib"}; static const char *const X86LibDirs[] = {"/lib32", "/lib"}; static const char *const X86Triples[] = { - "i686-pld-linux", "i586-pld-linux", "i486-pld-linux", "i386-pld-linux", "athlon-pld-linux", -@@ -1407,15 +1407,19 @@ - } - break; - case llvm::Triple::x86_64: -- LibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs)); -- TripleAliases.append(begin(X86_64Triples), end(X86_64Triples)); -- // x32 is always available when x86_64 is available, so adding it as -- // secondary arch with x86_64 triples - if (TargetTriple.getEnvironment() == llvm::Triple::GNUX32) { -- BiarchLibDirs.append(begin(X32LibDirs), end(X32LibDirs)); -+ LibDirs.append(begin(X32LibDirs), end(X32LibDirs)); -+ TripleAliases.append(begin(X32Triples), end(X32Triples)); -+ BiarchLibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs)); +@@ -2352,12 +2353,16 @@ + LibDirs.append(begin(X32LibDirs), end(X32LibDirs)); + TripleAliases.append(begin(X32Triples), end(X32Triples)); + BiarchLibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs)); + BiarchLibDirs.append(begin(X86LibDirs), end(X86LibDirs)); BiarchTripleAliases.append(begin(X86_64Triples), end(X86_64Triples)); + BiarchTripleAliases.append(begin(X86Triples), end(X86Triples)); } else { -+ LibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs)); -+ TripleAliases.append(begin(X86_64Triples), end(X86_64Triples)); -+ BiarchLibDirs.append(begin(X32LibDirs), end(X32LibDirs)); - BiarchLibDirs.append(begin(X86LibDirs), end(X86LibDirs)); -+ BiarchTripleAliases.append(begin(X32Triples), end(X32Triples)); - BiarchTripleAliases.append(begin(X86Triples), end(X86Triples)); + LibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs)); + TripleAliases.append(begin(X86_64Triples), end(X86_64Triples)); + BiarchLibDirs.append(begin(X32LibDirs), end(X32LibDirs)); ++ BiarchLibDirs.append(begin(X86LibDirs), end(X86LibDirs)); + BiarchTripleAliases.append(begin(X32Triples), end(X32Triples)); ++ BiarchTripleAliases.append(begin(X86Triples), end(X86Triples)); } - break; + BiarchLibDirs.append(begin(X86LibDirs), end(X86LibDirs)); + BiarchTripleAliases.append(begin(X86Triples), end(X86Triples)); -- 2.46.0