(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: 11.0.0
17 Release: 0.20200726snap0%{?dist}
18 Summary: Next generation high-performance debugger - experimental trunk snapshot
19 License: NCSA
20 URL: http://lldb.llvm.org/
21 Patch1: cmake-old1.patch
22 Patch2: cmake-old2.patch
23 ExclusiveArch: x86_64
24 BuildRequires: gcc-c++ git libedit-devel libatomic libxml2-devel zlib-devel valgrind-devel libpfm-devel
25 # https://src.fedoraproject.org/rpms/epydoc
26 #BuildRequires: epydoc
27 %if 0%{?rhel:1} && 0%{?rhel} <= 7
28 BuildRequires: llvm-toolset-7-cmake devtoolset-8-gcc-c++ python-devel python2-pyyaml
29 # swig on rhel7: /builddir/build/BUILD/lldb-experimental-11.0.0/lldb/bindings/./python/python-typemaps.swig:496: Error: Syntax error in input(3).
30 BuildRequires: swig3
31 BuildRequires: rh-git218-git-core
32 # https://bugzilla.redhat.com/show_bug.cgi?id=1511892
33 %global __cmake /opt/rh/llvm-toolset-7/root/usr/bin/cmake3
34 %else
35 %if !0%{?rhel:1} || 0%{?rhel} > 8
36 BuildRequires: z3-devel
37 %endif
38 BuildRequires: cmake swig
39 BuildRequires: python3-devel python3-pygments python3-pyyaml
40 # removed in F31+
41 #BuildRequires: xar-devel
42 %endif
43
44 %description
45 LLDB is a next generation, high-performance debugger. It is built as a set
46 of reusable components which highly leverage existing libraries in the
47 larger LLVM Project, such as the Clang expression parser and LLVM
48 disassembler.
49 This package is an experimental trunk snapshot.
50 %if %{use_jankratochvil_dwz}
51 This package contains off-trunk DWZ support for Fedora debuginfos such as:
52   unsupported DW_FORM values: 0x1f20 0x1f21
53 %endif
54 %if %{use_jankratochvil_rust}
55 This package contains off-trunk Rust support:
56   https://github.com/rust-lang-nursery/lldb
57 %endif
58
59 %package devel
60 Summary: Development header files for %{name}
61 Requires: %{name}%{?_isa} = %{version}-%{release}
62
63 %description devel
64 The package contains header files for %{name}.
65
66 {-L,"-Wl,-rpath,"}%{pkg_prefix}/%{_lib} -I%{pkg_prefix}/include -llldb -lLLVMSupport -ltinfo -pthread
67
68 %ldconfig_scriptlets
69
70 %prep
71 %if 0%{?rhel:1} && 0%{?rhel} <= 7
72 # git clone --depth 10000 --single-branch --reference ../reference https://github.com/llvm/llvm-project.git .
73 # fatal: git fetch-pack: expected shallow list
74 . /opt/rh/rh-git218/enable
75 %endif
76 %setup -q -c -T
77 OPTS="--depth 10000"
78 %if !0%{?rhel:1} || 0%{?rhel} > 7
79   OPTS="$OPTS --no-tags"
80 %endif
81 REF="reference"
82 # RHEL-7 does not support: --reference-if-able
83 CLONEOPTS="--single-branch"
84 test -d ../$REF/ && CLONEOPTS="$CLONEOPTS --reference ../$REF"
85 # 2500 = 1 month in 2019
86 git clone $OPTS $CLONEOPTS https://github.com/llvm/llvm-project.git .
87 %if %{use_jankratochvil_dwz} || %{use_jankratochvil_rust}
88 git remote remove jankratochvil || :
89 #git remote add jankratochvil git://git.jankratochvil.net/lldb
90 git remote add jankratochvil https://github.com/jankratochvil/llvm-project.git
91 git fetch $OPTS jankratochvil
92 git config user.email jankratochvil@copr.fedorainfracloud.org
93 git config user.name jankratochvil
94 %endif
95 %if %{use_jankratochvil_dwz}
96 git merge jankratochvil/dwz
97 %endif
98 %if %{use_jankratochvil_rust}
99 # '-c merge.renames=false' is F-29+.
100 # '-c merge.renameLimit=0' has no effect.
101 git -c merge.renameLimit=1 merge jankratochvil/rust
102 %endif
103 %patch2 -p1 -R
104 %patch1 -p1 -R
105
106 %build
107 FLAGS="%{optflags}"
108
109 # lldb/scripts/LLDBWrapPython.cpp:23699:70: error: format not a string literal and no format arguments [-Werror=format-security]
110 FLAGS="$FLAGS -Wno-error=format-security"
111
112 %if (0%{?rhel:1} && 0%{?rhel} <= 7)
113 . /opt/rh/devtoolset-8/enable
114 # -gsplit-dwarf: LLVM: internal compiler error: in output_index_string, at dwarf2out.c:21891
115 # https://bugzilla.redhat.com/show_bug.cgi?id=1590678
116 # Set %%{fast} only after %%debug_package above.
117 %global fast 1
118 %endif
119 %if %{fast}
120 FLAGS="$FLAGS -g0"
121 %else
122 # -fno-reorder-blocks-and-partition:
123 # -gsplit-dwarf: Error: can't resolve `.text.unlikely' - `.LVL414'
124 # https://bugzilla.redhat.com/show_bug.cgi?id=1573647
125 FLAGS="$FLAGS -fdebug-types-section"
126 %endif
127
128 CFLAGS="$FLAGS"
129 CXXFLAGS="$FLAGS"
130
131 # This is default - changing it breaks the testsuite: -DLLVM_LINK_LLVM_DYLIB=OFF
132 # It does not work: -DDCMAKE_EXECUTABLE_SUFFIX=-experimental
133 # -fdebug-types-section && -DLLVM_USE_LINKER=gold:
134 # ../../../../lib64/libclangLex.a(PreprocessingRecord.cpp.o)(.debug_types+0xfe): error: undefined reference to 'clang::SourceRange::getBegin() const'
135 %cmake llvm \
136   -DCMAKE_INSTALL_PREFIX=%{pkg_prefix} \
137   -DBUILD_SHARED_LIBS=OFF \
138 %if %{fast}
139   -DCMAKE_BUILD_TYPE=Release \
140 %else
141   -DCMAKE_BUILD_TYPE=RelWithDebInfo \
142 %endif
143   -DLLVM_ENABLE_PROJECTS="lldb;clang;lld" \
144   -DLLVM_TARGETS_TO_BUILD=X86 \
145   -DLLVM_BUILD_TOOLS=OFF \
146   -DLLVM_USE_LINKER=gold \
147   $(: file INSTALL cannot find build-release/lib/python3.6 ) \
148 %if 0%{?__isa_bits} == 64
149   -DLLVM_LIBDIR_SUFFIX=64 \
150 %else
151   -DLLVM_LIBDIR_SUFFIX= \
152 %endif
153   -DLLDB_DISABLE_CURSES=OFF \
154   -DLLDB_DISABLE_LIBEDIT=OFF \
155   -DLLDB_DISABLE_PYTHON=OFF \
156   #
157 %if 0%{?rhel:1} && 0%{?rhel} <= 8
158 %__cmake --build . -- %{?_smp_mflags}
159 %else
160 %cmake_build
161 %endif
162
163 %install
164 mkdir -p %{buildroot}%{pkg_prefix}
165 (function revline {
166    echo "$(cd $1;git rev-parse ${2:-origin/master}) ${2:-$1}"
167  }
168  revline .
169 %if %{use_jankratochvil_dwz}
170  revline . jankratochvil/dwz
171 %endif
172 %if %{use_jankratochvil_rust}
173  revline . jankratochvil/rust
174 %endif
175 ) >%{buildroot}%{pkg_prefix}/HEAD
176 %if 0%{?rhel:1} && 0%{?rhel} <= 8
177 # It runs a new configure without installing anything: DESTDIR="%{buildroot}" #__cmake --install .
178 %make_install
179 %else
180 %cmake_install
181 %endif
182 mkdir -p %{buildroot}%{_bindir}
183 # lldb-mi
184 for i in lldb;do
185   echo >%{buildroot}%{_bindir}/${i}-experimental -e '#! /bin/bash\nexec %{pkg_prefix}/bin/'$i' "$@"'
186   chmod +x %{buildroot}%{_bindir}/${i}-experimental
187 done
188
189 # remove static libraries
190 rm -fv %{buildroot}%{_libdir}/*.a
191
192 ### python: fix liblldb.so -> liblldb.so.7 symlink target
193 (cd %{buildroot}%{pkg_prefix}/%{_lib}/python*/site-packages/lldb/
194  ln -vsf "$(dirname $(readlink _lldb.so))/$(readlink $(readlink _lldb.so))" _lldb.so
195 )
196
197 %files
198 %{_bindir}/lldb-experimental
199 #{_bindir}/lldb-mi-experimental
200 %{pkg_prefix}/HEAD
201 %{pkg_prefix}/bin/lldb
202 %{pkg_prefix}/bin/lldb-server
203 #{pkg_prefix}/bin/lldb-mi
204 %{pkg_prefix}/bin/lldb-argdumper
205 # RHEL-7: File not found by glob: .../lib{lldb,clang,LLVM}*.so.*
206 %{pkg_prefix}/%{_lib}/libl*.so.*
207 %{pkg_prefix}/%{_lib}/python*
208
209 %files devel
210 %{pkg_prefix}/include
211 %{pkg_prefix}/%{_lib}/lib[^l]*.so.*
212 %{pkg_prefix}/%{_lib}/*.so
213 %{pkg_prefix}/%{_lib}/*.a
214
215 %changelog
216 * Thu Apr  5 2018 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.0.0-0.1
217 - Initial import for COPR, based on Fedora package 'lldb'.