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