(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.20210604snap7%{?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: llvm-toolset-7.0-clang llvm-toolset-7.0-lld
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/llvm-toolset-7.0/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 # ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol ...; recompile with -fPIC
212 FLAGS="$FLAGS -fPIC"
213 %if 0%{?rhel:1} && 0%{?rhel} <= 7
214 # clang: error: unknown argument: '-fstack-protector-strong'
215 FLAGS="$(echo $FLAGS|sed 's/ -fstack-protector-strong / /')"
216 %endif
217
218 CFLAGS="$FLAGS"
219 CXXFLAGS="$FLAGS"
220
221 # This is default - changing it breaks the testsuite: -DLLVM_LINK_LLVM_DYLIB=OFF
222 # It does not work: -DDCMAKE_EXECUTABLE_SUFFIX=-experimental
223 %cmake llvm \
224   -DCMAKE_INSTALL_PREFIX=%{pkg_prefix} \
225   -DCMAKE_C_COMPILER=clang \
226   -DCMAKE_CXX_COMPILER=clang++ \
227 %if 0%{?rhel:1} && 0%{?rhel} <= 7
228   -DLLVM_USE_LINKER=gold \
229 %else
230   -DLLVM_USE_LINKER=lld \
231 %endif
232 %if %{fast}
233   -DCMAKE_BUILD_TYPE=Release \
234 %else
235   -DCMAKE_BUILD_TYPE=RelWithDebInfo \
236 %endif
237   -DLLVM_ENABLE_PROJECTS="lldb;clang;lld" \
238   -DLLVM_TARGETS_TO_BUILD=X86 \
239   -DLLVM_BUILD_TOOLS=OFF \
240   $(: file INSTALL cannot find build-release/lib/python3.6 ) \
241 %if 0%{?__isa_bits} == 64
242   -DLLVM_LIBDIR_SUFFIX=64 \
243 %else
244   -DLLVM_LIBDIR_SUFFIX= \
245 %endif
246   -DLLDB_DISABLE_CURSES=OFF \
247   -DLLDB_DISABLE_LIBEDIT=OFF \
248   -DLLDB_DISABLE_PYTHON=OFF \
249   -DLLVM_ENABLE_ASSERTIONS=ON \
250   #
251 %cmake_build
252
253 %install
254 mkdir -p %{buildroot}%{pkg_prefix}
255 (function revline {
256    echo "$(cd $1;git rev-parse ${2:-origin/master}) ${2:-$1}"
257  }
258  revline .
259 %if %{use_jankratochvil_dwz}
260  revline . jankratochvil/dwz
261 %endif
262 %if %{use_jankratochvil_rust}
263  revline . jankratochvil/rust
264 %endif
265 ) >%{buildroot}%{pkg_prefix}/HEAD
266 %cmake_install
267 mkdir -p %{buildroot}%{_bindir}
268 # lldb-mi
269 for i in lldb;do
270   echo >%{buildroot}%{_bindir}/${i}-experimental -e '#! /bin/bash\nexec %{pkg_prefix}/bin/'$i' "$@"'
271   chmod +x %{buildroot}%{_bindir}/${i}-experimental
272 done
273
274 # remove static libraries
275 rm -fv %{buildroot}%{_libdir}/*.a
276
277 ### python: fix liblldb.so -> liblldb.so.7 symlink target
278 (cd %{buildroot}%{pkg_prefix}/%{_lib}/python*/site-packages/lldb/
279  ln -vsf "$(dirname $(readlink _lldb.so))/$(readlink $(readlink _lldb.so))" _lldb.so
280 )
281 du -shc $PWD %{buildroot}
282
283 %files
284 %{_bindir}/lldb-experimental
285 #{_bindir}/lldb-mi-experimental
286 %{pkg_prefix}/HEAD
287 %{pkg_prefix}/bin/lldb
288 %{pkg_prefix}/bin/lldb-server
289 #{pkg_prefix}/bin/lldb-mi
290 %{pkg_prefix}/bin/lldb-argdumper
291 # RHEL-7: File not found by glob: .../lib{lldb,clang,LLVM}*.so.*
292 %{pkg_prefix}/%{_lib}/libl*.so.*
293 %{pkg_prefix}/%{_lib}/python*
294 %{pkg_prefix}/%{_lib}/lib[^l]*.so.*
295
296 %files devel
297 %{pkg_prefix}/include
298 %{pkg_prefix}/%{_lib}/*.so
299
300 %changelog
301 * Thu Apr  5 2018 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.0.0-0.1
302 - Initial import for COPR, based on Fedora package 'lldb'.