(no commit message)
[lldb-experimental.git] / lldb-experimental.spec
1 %global fast 0
2 %global use_jankratochvil_dwz 1
3 %global use_jankratochvil_rust 0
4 %global pkg_prefix /opt/%{name}
5 %global _unpackaged_files_terminate_build 0
6 # dwz: Couldn't find DIE referenced by DW_OP_GNU_parameter_ref
7 %global _find_debuginfo_dwz_opts %{nil}
8 # *** ERROR: ambiguous python shebang in /opt/lldb-experimental/...: #!/usr/bin/env python. Change it to python3 (or python2) explicitly.
9 %global __brp_mangle_shebangs %{nil}
10 %if (0%{?rhel:1} && 0%{?rhel} <= 7)
11 # -gsplit-dwarf: LLVM: internal compiler error: in output_index_string, at dwarf2out.c:21891
12 # https://bugzilla.redhat.com/show_bug.cgi?id=1590678
13 %global fast 1
14 %endif
15 %if %{fast}
16 %global debug_package %{nil}
17 %endif
18 Name: lldb-experimental
19 Version: 13.0.0
20 Release: 0.20210212snap0%{?dist}
21 Summary: Next generation high-performance debugger - experimental trunk snapshot
22 License: NCSA
23 URL: http://lldb.llvm.org/
24 ExclusiveArch: x86_64
25 BuildRequires: gcc-c++ git libedit-devel libatomic libxml2-devel zlib-devel valgrind-devel libpfm-devel
26 # https://src.fedoraproject.org/rpms/epydoc
27 #BuildRequires: epydoc
28 %if 0%{?rhel:1} && 0%{?rhel} <= 7
29 #+ /usr/lib/rpm/brp-python-bytecompile /usr/bin/python 1
30 #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 ...
31 #  File "/opt/lldb-experimental/lib64/python3.8/site-packages/lldb/__init__.py", line 883
32 #    def IsValid(self) -> "bool":
33 #                      ^
34 #SyntaxError: invalid syntax
35 %global __python /usr/bin/python3
36 BuildRequires: devtoolset-8-gcc-c++
37 # swig on rhel7: /builddir/build/BUILD/lldb-experimental-11.0.0/lldb/bindings/./python/python-typemaps.swig:496: Error: Syntax error in input(3).
38 BuildRequires: swig3
39 BuildRequires: rh-git218-git-core
40 BuildRequires: rh-python38-python-devel rh-python38-python-pyyaml
41 # https://bugzilla.redhat.com/show_bug.cgi?id=1511892
42 BuildRequires: cmake3
43 %global cmake %{cmake3}
44 %global cmake_build %{cmake3_build}
45 %global cmake_install %{cmake3_install}
46 %else
47 # FIXME: CentOS-8:
48 # CMake Error at CMakeLists.txt:3 (cmake_minimum_required):
49 #   CMake 3.13.4 or higher is required.  You are running version 3.11.4
50 %if 0%{?rhel} != 8
51 BuildRequires: cmake
52 %else
53 # cmake-3.17.0-1.el8:
54 BuildRequires: wget expat-devel
55 BuildRequires: /usr/bin/sphinx-build curl-devel emacs jsoncpp-devel openssl-devel pkgconfig(Qt5Widgets) rhash-devel
56 # -- Could NOT find LibArchive: Found unsuitable version "3.3.2", but required is at least "3.3.3" (found /usr/lib64/libarchive.so)
57 # CMAKE_USE_SYSTEM_LIBARCHIVE is ON but LibArchive is not found!
58 #BuildRequires: libarchive-devel
59 # -- Could NOT find LibUV: Found unsuitable version "", but required is at least "1.10.0" (found LibUV_LIBRARY-NOTFOUND)
60 # CMAKE_USE_SYSTEM_LIBUV is ON but a libuv is not found!
61 # [local]=https://kojipkgs.fedoraproject.org/repos/epel8-build/latest/$basearch/
62 #BuildRequires: libuv-devel
63 # CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
64 # Please set them or make sure they are set and tested correctly in the CMake files:
65 # BZIP2_LIBRARY
66 BuildRequires: bzip2-devel
67 %endif
68 BuildRequires: swig
69 BuildRequires: python3-devel python3-pygments python3-pyyaml
70 # removed in F31+
71 #BuildRequires: xar-devel
72 %if !0%{?rhel:1} || 0%{?rhel} > 8
73 BuildRequires: z3-devel
74 %endif
75 %endif
76
77 %description
78 LLDB is a next generation, high-performance debugger. It is built as a set
79 of reusable components which highly leverage existing libraries in the
80 larger LLVM Project, such as the Clang expression parser and LLVM
81 disassembler.
82 This package is an experimental trunk snapshot.
83 %if %{use_jankratochvil_dwz}
84 This package contains off-trunk DWZ support for Fedora debuginfos such as:
85   unsupported DW_FORM values: 0x1f20 0x1f21
86 %endif
87 %if %{use_jankratochvil_rust}
88 This package contains off-trunk Rust support:
89   https://github.com/rust-lang-nursery/lldb
90 %endif
91
92 %package devel
93 Summary: Development header files for %{name}
94 Requires: %{name}%{?_isa} = %{version}-%{release}
95
96 %description devel
97 The package contains header files for %{name}.
98
99 {-L,"-Wl,-rpath,"}%{pkg_prefix}/%{_lib} -I%{pkg_prefix}/include -llldb -lLLVMSupport -ltinfo -pthread
100
101 %ldconfig_scriptlets
102
103 %prep
104 %if 0%{?rhel:1} && 0%{?rhel} <= 7
105 # git clone --depth 10000 --single-branch --reference ../reference https://github.com/llvm/llvm-project.git .
106 # fatal: git fetch-pack: expected shallow list
107 . /opt/rh/rh-git218/enable
108 # CMake Warning at ../lldb/cmake/modules/FindPythonInterpAndLibs.cmake:10 (find_package):
109 #   By not providing "FindPython3.cmake" in CMAKE_MODULE_PATH this project has
110 #   asked CMake to find a package configuration file provided by "Python3", but
111 #   CMake did not find one.
112 #   Could not find a package configuration file provided by "Python3" with any
113 #   of the following names:
114 #     Python3Config.cmake
115 #     python3-config.cmake
116 #   Add the installation prefix of "Python3" to CMAKE_PREFIX_PATH or set
117 #   "Python3_DIR" to a directory containing one of the above files.  If
118 #   "Python3" provides a separate development package or SDK, be sure it has
119 #   been installed.
120 # Call Stack (most recent call first):
121 #   ../lldb/cmake/modules/FindPythonInterpAndLibs.cmake:71 (FindPython3)
122 #   ../lldb/cmake/modules/LLDBConfig.cmake:48 (find_package)
123 #   ../lldb/cmake/modules/LLDBConfig.cmake:59 (add_optional_dependency)
124 #   ../lldb/CMakeLists.txt:28 (include)
125 . /opt/rh/rh-python38/enable
126 %endif
127 %if 0%{?rhel} == 8
128 cmakesrc=cmake-3.18.3-1.fc33.src.rpm
129 rm -rf $cmakesrc $cmakesrc.tgz $cmakesrc.d
130 wget http://ftp.fi.muni.cz/pub/linux/fedora/linux/releases/33/Everything/source/tree/Packages/c/$cmakesrc
131 rpm2archive $cmakesrc
132 (mkdir $cmakesrc.d
133  cd $cmakesrc.d
134  tar xzf ../$cmakesrc.tgz
135  # FIXME: Why? FIXME: No longer needed?
136  #for i in .[a-z]*;do mv $i `echo $i|sed 's/^\.//'`;done
137  sed -i -e 's/qt-gui /&--no-system-libarchive --no-system-libuv /' cmake.spec
138  rpmbuild --define "_topdir $PWD" --define "_builddir $PWD" --define "_rpmdir $PWD" --define "_sourcedir $PWD" --define "_specdir $PWD" --define "_srcrpmdir $PWD" -bc --nodeps cmake.spec
139 )
140 %global __cmake %(echo %{_builddir}/cmake-*.d/cmake-*/*/bin/cmake)
141 %global __cmake_builddir .
142 %global cmake_build \
143   %__cmake --build "%{__cmake_builddir}" %{?_smp_mflags} --verbose
144 %global cmake_install \
145   DESTDIR="%{buildroot}" %__cmake --install "%{__cmake_builddir}"
146 %endif
147 %setup -q -c -T
148 OPTS="--depth 10000"
149 %if !0%{?rhel:1} || 0%{?rhel} > 7
150   OPTS="$OPTS --no-tags"
151 %endif
152 REF="reference"
153 # RHEL-7 does not support: --reference-if-able
154 CLONEOPTS="--single-branch"
155 test -d ../$REF/ && CLONEOPTS="$CLONEOPTS --reference ../$REF"
156 # 2500 = 1 month in 2019
157 git clone $OPTS $CLONEOPTS https://github.com/llvm/llvm-project.git .
158 %if %{use_jankratochvil_dwz} || %{use_jankratochvil_rust}
159 git remote remove jankratochvil || :
160 #git remote add jankratochvil git://git.jankratochvil.net/lldb
161 git remote add jankratochvil https://github.com/jankratochvil/llvm-project.git
162 git fetch $OPTS jankratochvil
163 git config user.email jankratochvil@copr.fedorainfracloud.org
164 git config user.name jankratochvil
165 %endif
166 %if %{use_jankratochvil_dwz}
167 git merge jankratochvil/dwz
168 %endif
169 %if %{use_jankratochvil_rust}
170 # '-c merge.renames=false' is F-29+.
171 # '-c merge.renameLimit=0' has no effect.
172 git -c merge.renameLimit=1 merge jankratochvil/rust
173 %endif
174
175 %build
176 FLAGS="%{optflags}"
177
178 # lldb/scripts/LLDBWrapPython.cpp:23699:70: error: format not a string literal and no format arguments [-Werror=format-security]
179 FLAGS="$FLAGS -Wno-error=format-security"
180
181 %if (0%{?rhel:1} && 0%{?rhel} <= 7)
182 . /opt/rh/devtoolset-8/enable
183 . /opt/rh/rh-python38/enable
184 %endif
185 %if %{fast}
186 FLAGS="$FLAGS -g0"
187 %else
188 # -fno-reorder-blocks-and-partition:
189 # -gsplit-dwarf: Error: can't resolve `.text.unlikely' - `.LVL414'
190 # https://bugzilla.redhat.com/show_bug.cgi?id=1573647
191 FLAGS="$FLAGS -fdebug-types-section"
192 %endif
193
194 CFLAGS="$FLAGS"
195 CXXFLAGS="$FLAGS"
196
197 # This is default - changing it breaks the testsuite: -DLLVM_LINK_LLVM_DYLIB=OFF
198 # It does not work: -DDCMAKE_EXECUTABLE_SUFFIX=-experimental
199 # -fdebug-types-section && -DLLVM_USE_LINKER=gold:
200 # ../../../../lib64/libclangLex.a(PreprocessingRecord.cpp.o)(.debug_types+0xfe): error: undefined reference to 'clang::SourceRange::getBegin() const'
201 %cmake llvm \
202   -DCMAKE_INSTALL_PREFIX=%{pkg_prefix} \
203 %if %{fast}
204   -DCMAKE_BUILD_TYPE=Release \
205 %else
206   -DCMAKE_BUILD_TYPE=RelWithDebInfo \
207 %endif
208   -DLLVM_ENABLE_PROJECTS="lldb;clang;lld" \
209   -DLLVM_TARGETS_TO_BUILD=X86 \
210   -DLLVM_BUILD_TOOLS=OFF \
211   -DLLVM_USE_LINKER=gold \
212   $(: file INSTALL cannot find build-release/lib/python3.6 ) \
213 %if 0%{?__isa_bits} == 64
214   -DLLVM_LIBDIR_SUFFIX=64 \
215 %else
216   -DLLVM_LIBDIR_SUFFIX= \
217 %endif
218   -DLLDB_DISABLE_CURSES=OFF \
219   -DLLDB_DISABLE_LIBEDIT=OFF \
220   -DLLDB_DISABLE_PYTHON=OFF \
221   #
222 %cmake_build
223
224 %install
225 mkdir -p %{buildroot}%{pkg_prefix}
226 (function revline {
227    echo "$(cd $1;git rev-parse ${2:-origin/master}) ${2:-$1}"
228  }
229  revline .
230 %if %{use_jankratochvil_dwz}
231  revline . jankratochvil/dwz
232 %endif
233 %if %{use_jankratochvil_rust}
234  revline . jankratochvil/rust
235 %endif
236 ) >%{buildroot}%{pkg_prefix}/HEAD
237 %cmake_install
238 mkdir -p %{buildroot}%{_bindir}
239 # lldb-mi
240 for i in lldb;do
241   echo >%{buildroot}%{_bindir}/${i}-experimental -e '#! /bin/bash\nexec %{pkg_prefix}/bin/'$i' "$@"'
242   chmod +x %{buildroot}%{_bindir}/${i}-experimental
243 done
244
245 # remove static libraries
246 rm -fv %{buildroot}%{_libdir}/*.a
247
248 ### python: fix liblldb.so -> liblldb.so.7 symlink target
249 (cd %{buildroot}%{pkg_prefix}/%{_lib}/python*/site-packages/lldb/
250  ln -vsf "$(dirname $(readlink _lldb.so))/$(readlink $(readlink _lldb.so))" _lldb.so
251 )
252 du -shc $PWD %{buildroot}
253
254 %files
255 %{_bindir}/lldb-experimental
256 #{_bindir}/lldb-mi-experimental
257 %{pkg_prefix}/HEAD
258 %{pkg_prefix}/bin/lldb
259 %{pkg_prefix}/bin/lldb-server
260 #{pkg_prefix}/bin/lldb-mi
261 %{pkg_prefix}/bin/lldb-argdumper
262 # RHEL-7: File not found by glob: .../lib{lldb,clang,LLVM}*.so.*
263 %{pkg_prefix}/%{_lib}/libl*.so.*
264 %{pkg_prefix}/%{_lib}/python*
265 %{pkg_prefix}/%{_lib}/lib[^l]*.so.*
266
267 %files devel
268 %{pkg_prefix}/include
269 %{pkg_prefix}/%{_lib}/*.so
270
271 %changelog
272 * Thu Apr  5 2018 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.0.0-0.1
273 - Initial import for COPR, based on Fedora package 'lldb'.