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