(no commit message)
[lldb-experimental.git] / lldb-experimental.spec
index b0707e6..dbabe50 100644 (file)
@@ -1,41 +1,88 @@
 %global fast 0
 %global use_jankratochvil_dwz 1
+# FIXME:
+%global use_jankratochvil_layout5 0
+%global use_jankratochvil_ocaml_doc 1
 %global use_jankratochvil_rust 0
+%global use_nealsid_lldb_editline_remove_wchar 0
 %global pkg_prefix /opt/%{name}
 %global _unpackaged_files_terminate_build 0
 # dwz: Couldn't find DIE referenced by DW_OP_GNU_parameter_ref
 %global _find_debuginfo_dwz_opts %{nil}
 # *** ERROR: ambiguous python shebang in /opt/lldb-experimental/...: #!/usr/bin/env python. Change it to python3 (or python2) explicitly.
 %global __brp_mangle_shebangs %{nil}
+%if (0%{?rhel:1} && 0%{?rhel} <= 7)
+# -gsplit-dwarf: LLVM: internal compiler error: in output_index_string, at dwarf2out.c:21891
+# https://bugzilla.redhat.com/show_bug.cgi?id=1590678
+%global fast 1
+%endif
 %if %{fast}
 %global debug_package %{nil}
 %endif
 Name: lldb-experimental
-Version: 11.0.0
-Release: 0.20200531snap0%{?dist}
+Version: 14.0.0
+Release: 0.20210922snap0%{?dist}
 Summary: Next generation high-performance debugger - experimental trunk snapshot
 License: NCSA
 URL: http://lldb.llvm.org/
 ExclusiveArch: x86_64
-BuildRequires: gcc-c++ git libedit-devel libatomic ninja-build libxml2-devel zlib-devel valgrind-devel libpfm-devel
+# Source zero not found
+# https://bugzilla.redhat.com/show_bug.cgi?id=1938320
+Source0: empty.tar
+BuildRequires: clang git libedit-devel libatomic libxml2-devel zlib-devel valgrind-devel libpfm-devel
 # https://src.fedoraproject.org/rpms/epydoc
 #BuildRequires: epydoc
+%if 0%{?rhel} > 8 || 0%{?fedora} >= 34
+BuildRequires:  ocaml-findlib ocaml-ctypes ocaml-ocamldoc
+%endif
 %if 0%{?rhel:1} && 0%{?rhel} <= 7
-BuildRequires: llvm-toolset-7-cmake devtoolset-8-gcc-c++ python-devel python2-pyyaml
+#+ /usr/lib/rpm/brp-python-bytecompile /usr/bin/python 1
+#Compiling /quad/home/jkratoch/redhat/lldb-experimental/BUILDROOT/lldb-experimental-13.0.0-0.20210206snap1.el7.x86_64/opt/lldb-experimental/lib64/python3.8/site-packages/lldb/__init__.py ...
+#  File "/opt/lldb-experimental/lib64/python3.8/site-packages/lldb/__init__.py", line 883
+#    def IsValid(self) -> "bool":
+#                      ^
+#SyntaxError: invalid syntax
+%global __python /usr/bin/python3
+BuildRequires: llvm-toolset-7.0-clang llvm-toolset-7.0-lld
 # swig on rhel7: /builddir/build/BUILD/lldb-experimental-11.0.0/lldb/bindings/./python/python-typemaps.swig:496: Error: Syntax error in input(3).
 BuildRequires: swig3
+BuildRequires: rh-git218-git-core
+BuildRequires: rh-python38-python-devel rh-python38-python-pyyaml
 # https://bugzilla.redhat.com/show_bug.cgi?id=1511892
-%global __cmake /opt/rh/llvm-toolset-7/root/usr/bin/cmake3
-%global ninjabuild ninja-build
+BuildRequires: cmake3
+%global cmake %{cmake3}
+%global cmake_build %{cmake3_build}
+%global cmake_install %{cmake3_install}
 %else
