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