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