62c963aa9b7881560182168d660b2e1b5e55b212
[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.20200721snap0%{?dist}
16 Summary: Next generation high-performance debugger - experimental trunk snapshot
17 License: NCSA
18 URL: http://lldb.llvm.org/
19 ExclusiveArch: x86_64
20 BuildRequires: gcc-c++ git libedit-devel libatomic ninja-build libxml2-devel zlib-devel valgrind-devel libpfm-devel
21 # https://src.fedoraproject.org/rpms/epydoc
22 #BuildRequires: epydoc
23 %if 0%{?rhel:1} && 0%{?rhel} <= 7
24 BuildRequires: llvm-toolset-7-cmake devtoolset-8-gcc-c++ python-devel python2-pyyaml
25 # swig on rhel7: /builddir/build/BUILD/lldb-experimental-11.0.0/lldb/bindings/./python/python-typemaps.swig:496: Error: Syntax error in input(3).
26 BuildRequires: swig3
27 # https://bugzilla.redhat.com/show_bug.cgi?id=1511892
28 %global __cmake /opt/rh/llvm-toolset-7/root/usr/bin/cmake3
29 %global ninjabuild ninja-build
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 %global ninjabuild ninja
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 %setup -q -c -T
69 OPTS="--depth 10000"
70 %if !0%{?rhel:1} || 0%{?rhel} > 7
71   OPTS="$OPTS --no-tags"
72 %endif
73 REF="reference"
74 # RHEL-7 does not support: --reference-if-able
75 CLONEOPTS="--single-branch"
76 test -d ../$REF/ && CLONEOPTS="$CLONEOPTS --reference ../$REF"
77 # 2500 = 1 month in 2019
78 git clone $OPTS $CLONEOPTS https://github.com/llvm/llvm-project.git .
79 %if %{use_jankratochvil_dwz} || %{use_jankratochvil_rust}
80 git remote remove jankratochvil || :
81 #git remote add jankratochvil git://git.jankratochvil.net/lldb
82 git remote add jankratochvil https://github.com/jankratochvil/llvm-project.git
83 git fetch $OPTS jankratochvil
84 git config user.email jankratochvil@copr.fedorainfracloud.org
85 git config user.name jankratochvil
86 %endif
87 %if %{use_jankratochvil_dwz}
88 git merge jankratochvil/dwz
89 %endif
90 %if %{use_jankratochvil_rust}
91 # '-c merge.renames=false' is F-29+.
92 # '-c merge.renameLimit=0' has no effect.
93 git -c merge.renameLimit=1 merge jankratochvil/rust
94 %endif
95
96 %build
97 mkdir build-release
98 cd    build-release
99
100 FLAGS="%{optflags}"
101
102 # lldb/scripts/LLDBWrapPython.cpp:23699:70: error: format not a string literal and no format arguments [-Werror=format-security]
103 FLAGS="$FLAGS -Wno-error=format-security"
104
105 %if (0%{?rhel:1} && 0%{?rhel} <= 7)
106 . /opt/rh/devtoolset-8/enable
107 # -gsplit-dwarf: LLVM: internal compiler error: in output_index_string, at dwarf2out.c:21891
108 # https://bugzilla.redhat.com/show_bug.cgi?id=1590678
109 # Set %%{fast} only after %%debug_package above.
110 %global fast 1
111 %endif
112 %if %{fast}
113 FLAGS="$FLAGS -g0"
114 %else
115 # -fno-reorder-blocks-and-partition:
116 # -gsplit-dwarf: Error: can't resolve `.text.unlikely' - `.LVL414'
117 # https://bugzilla.redhat.com/show_bug.cgi?id=1573647
118 FLAGS="$FLAGS -gsplit-dwarf -fno-reorder-blocks-and-partition"
119 %endif
120
121 CFLAGS="$FLAGS"
122 CXXFLAGS="$FLAGS"
123
124 # This is default - changing it breaks the testsuite: -DLLVM_LINK_LLVM_DYLIB=OFF
125 # It does not work: -DDCMAKE_EXECUTABLE_SUFFIX=-experimental
126 # -fdebug-types-section && -DLLVM_USE_LINKER=gold:
127 # ../../../../lib64/libclangLex.a(PreprocessingRecord.cpp.o)(.debug_types+0xfe): error: undefined reference to 'clang::SourceRange::getBegin() const'
128 %cmake ../llvm \
129   -GNinja \
130   -DCMAKE_INSTALL_PREFIX=%{buildroot}%{pkg_prefix} \
131   -DBUILD_SHARED_LIBS=OFF \
132 %if %{fast}
133   -DCMAKE_BUILD_TYPE=Release \
134 %else
135   -DCMAKE_BUILD_TYPE=RelWithDebInfo \
136 %endif
137   -DLLVM_ENABLE_PROJECTS="lldb;clang;lld" \
138   -DLLVM_TARGETS_TO_BUILD=X86 \
139   -DLLVM_BUILD_TOOLS=OFF \
140   -DLLVM_USE_LINKER=gold \
141   $(: file INSTALL cannot find build-release/lib/python3.6 ) \
142 %if 0%{?__isa_bits} == 64
143   -DLLVM_LIBDIR_SUFFIX=64 \
144 %else
145   -DLLVM_LIBDIR_SUFFIX= \
146 %endif
147   -DLLDB_DISABLE_CURSES=OFF \
148   -DLLDB_DISABLE_LIBEDIT=OFF \
149   -DLLDB_DISABLE_PYTHON=OFF \
150   #
151 %{ninjabuild} -v
152
153 %install
154 mkdir -p %{buildroot}%{pkg_prefix}
155 (function revline {
156    echo "$(cd $1;git rev-parse ${2:-origin/master}) ${2:-$1}"
157  }
158  revline .
159 %if %{use_jankratochvil_dwz}
160  revline . jankratochvil/dwz
161 %endif
162 %if %{use_jankratochvil_rust}
163  revline . jankratochvil/rust
164 %endif
165 ) >%{buildroot}%{pkg_prefix}/HEAD
166 cd build-release
167 %{ninjabuild} -v install
168 mkdir -p %{buildroot}%{_bindir}
169 # lldb-mi
170 for i in lldb;do
171   echo >%{buildroot}%{_bindir}/${i}-experimental -e '#! /bin/bash\nexec %{pkg_prefix}/bin/'$i' "$@"'
172   chmod +x %{buildroot}%{_bindir}/${i}-experimental
173 done
174
175 # remove static libraries
176 rm -fv %{buildroot}%{_libdir}/*.a
177
178 ### python: fix liblldb.so -> liblldb.so.7 symlink target
179 (cd %{buildroot}%{pkg_prefix}/%{_lib}/python*/site-packages/lldb/
180  ln -vsf "$(dirname $(readlink _lldb.so))/$(readlink $(readlink _lldb.so))" _lldb.so
181 )
182
183 %files
184 %{_bindir}/lldb-experimental
185 #{_bindir}/lldb-mi-experimental
186 %{pkg_prefix}/HEAD
187 %{pkg_prefix}/bin/lldb
188 %{pkg_prefix}/bin/lldb-server
189 #{pkg_prefix}/bin/lldb-mi
190 %{pkg_prefix}/bin/lldb-argdumper
191 # RHEL-7: File not found by glob: .../lib{lldb,clang,LLVM}*.so.*
192 %{pkg_prefix}/%{_lib}/libl*.so.*
193 %{pkg_prefix}/%{_lib}/python*
194
195 %files devel
196 %{pkg_prefix}/include
197 %{pkg_prefix}/%{_lib}/lib[^l]*.so.*
198 %{pkg_prefix}/%{_lib}/*.so
199 %{pkg_prefix}/%{_lib}/*.a
200
201 %changelog
202 * Thu Apr  5 2018 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.0.0-0.1
203 - Initial import for COPR, based on Fedora package 'lldb'.