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