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