[packages/llvm] up to 12.0.0
atler
atler at pld-linux.org
Fri Apr 16 17:40:53 CEST 2021
commit 40bef2a399cc254f8930679d7e7ece824547d958
Author: Jan Palus <atler at pld-linux.org>
Date: Fri Apr 16 17:23:15 2021 +0200
up to 12.0.0
- patch with fixes for https://bugs.llvm.org/show_bug.cgi?id=49990
- rust not ready yet
llvm-pld.patch | 4 +-
llvm-python-modules.patch | 59 +-----
llvm.spec | 98 +++++----
llvm12-build_fixes.patch | 511 ++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 572 insertions(+), 100 deletions(-)
---
diff --git a/llvm.spec b/llvm.spec
index 6b5c82f..67f918e 100644
--- a/llvm.spec
+++ b/llvm.spec
@@ -42,36 +42,37 @@
Summary: The Low Level Virtual Machine (An Optimizing Compiler Infrastructure)
Summary(pl.UTF-8): Niskopoziomowa maszyna wirtualna (infrastruktura kompilatora optymalizującego)
Name: llvm
-Version: 11.0.1
-Release: 3
+Version: 12.0.0
+Release: 1
License: University of Illinois/NCSA Open Source License
Group: Development/Languages
#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: 6ec7ae9fd43da9b87cda15b3ab9cc7af
+# Source0-md5: ceab21c9081e122a88d82216a80d0dc0
Source1: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/clang-%{version}.src.tar.xz
-# Source1-md5: b4cb0b74b1f3292a89c9720f3e1e2934
+# Source1-md5: 877200cc072ece1a52c27677ab26e3ee
Source2: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/compiler-rt-%{version}.src.tar.xz
-# Source2-md5: 29d6186e048936008512b8bbdb3a1b71
+# Source2-md5: 313e9b1caf33195cbece3ba3174115a1
Source3: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/lldb-%{version}.src.tar.xz
-# Source3-md5: e49cde09adb5ed43a651e6d5bcb2aded
+# Source3-md5: 6e1b19f825fe8535aeb740b44d815c81
Source4: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/polly-%{version}.src.tar.xz
-# Source4-md5: f9cc25cb4e52f1176225ef28d3b4d8ab
+# Source4-md5: c9b362f89ed8f2d6f9563648ecb7af66
Source5: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/clang-tools-extra-%{version}.src.tar.xz
-# Source5-md5: 1e577a85948a0f07483b7c405e59a0ca
+# Source5-md5: 640967530560f7ff96e487b6d64aa6e4
Source6: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/lld-%{version}.src.tar.xz
-# Source6-md5: 652c93bd3f78fcb9a02d8d3027f7dae2
+# Source6-md5: 7368ec545a26d67dbc487706970827c1
Source7: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/flang-%{version}.src.tar.xz
-# Source7-md5: 3d37b40aa1618d8337e9b010d3e24f2d
-# "mlir" subdir extracted from https://github.com/llvm/llvm-project/releases/download/llvmorg-11.0.1/llvm-project-11.0.1.src.tar.xz
+# Source7-md5: 28e7993b76258a04b3eabdcd2f4eae45
+# "mlir" subdir extracted from https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.0/llvm-project-12.0.0.src.tar.xz
Source8: mlir-%{version}.tar.xz
-# Source8-md5: 97736d1209b01ac52b0dd3c0916f8198
+# Source8-md5: 6ec5402ada1f8b60cb8e8c023a267901
Patch1: %{name}-pld.patch
Patch2: %{name}-python-modules.patch
Patch3: x32-gcc-toolchain.patch
Patch4: cmake-buildtype.patch
Patch5: %{name}-ocaml-shared.patch
Patch6: %{name}-flang.patch
+Patch7: llvm12-build_fixes.patch
URL: http://llvm.org/
BuildRequires: bash
BuildRequires: binutils-devel
@@ -94,9 +95,9 @@ BuildRequires: ocaml-ocamldoc
%endif
BuildRequires: perl-base >= 1:5.6
BuildRequires: perl-tools-pod
-BuildRequires: python >= 1:2.7
-BuildRequires: python-PyYAML
-BuildRequires: python-pygments >= 2.0
+BuildRequires: python3
+BuildRequires: python3-PyYAML
+BuildRequires: python3-pygments >= 2.0
BuildRequires: rpm-pythonprov
BuildRequires: rpmbuild(macros) >= 1.734
%{?with_doc:BuildRequires: sphinx-pdg}
@@ -134,7 +135,7 @@ BuildRequires: libatomic-devel
BuildRequires: libxml2-devel >= 2
BuildRequires: lua-devel
BuildRequires: ncurses-ext-devel
-BuildRequires: python-devel >= 1:2.7
+BuildRequires: python3-devel
%{?with_doc:BuildRequires: python3-recommonmark}
BuildRequires: swig-python >= 3.0.11
BuildRequires: xz-devel
@@ -154,7 +155,7 @@ Requires: %{name}-libs = %{version}-%{release}
ExcludeArch: ppc64
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
-%define abi 11
+%define abi 12
%define _sysconfdir /etc/%{name}
%define specflags_ppc -fno-var-tracking-assignments
@@ -358,7 +359,7 @@ Group: Development/Languages
Requires: clang = %{version}-%{release}
# not picked up automatically since files are currently not instaled
# in standard Python hierarchies yet
-Requires: python
+Requires: python3
%description -n clang-analyzer
The Clang Static Analyzer consists of both a source code analysis
@@ -456,7 +457,7 @@ Summary(pl.UTF-8): Wydajny debugger nowej generacji
Group: Development/Debuggers
URL: http://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
@@ -574,14 +575,15 @@ Integracja narzędzi Clang do formatowania i zmiany nazw z Vimem.
%if %{with flang}
%patch6 -p1
%endif
+%patch7 -p1
grep -rl /usr/bin/env projects tools utils | xargs sed -i -e '1{
- s,^#!.*bin/env python,#!%{__python},
+ s,^#!.*bin/env python,#!%{__python3},
s,^#!.*bin/env perl,#!%{__perl},
}'
find -name '*.py' -print0 | xargs -0 sed -i -e '1{
- s,^#!.*bin/python.*,#!%{__python},
+ s,^#!.*bin/python.*,#!%{__python3},
}'
%build
@@ -647,10 +649,10 @@ export LDFLAGS="%{rpmldflags} -Wl,--reduce-memory-overheads"
%{__make} -C tools/clang/docs docs-clang-man
%{__make} -C tools/lld/docs docs-lld-html
# workaround failed import of _lldb
-cp -pnL %{_lib}/python%{py_ver}/site-packages/lldb/_lldb.so tools/lldb/docs/lldb
+cp -pnL %{_lib}/python%{py3_ver}/site-packages/lldb/_lldb.so tools/lldb/docs/lldb
%{__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
@@ -661,17 +663,16 @@ 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}
+%py3_comp $RPM_BUILD_ROOT%{py3_sitedir}
+%py3_ocomp $RPM_BUILD_ROOT%{py3_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%{_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}
@@ -679,7 +680,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.1
# make links
echo '.so llvm-ar.1' > $RPM_BUILD_ROOT%{_mandir}/man1/llvm-ranlib.1
%endif
@@ -707,7 +708,7 @@ done
# not this OS
%{__rm} $RPM_BUILD_ROOT%{_datadir}/clang/clang-format-bbedit.applescript
# use system six
-%{__rm} $RPM_BUILD_ROOT%{py_sitedir}/six.py*
+%{__rm} $RPM_BUILD_ROOT%{py3_sitedir}/{,__pycache__/}six*.py*
# it seems it is used internally by an extra clang tool
%{__rm} $RPM_BUILD_ROOT%{_libdir}/libfindAllSymbols.a
@@ -737,6 +738,7 @@ rm -rf $RPM_BUILD_ROOT
%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-cat
%attr(755,root,root) %{_bindir}/llvm-cfi-verify
%attr(755,root,root) %{_bindir}/llvm-cov
@@ -757,6 +759,7 @@ rm -rf $RPM_BUILD_ROOT
%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
@@ -772,6 +775,7 @@ rm -rf $RPM_BUILD_ROOT
%attr(755,root,root) %{_bindir}/llvm-opt-report
%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
@@ -787,12 +791,11 @@ rm -rf $RPM_BUILD_ROOT
%attr(755,root,root) %{_bindir}/llvm-tblgen
%attr(755,root,root) %{_bindir}/llvm-undname
%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}/split-file
%attr(755,root,root) %{_bindir}/verify-uselistorder
-%attr(755,root,root) %{_bindir}/yaml2obj
%if %{with doc}
%{_mandir}/man1/bugpoint.1*
%{_mandir}/man1/dsymutil.1*
@@ -811,7 +814,9 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man1/llvm-dwarfdump.1*
%{_mandir}/man1/llvm-exegesis.1*
%{_mandir}/man1/llvm-extract.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*
@@ -821,6 +826,7 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man1/llvm-objdump.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*
@@ -830,7 +836,7 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man1/llvm-strip.1*
%{_mandir}/man1/llvm-symbolizer.1*
%{_mandir}/man1/opt.1*
-%{_mandir}/man1/tblgen.1*
+%{_mandir}/man1/xxx-tblgen.1*
%endif
%files libs
@@ -838,10 +844,10 @@ rm -rf $RPM_BUILD_ROOT
%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.11
+%attr(755,root,root) %ghost %{_libdir}/libLTO.so.12
%attr(755,root,root) %{_libdir}/LLVMgold.so
-%attr(755,root,root) %{_libdir}/libRemarks.so.11
-%attr(755,root,root) %{_libdir}/libclang-cpp.so.11
+%attr(755,root,root) %{_libdir}/libRemarks.so.12
+%attr(755,root,root) %{_libdir}/libclang-cpp.so.12
%files devel
%defattr(644,root,root,755)
@@ -1039,6 +1045,7 @@ rm -rf $RPM_BUILD_ROOT
%doc tools/lld/{LICENSE.TXT,README.md}
%attr(755,root,root) %{_bindir}/ld.lld
%attr(755,root,root) %{_bindir}/ld64.lld
+%attr(755,root,root) %{_bindir}/ld64.lld.darwinnew
%attr(755,root,root) %{_bindir}/lld
%attr(755,root,root) %{_bindir}/lld-link
%attr(755,root,root) %{_bindir}/wasm-ld
@@ -1058,15 +1065,16 @@ rm -rf $RPM_BUILD_ROOT
%attr(755,root,root) %{_bindir}/lldb-server
%attr(755,root,root) %{_bindir}/lldb-vscode
%attr(755,root,root) %{_libdir}/liblldb.so.%{version}
-%attr(755,root,root) %ghost %{_libdir}/liblldb.so.11
-%attr(755,root,root) %ghost %{_libdir}/liblldbIntelFeatures.so.11
-%dir %{py_sitedir}/lldb
-%attr(755,root,root) %{py_sitedir}/lldb/lldb-argdumper
-%{py_sitedir}/lldb/formatters
-%{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) %ghost %{_libdir}/liblldb.so.12
+%attr(755,root,root) %ghost %{_libdir}/liblldbIntelFeatures.so.12
+%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
+%attr(755,root,root) %{py3_sitedir}/lldb/_lldb.so
%files -n lldb-devel
%defattr(644,root,root,755)
diff --git a/llvm-pld.patch b/llvm-pld.patch
index 632c040..0676a36 100644
--- a/llvm-pld.patch
+++ b/llvm-pld.patch
@@ -10,8 +10,8 @@ diff -urNp -x '*.orig' llvm-11.0.1.src.org/tools/clang/include/clang/Driver/Dist
DebianSqueeze,
DebianWheezy,
@@ -132,6 +133,10 @@ public:
- return DistroVal == Gentoo;
- }
+
+ bool IsGentoo() const { return DistroVal == Gentoo; }
+ bool IsPLD() {
+ return DistroVal == PLDLinux;
diff --git a/llvm-python-modules.patch b/llvm-python-modules.patch
index fa8d826..f0d3b53 100644
--- a/llvm-python-modules.patch
+++ b/llvm-python-modules.patch
@@ -1,67 +1,20 @@
--- llvm-11.0.0.src/CMakeLists.txt.orig 2020-10-07 12:10:48.000000000 +0200
+++ llvm-11.0.0.src/CMakeLists.txt 2020-10-13 01:18:33.807817497 +0200
-@@ -646,6 +646,23 @@
+@@ -646,6 +646,8 @@
set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR OFF CACHE BOOL
"Enable per-target runtimes directory")
-+include(FindPythonInterp)
-+if( NOT PYTHONINTERP_FOUND )
-+ message(FATAL_ERROR
-+"Unable to find Python interpreter, required for builds and testing.
-+
-+Please install Python or specify the PYTHON_EXECUTABLE CMake variable.")
-+endif()
-+
-+if( ${PYTHON_VERSION_STRING} VERSION_LESS 2.7 )
-+ message(FATAL_ERROR "Python 2.7 or newer is required")
-+endif()
-+
-+add_executable(Python3::Interpreter IMPORTED)
-+set_target_properties(Python3::Interpreter PROPERTIES
-+ IMPORTED_LOCATION ${PYTHON_EXECUTABLE})
-+set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
++find_package(Python3 REQUIRED COMPONENTS Interpreter)
+
set(LLVM_PROFDATA_FILE "" CACHE FILEPATH
"Profiling data file to use when compiling in order to improve runtime performance.")
-@@ -679,40 +691,6 @@
+@@ -679,8 +691,6 @@
include(HandleLLVMOptions)
--if(CMAKE_VERSION VERSION_LESS 3.12)
-- include(FindPythonInterp)
-- if( NOT PYTHONINTERP_FOUND )
-- message(FATAL_ERROR
-- "Unable to find Python interpreter, required for builds and testing.
--
-- Please install Python or specify the PYTHON_EXECUTABLE CMake variable.")
-- endif()
--
-- if( ${PYTHON_VERSION_STRING} VERSION_LESS 2.7 )
-- message(FATAL_ERROR "Python 2.7 or newer is required")
-- endif()
--
-- add_executable(Python3::Interpreter IMPORTED)
-- set_target_properties(Python3::Interpreter PROPERTIES
-- IMPORTED_LOCATION ${PYTHON_EXECUTABLE})
-- set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
--else()
-- find_package(Python3 COMPONENTS Interpreter)
-- if(NOT Python3_Interpreter_FOUND)
-- message(WARNING "Python3 not found, using python2 as a fallback")
-- find_package(Python2 COMPONENTS Interpreter REQUIRED)
-- if(Python2_VERSION VERSION_LESS 2.7)
-- message(SEND_ERROR "Python 2.7 or newer is required")
-- endif()
--
-- # Treat python2 as python3
-- add_executable(Python3::Interpreter IMPORTED)
-- set_target_properties(Python3::Interpreter PROPERTIES
-- IMPORTED_LOCATION ${Python2_EXECUTABLE})
-- set(Python3_EXECUTABLE ${Python2_EXECUTABLE})
-- endif()
--endif()
+-find_package(Python3 REQUIRED COMPONENTS Interpreter)
-
######
- # LLVMBuild Integration
- #
+
+ # Configure all of the various header file fragments LLVM uses which depend on
diff --git a/llvm12-build_fixes.patch b/llvm12-build_fixes.patch
new file mode 100644
index 0000000..8205961
--- /dev/null
+++ b/llvm12-build_fixes.patch
@@ -0,0 +1,511 @@
+From f51ab1871655a9a96134c2636c37dcb5a6b01ac3 Mon Sep 17 00:00:00 2001
+From: serge-sans-paille <sguelton at redhat.com>
+Date: Mon, 22 Mar 2021 10:05:25 +0100
+Subject: [PATCH] Make clangd CompletionModel usable even with non-standard
+ (but supported) layout
+
+llvm supports specifying a non-standard layout where each project lies in its
+own place. Do not assume a fixed layout and use the appropriate cmake variable
+instead.
+
+Differential Revision: https://reviews.llvm.org/D96787
+---
+ clang-tools-extra/clangd/quality/CompletionModel.cmake | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/clang-tools-extra/clangd/quality/CompletionModel.cmake b/clang-tools-extra/clangd/quality/CompletionModel.cmake
+index 60c6d2aa84330..41bc2ed1890b0 100644
+--- a/tools/clang/tools/extra/clangd/quality/CompletionModel.cmake
++++ b/tools/clang/tools/extra/clangd/quality/CompletionModel.cmake
+@@ -5,8 +5,8 @@
+ # will define a C++ class called ${cpp_class} - which may be a
+ # namespace-qualified class name.
+ function(gen_decision_forest model filename cpp_class)
+- set(model_compiler ${CMAKE_SOURCE_DIR}/../clang-tools-extra/clangd/quality/CompletionModelCodegen.py)
+-
++ set(model_compiler ${LLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR}/clangd/quality/CompletionModelCodegen.py)
++
+ set(output_dir ${CMAKE_CURRENT_BINARY_DIR})
+ set(header_file ${output_dir}/${filename}.h)
+ set(cpp_file ${output_dir}/${filename}.cpp)
+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 <stdint.h>
++
++//
++// 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
++
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/llvm.git/commitdiff/40bef2a399cc254f8930679d7e7ece824547d958
More information about the pld-cvs-commit
mailing list