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