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