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