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