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