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