(no commit message)
[lldb-experimental.git] / lldb-experimental.spec
1 %global fast 0
2 %global use_jankratochvil_dwz 1
3 %global use_jankratochvil_layout5 1
4 %global use_jankratochvil_ocaml_doc 1
5 %global use_jankratochvil_rnglist 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.20210810snap2%{?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_rnglist}
107 This package contains off-trunk DWARF-5 .debug_rnglists fix.
108 %endif
109 %if %{use_jankratochvil_rust}
110 This package contains off-trunk Rust support:
111   https://github.com/rust-lang-nursery/lldb
112 %endif
113 %if %{use_nealsid_lldb_editline_remove_wchar}
114 This package contains:
115   https://github.com/nealsid/llvm-project/tree/lldb-editline-remove-wchar
116 %endif
117
118 %package devel
119 Summary: Development header files for %{name}
120 Requires: %{name}%{?_isa} = %{version}-%{release}
121
122 %description devel
123 The package contains header files for %{name}.
124
125 {-L,"-Wl,-rpath,"}%{pkg_prefix}/%{_lib} -I%{pkg_prefix}/include -llldb -lLLVMSupport -ltinfo -pthread
126
127 %ldconfig_scriptlets
128
129 %prep
130 %if 0%{?rhel:1} && 0%{?rhel} <= 7
131 # git clone --depth 10000 --single-branch --reference ../reference https://github.com/llvm/llvm-project.git .
132 # fatal: git fetch-pack: expected shallow list
133 . /opt/rh/rh-git218/enable
134 # CMake Warning at ../lldb/cmake/modules/FindPythonInterpAndLibs.cmake:10 (find_package):
135 #   By not providing "FindPython3.cmake" in CMAKE_MODULE_PATH this project has
136 #   asked CMake to find a package configuration file provided by "Python3", but
137 #   CMake did not find one.
138 #   Could not find a package configuration file provided by "Python3" with any
139 #   of the following names:
140 #     Python3Config.cmake
141 #     python3-config.cmake
142 #   Add the installation prefix of "Python3" to CMAKE_PREFIX_PATH or set
143 #   "Python3_DIR" to a directory containing one of the above files.  If
144 #   "Python3" provides a separate development package or SDK, be sure it has
145 #   been installed.
146 # Call Stack (most recent call first):
147 #   ../lldb/cmake/modules/FindPythonInterpAndLibs.cmake:71 (FindPython3)
148 #   ../lldb/cmake/modules/LLDBConfig.cmake:48 (find_package)
149 #   ../lldb/cmake/modules/LLDBConfig.cmake:59 (add_optional_dependency)
150 #   ../lldb/CMakeLists.txt:28 (include)
151 . /opt/rh/rh-python38/enable
152 %endif
153 %if 0%{?rhel} == 8
154 cmakesrc=cmake-3.18.3-1.fc33.src.rpm
155 rm -rf $cmakesrc $cmakesrc.tgz $cmakesrc.d
156 wget http://ftp.fi.muni.cz/pub/linux/fedora/linux/releases/33/Everything/source/tree/Packages/c/$cmakesrc
157 rpm2archive $cmakesrc
158 (mkdir $cmakesrc.d
159  cd $cmakesrc.d
160  tar xzf ../$cmakesrc.tgz
161  # FIXME: Why? FIXME: No longer needed?
162  #for i in .[a-z]*;do mv $i `echo $i|sed 's/^\.//'`;done
163  sed -i -e 's/qt-gui /&--no-system-libarchive --no-system-libuv /' cmake.spec
164  rpmbuild --define "_topdir $PWD" --define "_builddir $PWD" --define "_rpmdir $PWD" --define "_sourcedir $PWD" --define "_specdir $PWD" --define "_srcrpmdir $PWD" -bc --nodeps cmake.spec
165 )
166 %global __cmake %(echo %{_builddir}/cmake-*.d/cmake-*/*/bin/cmake)
167 %global __cmake_builddir .
168 %global cmake_build \
169   %__cmake --build "%{__cmake_builddir}" %{?_smp_mflags} --verbose
170 %global cmake_install \
171   DESTDIR="%{buildroot}" %__cmake --install "%{__cmake_builddir}"
172 %endif
173 %setup -q -c -T
174 OPTS="--depth 10000"
175 %if !0%{?rhel:1} || 0%{?rhel} > 7
176   OPTS="$OPTS --no-tags"
177 %endif
178 REF="reference"
179 # RHEL-7 does not support: --reference-if-able
180 CLONEOPTS="--single-branch"
181 test -d ../$REF/ && CLONEOPTS="$CLONEOPTS --reference ../$REF"
182 # 2500 = 1 month in 2019
183 git clone $OPTS $CLONEOPTS https://github.com/llvm/llvm-project.git .
184 %if 1
185 git remote remove jankratochvil || :
186 #git remote add jankratochvil git://git.jankratochvil.net/lldb
187 git remote add jankratochvil https://github.com/jankratochvil/llvm-project.git
188 git fetch $OPTS jankratochvil
189 git config user.email jankratochvil@copr.fedorainfracloud.org
190 git config user.name jankratochvil
191 %endif
192 %if %{use_jankratochvil_dwz}
193 git merge jankratochvil/dwz
194 %endif
195 %if %{use_jankratochvil_layout5}
196 git merge jankratochvil/layout5
197 %endif
198 %if %{use_jankratochvil_ocaml_doc}
199 git merge jankratochvil/ocaml_doc
200 %endif
201 %if %{use_jankratochvil_rnglist}
202 git merge jankratochvil/rnglist
203 %endif
204 %if %{use_jankratochvil_rust}
205 # '-c merge.renames=false' is F-29+.
206 # '-c merge.renameLimit=0' has no effect.
207 git -c merge.renameLimit=1 merge jankratochvil/rust
208 %endif
209 %if %{use_nealsid_lldb_editline_remove_wchar}
210 git remote add nealsid https://github.com/nealsid/llvm-project.git
211 git fetch nealsid
212 git merge nealsid/lldb-editline-remove-wchar
213 %endif
214
215 %build
216 FLAGS="%{optflags}"
217
218 # lldb/scripts/LLDBWrapPython.cpp:23699:70: error: format not a string literal and no format arguments [-Werror=format-security]
219 FLAGS="$FLAGS -Wno-error=format-security"
220
221 %if (0%{?rhel:1} && 0%{?rhel} <= 7)
222 . /opt/rh/llvm-toolset-7.0/enable
223 . /opt/rh/rh-python38/enable
224 %endif
225 %if %{fast}
226 FLAGS="$FLAGS -g0"
227 %else
228 # -fno-reorder-blocks-and-partition:
229 # -gsplit-dwarf: Error: can't resolve `.text.unlikely' - `.LVL414'
230 # https://bugzilla.redhat.com/show_bug.cgi?id=1573647
231 %if 0%{?fedora} != 35
232 FLAGS="$FLAGS -fdebug-types-section"
233 %endif
234 %endif
235
236 # clang-12: error: unsupported argument 'auto' to option 'flto='
237 # clang-12: warning: optimization flag '-ffat-lto-objects' is not supported [-Wignored-optimization-argument]
238 FLAGS="$(echo $FLAGS|sed 's/ -flto=auto -ffat-lto-objects / -flto /')"
239 # ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol ...; recompile with -fPIC
240 FLAGS="$FLAGS -fPIC"
241 %if 0%{?rhel:1} && 0%{?rhel} <= 7
242 # clang: error: unknown argument: '-fstack-protector-strong'
243 FLAGS="$(echo $FLAGS|sed 's/ -fstack-protector-strong / /')"
244 %endif
245
246 export CFLAGS="$FLAGS"
247 export CXXFLAGS="$FLAGS"
248
249 export LDFLAGS="%{build_ldflags}"
250 LDFLAGS="$LDFLAGS -flto -Wl,--build-id=sha1"
251
252 # This is default - changing it breaks the testsuite: -DLLVM_LINK_LLVM_DYLIB=OFF
253 # It does not work: -DDCMAKE_EXECUTABLE_SUFFIX=-experimental
254 %cmake llvm \
255   -DCMAKE_INSTALL_PREFIX=%{pkg_prefix} \
256   -DCMAKE_C_COMPILER=clang \
257   -DCMAKE_CXX_COMPILER=clang++ \
258 %if 0%{?rhel:1} && 0%{?rhel} <= 7
259   -DLLVM_USE_LINKER=gold \
260 %else
261   -DLLVM_USE_LINKER=lld \
262 %endif
263 %if %{fast}
264   -DCMAKE_BUILD_TYPE=Release \
265 %else
266   -DCMAKE_BUILD_TYPE=RelWithDebInfo \
267 %endif
268   -DLLVM_ENABLE_PROJECTS="lldb;clang;lld" \
269   -DLLVM_TARGETS_TO_BUILD=X86 \
270   -DLLVM_BUILD_TOOLS=OFF \
271   $(: file INSTALL cannot find build-release/lib/python3.6 ) \
272 %if 0%{?__isa_bits} == 64
273   -DLLVM_LIBDIR_SUFFIX=64 \
274 %else
275   -DLLVM_LIBDIR_SUFFIX= \
276 %endif
277   -DLLDB_DISABLE_CURSES=OFF \
278   -DLLDB_DISABLE_LIBEDIT=OFF \
279   -DLLDB_DISABLE_PYTHON=OFF \
280   -DLLVM_ENABLE_ASSERTIONS=ON \
281   #
282 %cmake_build
283
284 %install
285 mkdir -p %{buildroot}%{pkg_prefix}
286 (function revline {
287    echo "$(cd $1;git rev-parse ${2:-origin/main}) ${2:-$1}"
288  }
289  revline .
290 %if %{use_jankratochvil_dwz}
291  revline . jankratochvil/dwz
292 %endif
293 %if %{use_jankratochvil_rust}
294  revline . jankratochvil/rust
295 %endif
296 ) >%{buildroot}%{pkg_prefix}/commit
297 %cmake_install
298 mkdir -p %{buildroot}%{_bindir}
299 # lldb-mi
300 for i in lldb;do
301   echo >%{buildroot}%{_bindir}/${i}-experimental -e '#! /bin/bash\nexec %{pkg_prefix}/bin/'$i' "$@"'
302   chmod +x %{buildroot}%{_bindir}/${i}-experimental
303 done
304
305 # remove static libraries
306 rm -fv %{buildroot}%{_libdir}/*.a
307
308 ### python: fix liblldb.so -> liblldb.so.7 symlink target
309 (cd %{buildroot}%{pkg_prefix}/%{_lib}/python*/site-packages/lldb/
310  ln -vsf "$(dirname $(readlink _lldb.so))/$(readlink $(readlink _lldb.so))" _lldb.so
311 )
312 du -shc $PWD %{buildroot}
313
314 %files
315 %{_bindir}/lldb-experimental
316 #{_bindir}/lldb-mi-experimental
317 %{pkg_prefix}/commit
318 %{pkg_prefix}/bin/lldb
319 %{pkg_prefix}/bin/lldb-server
320 #{pkg_prefix}/bin/lldb-mi
321 %{pkg_prefix}/bin/lldb-argdumper
322 # RHEL-7: File not found by glob: .../lib{lldb,clang,LLVM}*.so.*
323 %{pkg_prefix}/%{_lib}/libl*.so.*
324 %{pkg_prefix}/%{_lib}/python*
325 %{pkg_prefix}/%{_lib}/lib[^l]*.so.*
326
327 %files devel
328 %{pkg_prefix}/include
329 %{pkg_prefix}/%{_lib}/*.so
330
331 %changelog
332 * Thu Apr  5 2018 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.0.0-0.1
333 - Initial import for COPR, based on Fedora package 'lldb'.