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