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