-%if !0%{?rhel:1} || 0%{?rhel} > 8
-BuildRequires: z3-devel
+BuildRequires: lld
+# FIXME: CentOS-8:
+# CMake Error at CMakeLists.txt:3 (cmake_minimum_required):
+#   CMake 3.13.4 or higher is required.  You are running version 3.11.4
+%if 0%{?rhel} != 8
+BuildRequires: cmake
+%else
+# cmake-3.17.0-1.el8:
+BuildRequires: wget expat-devel
+BuildRequires: /usr/bin/sphinx-build curl-devel emacs jsoncpp-devel openssl-devel pkgconfig(Qt5Widgets) rhash-devel
+# -- Could NOT find LibArchive: Found unsuitable version "3.3.2", but required is at least "3.3.3" (found /usr/lib64/libarchive.so)
+# CMAKE_USE_SYSTEM_LIBARCHIVE is ON but LibArchive is not found!
+#BuildRequires: libarchive-devel
+# -- Could NOT find LibUV: Found unsuitable version "", but required is at least "1.10.0" (found LibUV_LIBRARY-NOTFOUND)
+# CMAKE_USE_SYSTEM_LIBUV is ON but a libuv is not found!
+# [local]=https://kojipkgs.fedoraproject.org/repos/epel8-build/latest/$basearch/
+#BuildRequires: libuv-devel
+# CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
+# Please set them or make sure they are set and tested correctly in the CMake files:
+# BZIP2_LIBRARY
+BuildRequires: bzip2-devel
 %endif
-BuildRequires: cmake swig
+BuildRequires: swig
 BuildRequires: python3-devel python3-pygments python3-pyyaml
 # removed in F31+
 #BuildRequires: xar-devel
-%global ninjabuild ninja
+%if !0%{?rhel:1} || 0%{?rhel} > 8
+BuildRequires: z3-devel
+%endif
 %endif
 
 %description
@@ -48,10 +95,22 @@ This package is an experimental trunk snapshot.
 This package contains off-trunk DWZ support for Fedora debuginfos such as:
   unsupported DW_FORM values: 0x1f20 0x1f21
 %endif
+%if %{use_jankratochvil_layout5}
+This package contains off-trunk:
+  Support for libstdc++11 std::unique_ptr: [[no_unique_address]]
+%endif
+%if %{use_jankratochvil_ocaml_doc}
+This package contains off-trunk:
+  ocaml_doc fix
+%endif
 %if %{use_jankratochvil_rust}
 This package contains off-trunk Rust support:
   https://github.com/rust-lang-nursery/lldb
 %endif
+%if %{use_nealsid_lldb_editline_remove_wchar}
+This package contains:
+  https://github.com/nealsid/llvm-project/tree/lldb-editline-remove-wchar
+%endif
 
 %package devel
 Summary: Development header files for %{name}
@@ -65,6 +124,49 @@ The package contains header files for %{name}.
 %ldconfig_scriptlets
 
 %prep
