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