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