(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 1
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: 13.0.0
23 Release: 0.20210710snap0%{?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 merge nealsid/lldb-editline-remove-wchar
205 %endif
206
207 %build
208 FLAGS="%{optflags}"
209
210 # lldb/scripts/LLDBWrapPython.cpp:23699:70: error: format not a string literal and no format arguments [-Werror=format-security]
211 FLAGS="$FLAGS -Wno-error=format-security"
212
213 %if (0%{?rhel:1} && 0%{?rhel} <= 7)
214 . /opt/rh/llvm-toolset-7.0/enable
215 . /opt/rh/rh-python38/enable
216 %endif
217 %if %{fast}
218 FLAGS="$FLAGS -g0"
219 %else
220 # -fno-reorder-blocks-and-partition:
221 # -gsplit-dwarf: Error: can't resolve `.text.unlikely' - `.LVL414'
222 # https://bugzilla.redhat.com/show_bug.cgi?id=1573647
223 %if 0%{?fedora} != 35
224 FLAGS="$FLAGS -fdebug-types-section"
225 %endif
226 %endif
227
228 # clang-12: error: unsupported argument 'auto' to option 'flto='
229 # clang-12: warning: optimization flag '-ffat-lto-objects' is not supported [-Wignored-optimization-argument]
230 FLAGS="$(echo $FLAGS|sed 's/ -flto=auto -ffat-lto-objects / -flto /')"
231 # ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol ...; recompile with -fPIC
232 FLAGS="$FLAGS -fPIC"
233 %if 0%{?rhel:1} && 0%{?rhel} <= 7
234 # clang: error: unknown argument: '-fstack-protector-strong'
235 FLAGS="$(echo $FLAGS|sed 's/ -fstack-protector-strong / /')"
236 %endif
237
238 export CFLAGS="$FLAGS"
239 export CXXFLAGS="$FLAGS"
240
241 export LDFLAGS="%{build_ldflags}"
242 LDFLAGS="$LDFLAGS -flto -Wl,--build-id=sha1"
243
244 # This is default - changing it breaks the testsuite: -DLLVM_LINK_LLVM_DYLIB=OFF
245 # It does not work: -DDCMAKE_EXECUTABLE_SUFFIX=-experimental
246 %cmake llvm \
247   -DCMAKE_INSTALL_PREFIX=%{pkg_prefix} \
248   -DCMAKE_C_COMPILER=clang \
249   -DCMAKE_CXX_COMPILER=clang++ \
250 %if 0%{?rhel:1} && 0%{?rhel} <= 7
251   -DLLVM_USE_LINKER=gold \
252 %else
253   -DLLVM_USE_LINKER=lld \
254 %endif
255 %if %{fast}
256   -DCMAKE_BUILD_TYPE=Release \
257 %else
258   -DCMAKE_BUILD_TYPE=RelWithDebInfo \
259 %endif
260   -DLLVM_ENABLE_PROJECTS="lldb;clang;lld" \
261   -DLLVM_TARGETS_TO_BUILD=X86 \
262   -DLLVM_BUILD_TOOLS=OFF \
263   $(: file INSTALL cannot find build-release/lib/python3.6 ) \
264 %if 0%{?__isa_bits} == 64
265   -DLLVM_LIBDIR_SUFFIX=64 \
266 %else
267   -DLLVM_LIBDIR_SUFFIX= \
268 %endif
269   -DLLDB_DISABLE_CURSES=OFF \
270   -DLLDB_DISABLE_LIBEDIT=OFF \
271   -DLLDB_DISABLE_PYTHON=OFF \
272   -DLLVM_ENABLE_ASSERTIONS=ON \
273   #
274 %cmake_build
275
276 %install
277 mkdir -p %{buildroot}%{pkg_prefix}
278 (function revline {
279    echo "$(cd $1;git rev-parse ${2:-origin/main}) ${2:-$1}"
280  }
281  revline .
282 %if %{use_jankratochvil_dwz}
283  revline . jankratochvil/dwz
284 %endif
285 %if %{use_jankratochvil_rust}
286  revline . jankratochvil/rust
287 %endif
288 ) >%{buildroot}%{pkg_prefix}/commit
289 %cmake_install
290 mkdir -p %{buildroot}%{_bindir}
291 # lldb-mi
292 for i in lldb;do
293   echo >%{buildroot}%{_bindir}/${i}-experimental -e '#! /bin/bash\nexec %{pkg_prefix}/bin/'$i' "$@"'
294   chmod +x %{buildroot}%{_bindir}/${i}-experimental
295 done
296
297 # remove static libraries
298 rm -fv %{buildroot}%{_libdir}/*.a
299
300 ### python: fix liblldb.so -> liblldb.so.7 symlink target
301 (cd %{buildroot}%{pkg_prefix}/%{_lib}/python*/site-packages/lldb/
302  ln -vsf "$(dirname $(readlink _lldb.so))/$(readlink $(readlink _lldb.so))" _lldb.so
303 )
304 du -shc $PWD %{buildroot}
305
306 %files
307 %{_bindir}/lldb-experimental
308 #{_bindir}/lldb-mi-experimental
309 %{pkg_prefix}/commit
310 %{pkg_prefix}/bin/lldb
311 %{pkg_prefix}/bin/lldb-server
312 #{pkg_prefix}/bin/lldb-mi
313 %{pkg_prefix}/bin/lldb-argdumper
314 # RHEL-7: File not found by glob: .../lib{lldb,clang,LLVM}*.so.*
315 %{pkg_prefix}/%{_lib}/libl*.so.*
316 %{pkg_prefix}/%{_lib}/python*
317 %{pkg_prefix}/%{_lib}/lib[^l]*.so.*
318
319 %files devel
320 %{pkg_prefix}/include
321 %{pkg_prefix}/%{_lib}/*.so
322
323 %changelog
324 * Thu Apr  5 2018 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.0.0-0.1
325 - Initial import for COPR, based on Fedora package 'lldb'.