+%if 0%{?rhel:1} && 0%{?rhel} <= 7
+# git clone --depth 10000 --single-branch --reference ../reference https://github.com/llvm/llvm-project.git .
+# fatal: git fetch-pack: expected shallow list
+. /opt/rh/rh-git218/enable
+# CMake Warning at ../lldb/cmake/modules/FindPythonInterpAndLibs.cmake:10 (find_package):
+#   By not providing "FindPython3.cmake" in CMAKE_MODULE_PATH this project has
+#   asked CMake to find a package configuration file provided by "Python3", but
+#   CMake did not find one.
+#   Could not find a package configuration file provided by "Python3" with any
+#   of the following names:
+#     Python3Config.cmake
+#     python3-config.cmake
+#   Add the installation prefix of "Python3" to CMAKE_PREFIX_PATH or set
+#   "Python3_DIR" to a directory containing one of the above files.  If
+#   "Python3" provides a separate development package or SDK, be sure it has
+#   been installed.
+# Call Stack (most recent call first):
+#   ../lldb/cmake/modules/FindPythonInterpAndLibs.cmake:71 (FindPython3)
+#   ../lldb/cmake/modules/LLDBConfig.cmake:48 (find_package)
+#   ../lldb/cmake/modules/LLDBConfig.cmake:59 (add_optional_dependency)
+#   ../lldb/CMakeLists.txt:28 (include)
+. /opt/rh/rh-python38/enable
+%endif
+%if 0%{?rhel} == 8
+cmakesrc=cmake-3.18.3-1.fc33.src.rpm
+rm -rf $cmakesrc $cmakesrc.tgz $cmakesrc.d
+wget http://ftp.fi.muni.cz/pub/linux/fedora/linux/releases/33/Everything/source/tree/Packages/c/$cmakesrc
+rpm2archive $cmakesrc
+(mkdir $cmakesrc.d
+ cd $cmakesrc.d
+ tar xzf ../$cmakesrc.tgz
+ # FIXME: Why? FIXME: No longer needed?
+ #for i in .[a-z]*;do mv $i `echo $i|sed 's/^\.//'`;done
+ sed -i -e 's/qt-gui /&--no-system-libarchive --no-system-libuv /' cmake.spec
+ rpmbuild --define "_topdir $PWD" --define "_builddir $PWD" --define "_rpmdir $PWD" --define "_sourcedir $PWD" --define "_specdir $PWD" --define "_srcrpmdir $PWD" -bc --nodeps cmake.spec
+)
+%global __cmake %(echo %{_builddir}/cmake-*.d/cmake-*/*/bin/cmake)
+%global __cmake_builddir .
+%global cmake_build \
+  %__cmake --build "%{__cmake_builddir}" %{?_smp_mflags} --verbose
+%global cmake_install \
+  DESTDIR="%{buildroot}" %__cmake --install "%{__cmake_builddir}"
+%endif
 %setup -q -c -T
 OPTS="--depth 10000"
 %if !0%{?rhel:1} || 0%{?rhel} > 7
@@ -76,7 +178,7 @@ CLONEOPTS="--single-branch"
 test -d ../$REF/ && CLONEOPTS="$CLONEOPTS --reference ../$REF"
 # 2500 = 1 month in 2019
 git clone $OPTS $CLONEOPTS https://github.com/llvm/llvm-project.git .
-%if %{use_jankratochvil_dwz} || %{use_jankratochvil_rust}
+%if 1
 git remote remove jankratochvil || :
 #git remote add jankratochvil git://git.jankratochvil.net/lldb
 git remote add jankratochvil https://github.com/jankratochvil/llvm-project.git
@@ -87,27 +189,32 @@ git config user.name jankratochvil
 %if %{use_jankratochvil_dwz}
 git merge jankratochvil/dwz
 %endif
+%if %{use_jankratochvil_layout5}
+git merge jankratochvil/layout5
+%endif
+%if %{use_jankratochvil_ocaml_doc}
+git merge jankratochvil/ocaml_doc
+%endif
 %if %{use_jankratochvil_rust}
 # '-c merge.renames=false' is F-29+.
 # '-c merge.renameLimit=0' has no effect.
 git -c merge.renameLimit=1 merge jankratochvil/rust
 %endif
+%if %{use_nealsid_lldb_editline_remove_wchar}
+git remote add nealsid https://github.com/nealsid/llvm-project.git
+git fetch nealsid
+git merge nealsid/lldb-editline-remove-wchar
+%endif
 
 %build
-mkdir build-release
-cd    build-release
-
 FLAGS="%{optflags}"
 
 # lldb/scripts/LLDBWrapPython.cpp:23699:70: error: format not a string literal and no format arguments [-Werror=format-security]
 FLAGS="$FLAGS -Wno-error=format-security"
 
 %if (0%{?rhel:1} && 0%{?rhel} <= 7)
-. /opt/rh/devtoolset-8/enable
-# -gsplit-dwarf: LLVM: internal compiler error: in output_index_string, at dwarf2out.c:21891
-# https://bugzilla.redhat.com/show_bug.cgi?id=1590678
-# Set %%{fast} only after %%debug_package above.
-%global fast 1
+. /opt/rh/llvm-toolset-7.0/enable
+. /opt/rh/rh-python38/enable
 %endif
 %if %{fast}
 FLAGS="$FLAGS -g0"
@@ -115,20 +222,38 @@ FLAGS="$FLAGS -g0"
 # -fno-reorder-blocks-and-partition:
 # -gsplit-dwarf: Error: can't resolve `.text.unlikely' - `.LVL414'
 # https://bugzilla.redhat.com/show_bug.cgi?id=1573647
-FLAGS="$FLAGS -gsplit-dwarf -fno-reorder-blocks-and-partition"
+%if 0%{?fedora} != 35
+FLAGS="$FLAGS -fdebug-types-section"
+%endif
 %endif
 
-CFLAGS="$FLAGS"
-CXXFLAGS="$FLAGS"
+# clang-12: error: unsupported argument 'auto' to option 'flto='
+# clang-12: warning: optimization flag '-ffat-lto-objects' is not supported [-Wignored-optimization-argument]
+FLAGS="$(echo $FLAGS|sed 's/ -flto=auto -ffat-lto-objects / -flto /')"
+# ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol ...; recompile with -fPIC
+FLAGS="$FLAGS -fPIC"
+%if 0%{?rhel:1} && 0%{?rhel} <= 7
+# clang: error: unknown argument: '-fstack-protector-strong'
+FLAGS="$(echo $FLAGS|sed 's/ -fstack-protector-strong / /')"
+%endif
+
+export CFLAGS="$FLAGS"
+export CXXFLAGS="$FLAGS"
+
+export LDFLAGS="%{build_ldflags}"
+LDFLAGS="$LDFLAGS -flto -Wl,--build-id=sha1"
 
 # This is default - changing it breaks the testsuite: -DLLVM_LINK_LLVM_DYLIB=OFF
 # It does not work: -DDCMAKE_EXECUTABLE_SUFFIX=-experimental
-# -fdebug-types-section && -DLLVM_USE_LINKER=gold:
-# ../../../../lib64/libclangLex.a(PreprocessingRecord.cpp.o)(.debug_types+0xfe): error: undefined reference to 'clang::SourceRange::getBegin() const'
-%cmake ../llvm \
-  -GNinja \
-  -DCMAKE_INSTALL_PREFIX=%{buildroot}%{pkg_prefix} \
-  -DBUILD_SHARED_LIBS=OFF \
+%cmake llvm \
+  -DCMAKE_INSTALL_PREFIX=%{pkg_prefix} \
+  -DCMAKE_C_COMPILER=clang \
+  -DCMAKE_CXX_COMPILER=clang++ \
+%if 0%{?rhel:1} && 0%{?rhel} <= 7
+  -DLLVM_USE_LINKER=gold \
+%else
+  -DLLVM_USE_LINKER=lld \
+%endif
 %if %{fast}
   -DCMAKE_BUILD_TYPE=Release \
 %else
@@ -137,7 +262,6 @@ CXXFLAGS="$FLAGS"
   -DLLVM_ENABLE_PROJECTS="lldb;clang;lld" \
   -DLLVM_TARGETS_TO_BUILD=X86 \
   -DLLVM_BUILD_TOOLS=OFF \
-  -DLLVM_USE_LINKER=gold \
   $(: file INSTALL cannot find build-release/lib/python3.6 ) \
 %if 0%{?__isa_bits} == 64
   -DLLVM_LIBDIR_SUFFIX=64 \
@@ -147,13 +271,14 @@ CXXFLAGS="$FLAGS"
   -DLLDB_DISABLE_CURSES=OFF \
   -DLLDB_DISABLE_LIBEDIT=OFF \
   -DLLDB_DISABLE_PYTHON=OFF \
+  -DLLVM_ENABLE_ASSERTIONS=ON \
   #
-%{ninjabuild} -v
+%cmake_build
 
 %install
 mkdir -p %{buildroot}%{pkg_prefix}
 (function revline {
-   echo "$(cd $1;git rev-parse ${2:-origin/master}) ${2:-$1}"
+   echo "$(cd $1;git rev-parse ${2:-origin/main}) ${2:-$1}"
  }
  revline .
 %if %{use_jankratochvil_dwz}
@@ -162,9 +287,8 @@ mkdir -p %{buildroot}%{pkg_prefix}
 %if %{use_jankratochvil_rust}
  revline . jankratochvil/rust
 %endif
-) >%{buildroot}%{pkg_prefix}/HEAD
-cd build-release
-%{ninjabuild} -v install
+) >%{buildroot}%{pkg_prefix}/commit
+%cmake_install
 mkdir -p %{buildroot}%{_bindir}
 # lldb-mi
 for i in lldb;do
@@ -179,11 +303,12 @@ rm -fv %{buildroot}%{_libdir}/*.a
 (cd %{buildroot}%{pkg_prefix}/%{_lib}/python*/site-packages/lldb/
  ln -vsf "$(dirname $(readlink _lldb.so))/$(readlink $(readlink _lldb.so))" _lldb.so
 )
+du -shc $PWD %{buildroot}
 
 %files
 %{_bindir}/lldb-experimental
 #{_bindir}/lldb-mi-experimental
-%{pkg_prefix}/HEAD
+%{pkg_prefix}/commit
 %{pkg_prefix}/bin/lldb
 %{pkg_prefix}/bin/lldb-server
 #{pkg_prefix}/bin/lldb-mi
@@ -191,12 +316,11 @@ rm -fv %{buildroot}%{_libdir}/*.a
 # RHEL-7: File not found by glob: .../lib{lldb,clang,LLVM}*.so.*
 %{pkg_prefix}/%{_lib}/libl*.so.*
 %{pkg_prefix}/%{_lib}/python*
+%{pkg_prefix}/%{_lib}/lib[^l]*.so.*
 
 %files devel
 %{pkg_prefix}/include
-%{pkg_prefix}/%{_lib}/lib[^l]*.so.*
 %{pkg_prefix}/%{_lib}/*.so
-%{pkg_prefix}/%{_lib}/*.a
 
 %changelog
 * Thu Apr  5 2018 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.0.0-0.1