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