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