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