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