File llvm20.spec of Package llvm20
1868
1
#
2
# spec file for package llvm20
3
#
4
# Copyright (c) 2025 SUSE LLC
5
#
6
# All modifications and additions to the file contributed by third parties
7
# remain the property of their copyright owners, unless otherwise agreed
8
# upon. The license for this file, and modifications and additions to the
9
# file, is the same license as for the pristine package itself (unless the
10
# license for the pristine package is not an Open Source License, in which
11
# case the license is the MIT License). An "Open Source License" is a
12
# license that conforms to the Open Source Definition (Version 1.9)
13
# published by the Open Source Initiative.
14
15
# Please submit bugfixes or comments via https://bugs.opensuse.org/
16
#
17
18
19
%global _sonum 20
20
%global _minor %{_sonum}.1
21
%global _soname %{_minor}%{?_rc:-rc%_rc}
22
%global _patch_level 0
23
%global _relver %{_minor}.%{_patch_level}
24
%global _version %_relver%{?_rc:-rc%_rc}
25
%global _itsme20 1
26
# Integer version used by update-alternatives
27
%global _uaver %{_sonum}1%{_patch_level}
28
%global _soclang 13
29
%global _socxx 1
30
31
%ifarch x86_64 aarch64 %arm riscv64
32
%bcond_without libcxx
33
%else
34
%bcond_with libcxx
35
%endif
36
37
%ifarch aarch64 ppc64 ppc64le %{ix86} x86_64 riscv64
38
%bcond_without openmp
39
%else
40
%bcond_with openmp
41
%endif
42
43
# Prefer ld.bfd for now because it produces a THP-compatible section layout.
44
%ifnarch %{arm}
45
%bcond_with use_lld
46
%else
47
%bcond_without use_lld
48
%endif
49
50
%ifarch aarch64 ppc64le s390x x86_64
51
%bcond_without lldb
52
%if %{suse_version} > 1600
53
%bcond_without lldb_python
54
%else
55
# LLDB Python bindings require Swig 4, which SLE/Leap don't have.
56
%bcond_with lldb_python
57
%endif
58
%else
59
%bcond_with lldb
60
%bcond_with lldb_python
61
%endif
62
63
%ifarch %{arm} aarch64 %{ix86} ppc64le riscv64 s390x x86_64
64
%bcond_without thin_lto
65
%else
66
%bcond_with thin_lto
67
%endif
68
69
%bcond_with ffi
70
%bcond_with oprofile
71
%bcond_with valgrind
72
%bcond_without polly
73
%bcond_without lld
74
75
# Leap 15 and SLES 15 defaults to GCC 7, which does not have stable C++17 ABI.
76
# See https://bugzilla.suse.com/show_bug.cgi?id=1235697
77
%if 0%{?suse_version} < 1600
78
%define gcc_version 13
79
%endif
80
81
%if %{suse_version} > 1600
82
%global python_pkg python3
83
%global python_bin python3
84
%else
85
%global python_pkg python311
86
%global python_bin python3.11
87
%endif
88
%global python_pkg_sitelib %{expand:%%{%{python_pkg}_sitelib}}
89
%global python_pkg_sitearch %{expand:%%{%{python_pkg}_sitearch}}
90
91
# Figure out the host triple.
92
%ifarch armv6hl
93
# See https://build.opensuse.org/request/show/968066.
94
%define target_cpu armv6kz
95
%else
96
# What RPM spells ppc, GCC spells powerpc.
97
%define target_cpu %{lua:print((string.gsub(rpm.expand("%{_target_cpu}"), "ppc", "powerpc")))}
98
%endif
99
100
%ifarch %{arm}
101
%define host_triple %{target_cpu}-%{_target_vendor}-%{_target_os}-gnueabihf
102
%else
103
%define host_triple %{target_cpu}-%{_target_vendor}-%{_target_os}
104
%endif
105
106
# By default, build everything.
107
%global llvm_targets "all"
108
%global llvm_experimental_targets "M68k"
109
%ifarch %arm ppc64 ppc64le
110
# No cross-compilation, but GPU targets.
111
%global llvm_targets "host;AMDGPU;BPF;NVPTX;WebAssembly"
112
%global llvm_experimental_targets ""
113
%endif
114
%ifarch ppc s390x
115
# No graphics cards on System Z; turned off for ppc because of relocation overflows.
116
%global llvm_targets "host;BPF;WebAssembly"
117
%global llvm_experimental_targets ""
118
%endif
119
120
%ifnarch ppc64le
121
%global openmp_cpu %{target_cpu}
122
%else
123
%global openmp_cpu ppc64
124
%endif
125
126
%define _plv %{!?product_libs_llvm_ver:%{_sonum}}%{?product_libs_llvm_ver}
127
128
# Expands to -n if we're providing the distribution default for the given package.
129
%define multisource() %{expand:%%{?_itsme%{expand:%%{!?product_libs_llvm_ver_%{1}:%%{_plv}}%%{?product_libs_llvm_ver_%{1}}}:-n}}
130
131
# set_jobs type memory
132
# Set max_<type>_jobs so that every job of the given type has at least the
133
# given amount of memory.
134
%define set_jobs() \
135
max_%{1}_jobs="%{?jobs:%{jobs}}" \
136
if test -n "$max_%{1}_jobs" -a "$max_%{1}_jobs" -gt 1 ; then \
137
max_jobs="$(($avail_mem / %2))" \
138
test "$max_%{1}_jobs" -gt "$max_jobs" && max_%{1}_jobs="$max_jobs" && echo "Warning: Reducing number of %{1} jobs to $max_jobs because of memory limits" \
139
test "$max_%{1}_jobs" -le 0 && max_%{1}_jobs=1 && echo "Warning: Not %{1}ing in parallel at all because of memory limits" \
140
fi
141
142
# Recursion utils.
143
%global _stop0 1
144
%define _lapply_rec(p:f:) %{expand:%{%{-p*} %{-f*}} %%{?!_stop%#:%%{_lapply_rec -p %{-p*} -f %*}}}
145
146
# Usage:
147
# %%global pattern foo_%%1
148
# %%{lapply -p pattern a b c}
149
# produces foo_a foo_b foo_c.
150
%define lapply(p:) %{_lapply_rec -p %{-p*} -f %{shrink:%*}}
151
152
%define comment() %{nil}
153
154
# Due to RPMs recursion limit, we have to split the lists into portions of ≤ 20.
155
%global llvm_ua_anchor llvm-ar
156
%global llvm_tools \
157
%{comment Optimizer, compiler, interpreter, linker} \
158
llc \
159
lli \
160
llvm-jitlink \
161
llvm-link \
162
llvm-lto \
163
llvm-lto2 \
164
llvm-opt-report \
165
llvm-rtdyld \
166
opt \
167
%{comment LLVM IR tools} \
168
llvm-as \
169
llvm-bcanalyzer \
170
llvm-bitcode-strip \
171
llvm-cat \
172
llvm-diff \
173
llvm-dis \
174
llvm-extract \
175
llvm-modextract \
176
llvm-sim \
177
llvm-split
178
%global llvm_elf_dwarf_tools \
179
%{comment ELF tools} \
180
llvm-cfi-verify \
181
llvm-nm \
182
llvm-objcopy \
183
llvm-objdump \
184
llvm-ranlib \
185
llvm-readelf \
186
llvm-readobj \
187
llvm-size \
188
llvm-strip \
189
%{comment Debug info tools} \
190
dsymutil \
191
llvm-addr2line \
192
llvm-debuginfo-analyzer \
193
llvm-debuginfod \
194
llvm-debuginfod-find \
195
llvm-dwarfdump \
196
llvm-dwarfutil \
197
llvm-dwp \
198
llvm-gsymutil \
199
llvm-symbolizer
200
%global llvm_abi_coff_macho_tools \
201
%{comment ABI tools} \
202
llvm-cxxdump \
203
llvm-cxxfilt \
204
llvm-cxxmap \
205
llvm-ifs \
206
%{comment Windows/COFF} \
207
llvm-cvtres \
208
llvm-dlltool \
209
llvm-lib \
210
llvm-ml \
211
llvm-mt \
212
llvm-pdbutil \
213
llvm-rc \
214
llvm-undname \
215
llvm-windres \
216
%{comment Apple/Mach-O} \
217
llvm-install-name-tool \
218
llvm-libtool-darwin \
219
llvm-lipo \
220
llvm-otool \
221
llvm-readtapi
222
%global llvm_instr_devel_tools \
223
%{comment Instrumentation and introspection} \
224
llvm-cgdata \
225
llvm-cov \
226
llvm-ctxprof-util \
227
llvm-profdata \
228
llvm-profgen \
229
llvm-xray \
230
sancov \
231
sanstats \
232
%{comment Development utilities} \
233
bugpoint \
234
llvm-c-test \
235
llvm-mc \
236
llvm-mca \
237
llvm-reduce \
238
llvm-remarkutil \
239
llvm-stress \
240
llvm-strings \
241
llvm-tblgen \
242
llvm-tli-checker \
243
reduce-chunk-list \
244
verify-uselistorder
245
246
%global clang_ua_anchor clang
247
%global clang_binfiles \
248
c-index-test \
249
clang++ \
250
clang-check \
251
clang-cl \
252
clang-cpp \
253
clang-extdef-mapping \
254
clang-format \
255
clang-installapi \
256
clang-linker-wrapper \
257
clang-nvlink-wrapper \
258
clang-offload-bundler \
259
clang-offload-packager \
260
clang-refactor \
261
clang-repl \
262
clang-scan-deps \
263
clang-sycl-linker \
264
clang-tblgen \
265
diagtool
266
%global clang_tools_extra_binfiles \
267
%{comment Technically still clang} \
268
amdgpu-arch \
269
nvptx-arch \
270
%{comment Real clang-tools-extra} \
271
clang-apply-replacements \
272
clang-change-namespace \
273
clang-include-cleaner \
274
clang-include-fixer \
275
clang-move \
276
clang-query \
277
clang-reorder-fields \
278
clang-tidy \
279
clangd \
280
find-all-symbols \
281
modularize \
282
pp-trace
283
%if %{with lld}
284
%global lld_ua_anchor lld
285
%global lld_binfiles \
286
ld.lld \
287
lld-link \
288
ld64.lld \
289
wasm-ld
290
%endif
291
%if %{with lldb}
292
%global lldb_ua_anchor lldb
293
%global lldb_binfiles \
294
lldb-argdumper \
295
lldb-dap \
296
lldb-instr \
297
lldb-server
298
%endif
299
%global binfiles \
300
%{llvm_ua_anchor} %{llvm_tools} %{llvm_elf_dwarf_tools} \
301
%{llvm_abi_coff_macho_tools} %{llvm_instr_devel_tools} \
302
%{clang_ua_anchor} %{clang_binfiles} %{clang_tools_extra_binfiles} \
303
%{?lld_ua_anchor} %{?lld_binfiles} %{?lldb_ua_anchor} %{?lldb_binfiles}
304
305
%global llvm_man \
306
%{comment Optimizer, compiler, interpreter, linker} \
307
llc \
308
lli \
309
llvm-link \
310
opt \
311
%{comment LLVM IR tools} \
312
llvm-as \
313
llvm-bcanalyzer \
314
llvm-dis \
315
llvm-extract \
316
%{comment Instrumentation and introspection} \
317
llvm-cgdata \
318
llvm-cov \
319
llvm-opt-report \
320
llvm-profdata \
321
llvm-profgen \
322
llvm-symbolizer
323
%global llvm_bin_utils_man \
324
%{comment ELF tools} \
325
llvm-ar \
326
llvm-nm \
327
llvm-objcopy \
328
llvm-objdump \
329
llvm-ranlib \
330
llvm-readelf \
331
llvm-readobj \
332
llvm-size \
333
llvm-strip \
334
%{comment Debug info tools} \
335
dsymutil \
336
llvm-addr2line \
337
llvm-debuginfo-analyzer \
338
llvm-dwarfdump \
339
llvm-dwarfutil \
340
%{comment Windows/COFF} \
341
llvm-lib \
342
llvm-pdbutil \
343
%{comment Apple/Mach-O} \
344
llvm-install-name-tool \
345
llvm-libtool-darwin \
346
llvm-lipo \
347
llvm-otool
348
%global llvm_devel_utils_man \
349
%{comment ABI tools} \
350
llvm-cxxfilt \
351
llvm-cxxmap \
352
llvm-ifs \
353
%{comment Development utilities} \
354
bugpoint \
355
llvm-diff \
356
llvm-mc \
357
llvm-mca \
358
llvm-reduce \
359
llvm-remarkutil \
360
llvm-stress \
361
llvm-strings \
362
llvm-tblgen \
363
llvm-tli-checker
364
365
%global clang_manfiles clang diagtool
366
%global manfiles %{llvm_man} %{llvm_bin_utils_man} %{llvm_devel_utils_man} %{clang_manfiles}
367
368
%define _dwz_low_mem_die_limit 40000000
369
%define _dwz_max_die_limit 200000000
370
371
Name: llvm20
372
Version: %_relver%{?_rc:~rc%_rc}
373
Release: 0
374
Summary: Low Level Virtual Machine
375
License: Apache-2.0 WITH LLVM-exception AND NCSA
376
Group: Development/Languages/Other
377
URL: https://www.llvm.org/
378
# NOTE: please see README.packaging in the llvm package for details on how to update this package
379
Source0: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{_version}/llvm-%{_version}.src.tar.xz
380
Source1: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{_version}/cmake-%{_version}.src.tar.xz
381
Source2: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{_version}/clang-%{_version}.src.tar.xz
382
Source3: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{_version}/clang-tools-extra-%{_version}.src.tar.xz
383
Source4: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{_version}/compiler-rt-%{_version}.src.tar.xz
384
Source5: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{_version}/libcxx-%{_version}.src.tar.xz
385
Source6: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{_version}/libcxxabi-%{_version}.src.tar.xz
386
Source7: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{_version}/openmp-%{_version}.src.tar.xz
387
Source8: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{_version}/lld-%{_version}.src.tar.xz
388
Source9: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{_version}/lldb-%{_version}.src.tar.xz
389
Source10: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{_version}/polly-%{_version}.src.tar.xz
390
Source11: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{_version}/runtimes-%{_version}.src.tar.xz
391
# We shouldn't actually use this, but it's hard to untangle from the build.
392
Source12: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{_version}/third-party-%{_version}.src.tar.xz
393
# Only header files should be used. (https://discourse.llvm.org/t/rfc-project-hand-in-hand-llvm-libc-libc-code-sharing/77701)
394
Source13: libc-%{_version}.src.tar.xz
395
Source14: https://github.com/llvm/llvm-project/raw/llvmorg-%{_version}/libunwind/include/mach-o/compact_unwind_encoding.h
396
Source29: https://releases.llvm.org/release-keys.asc#/%{name}.keyring
397
Source30: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{_version}/llvm-%{_version}.src.tar.xz.sig
398
Source31: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{_version}/cmake-%{_version}.src.tar.xz.sig
399
Source32: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{_version}/clang-%{_version}.src.tar.xz.sig
400
Source33: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{_version}/clang-tools-extra-%{_version}.src.tar.xz.sig
401
Source34: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{_version}/compiler-rt-%{_version}.src.tar.xz.sig
402
Source35: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{_version}/libcxx-%{_version}.src.tar.xz.sig
403
Source36: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{_version}/libcxxabi-%{_version}.src.tar.xz.sig
404
Source37: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{_version}/openmp-%{_version}.src.tar.xz.sig
405
Source38: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{_version}/lld-%{_version}.src.tar.xz.sig
406
Source39: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{_version}/lldb-%{_version}.src.tar.xz.sig
407
Source40: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{_version}/polly-%{_version}.src.tar.xz.sig
408
Source41: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{_version}/runtimes-%{_version}.src.tar.xz.sig
409
Source42: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{_version}/third-party-%{_version}.src.tar.xz.sig
410
# Docs are created manually, see below
411
Source50: llvm-docs-%{_version}.src.tar.xz
412
Source51: clang-docs-%{_version}.src.tar.xz
413
Source100: %{name}-rpmlintrc
414
Source101: baselibs.conf
415
# PATCH-FIX-OPENSUSE lto-disable-cache.patch -- Disable ThinLTO cache
416
Patch0: lto-disable-cache.patch
417
# Include tools before projects so that OpenMP can see Clang. (Proper fix?)
418
Patch1: llvm-projects-tools-order.patch
419
# PATCH-FIX-OPENSUSE assume-opensuse.patch idoenmez@suse.de -- Always enable openSUSE/SUSE features
420
Patch2: assume-opensuse.patch
421
# PATCH-FIX-OPENSUSE default-to-i586.patch -- Use i586 as default target for 32bit
422
Patch3: default-to-i586.patch
423
Patch4: clang-resourcedirs.patch
424
Patch6: llvm-fix-find-gcc5-install.patch
425
Patch9: link-clang-shared.patch
426
Patch10: link-clang-tools-extra-shared.patch
427
# PATCH-FIX-OPENSUSE lldb-cmake.patch -- Fix ncurses include path.
428
Patch11: lldb-cmake.patch
429
Patch13: llvm-normally-versioned-libllvm.patch
430
Patch14: llvm-do-not-install-static-libraries.patch
431
# PATCH-FIX-OPENSUSE (or -UPSTREAM?): we disable RPATHs, but the test driver drops LD_LIBRARY_PATH.
432
Patch15: libcxx-test-library-path.patch
433
# PATCH-FIX-UPSTREAM (?): Work around gh#llvm/llvm-project#28804 by hinting with __builtin_assume.
434
Patch16: llvm-workaround-superfluous-branches.patch
435
# PATCH-FIX-UPSTREAM: Recognize <arch>-suse-linux as implicitly GNU. Discussion at https://reviews.llvm.org/D110900.
436
Patch17: llvm-suse-implicit-gnu.patch
437
Patch20: llvm_build_tablegen_component_as_shared_library.patch
438
Patch21: tests-use-python3.patch
439
Patch24: opt-viewer-Find-style-css-in-usr-share.patch
440
# PATCH-FIX-OPENSUSE check-no-llvm-exegesis.patch -- Don't let tests depend on llvm-exegesis.
441
# We don't build this because it's not useful without libpfm and can't link with libLLVM.so.
442
Patch25: check-no-llvm-exegesis.patch
443
# PATCH-FIX-UPSTREAM: Require x86 target for test.
444
Patch27: clang-fix-openmp-test.patch
445
# PATCH-FIX-UPSTREAM: Fix test with x87 floating-point.
446
Patch28: llvm-fix-cov-test-i586.patch
447
BuildRequires: %{python_pkg}-base >= 3.8
448
BuildRequires: binutils-devel >= 2.21.90
449
BuildRequires: cmake >= 3.13.4
450
BuildRequires: fdupes
451
BuildRequires: gcc%{?gcc_version} >= 9
452
BuildRequires: gcc%{?gcc_version}-c++ >= 9
453
BuildRequires: libstdc++-devel
454
BuildRequires: ninja
455
BuildRequires: pkgconfig
456
BuildRequires: python-rpm-macros
457
BuildRequires: pkgconfig(libedit)
458
BuildRequires: pkgconfig(libzstd)
459
BuildRequires: pkgconfig(zlib)
460
Requires(post): update-alternatives
461
Requires(postun): update-alternatives
462
# llvm does not work on s390
463
ExcludeArch: s390
464
%if %{with ffi}
465
BuildRequires: pkgconfig(libffi)
466
%endif
467
%if %{with valgrind}
468
BuildRequires: pkgconfig(valgrind)
469
%endif
470
%if %{with oprofile}
471
BuildRequires: oprofile-devel
472
%endif
473
Suggests: %{name}-doc
474
475
%description
476
LLVM is a compiler infrastructure designed for compile-time,
477
link-time, runtime, and idle-time optimization of programs from
478
arbitrary programming languages.
479
480
The compiler infrastructure includes mirror sets of programming
481
tools as well as libraries with equivalent functionality.
482
483
%package -n libLLVM%{_sonum}
484
Summary: Libraries for LLVM
485
Group: System/Libraries
486
487
%description -n libLLVM%{_sonum}
488
This package contains the shared libraries needed for LLVM.
489
490
%package devel
491
Summary: Header Files for LLVM
492
Group: Development/Libraries/C and C++
493
Requires: %{name} = %{version}
494
%if %{with openmp}
495
# Referenced by LLVMExports.cmake
496
Requires: libomp%{_sonum}-devel
497
%endif
498
Requires: libLLVM%{_sonum} = %{version}
499
Requires: libLTO%{_sonum} = %{version}
500
Requires: libstdc++-devel
501
Requires: libtool
502
Requires: llvm%{_sonum}-gold
503
%if %{with polly}
504
# Referenced by LLVMExports.cmake
505
Requires: llvm%{_sonum}-polly-devel
506
%endif
507
Requires: pkgconfig
508
Conflicts: llvm-devel-provider < %{version}
509
%if %{suse_version} <= 1500
510
# llvm{5,7} in SLE/Leap 15.x used to have the man page for FileCheck.
511
Conflicts: llvm5
512
Conflicts: llvm7
513
%endif
514
Conflicts: cmake(LLVM)
515
# libLTO.so used to be a separate package.
516
Conflicts: libLTO.so < %{version}
517
Provides: libLTO.so = %{version}
518
Provides: llvm-devel-provider = %{version}
519
%if %{with ffi}
520
Requires: pkgconfig(libffi)
521
%endif
522
%if %{with valgrind}
523
Requires: pkgconfig(valgrind)
524
%endif
525
%if %{with oprofile}
526
Requires: oprofile-devel
527
%endif
528
529
%description devel
530
This package contains library and header files needed to develop
531
new native programs that use the LLVM infrastructure.
532
533
%package doc
534
Summary: Documentation for LLVM
535
Group: Documentation/HTML
536
Requires: %{name} = %{version}
537
# The docs used to be contained in the devel package.
538
Conflicts: llvm-devel-provider < 9.0.0
539
Conflicts: llvm-doc-provider < %{version}
540
Provides: llvm-doc-provider = %{version}
541
BuildArch: noarch
542
543
%description doc
544
This package contains documentation for the LLVM infrastructure.
545
546
%package -n clang%{_sonum}
547
Summary: CLANG frontend for LLVM
548
Group: Development/Languages/C and C++
549
URL: https://clang.llvm.org/
550
Requires: libclang_rt%{_sonum}
551
Requires(post): update-alternatives
552
Requires(postun): update-alternatives
553
Recommends: clang-tools
554
Recommends: gcc
555
Recommends: glibc-devel
556
Recommends: libstdc++-devel
557
Suggests: clang%{_sonum}-doc
558
Suggests: libc++-devel
559
560
%description -n clang%{_sonum}
561
This package contains the clang (C language) frontend for LLVM.
562
563
%package -n libclang_rt%{_sonum}
564
Summary: Clang shared runtime libraries
565
Group: System/Libraries
566
URL: https://compiler-rt.llvm.org/
567
568
%description -n libclang_rt%{_sonum}
569
The runtime libraries needed to run programs compiled with the -shared-libsan
570
of Clang. Also known as compiler-rt.
571
572
%package -n clang-tools
573
Summary: Tools for Clang
574
Group: Development/Languages/C and C++
575
URL: https://clang-analyzer.llvm.org/
576
# Can be used with older versions of Clang.
577
Requires: /usr/bin/clang
578
# Some binaries used to be in the clang package.
579
Conflicts: clang5
580
Conflicts: clang6
581
# hmaptool used to be contained in the llvm package.
582
Conflicts: llvm5
583
Conflicts: llvm6
584
%if %{suse_version} <= 1500
585
# llvm9 in SLE/Leap 15.x is still affected.
586
Conflicts: llvm9
587
%endif
588
Conflicts: scan-build < %{version}
589
Conflicts: scan-view < %{version}
590
Provides: scan-build = %{version}
591
Provides: scan-view = %{version}
592
Conflicts: emacs-llvm < %{version}
593
Provides: emacs-llvm = %{version}
594
Conflicts: vim-plugin-llvm < %{version}
595
596
%description -n clang-tools
597
This package contains tools and scripts for using Clang, including:
598
* bash completions for clang,
599
* the clang-doc tool,
600
* plugins for using clang-format, clang-include-fixer in vim and emacs.
601
* scripts for using clang-format: git-clang-format and clang-format-diff,
602
* scripts for using clang-tidy: run-clang-tidy and clang-tidy-diff,
603
* scripts for using the Clang static analyzer: scan-build and scan-view,
604
* a script for using find-all-symbols: run-find-all-symbols.
605
606
%package %{multisource libclang%{_soclang}} libclang%{_soclang}
607
Summary: Clang stable C API for indexing and code completion
608
Group: System/Libraries
609
Provides: libclang%{_soclang} = %{version}
610
Conflicts: libclang%{_soclang} < %{version}
611
612
%description %{multisource libclang%{_soclang}} libclang%{_soclang}
613
This library exposes a limited C API for indexing and code completion for
614
code written in languages of the C family.
615
It is designed to be stable across major versions of LLVM.
616
617
It corresponds to the header files in %{_includedir}/clang-c.
618
619
%package -n libclang-cpp%{_sonum}
620
Summary: Clang full C++ API
621
Group: System/Libraries
622
623
%description -n libclang-cpp%{_sonum}
624
This library exposes the full C++ API to Clang that is used to implement
625
all Clang tools. It is not stable across major LLVM versions.
626
627
It corresponds to the header files in %{_includedir}/clang.
628
629
%package -n clang%{_sonum}-devel
630
Summary: CLANG frontend for LLVM (devel package)
631
Group: Development/Libraries/C and C++
632
Requires: %{name}-devel = %{version}
633
Requires: clang%{_sonum} = %{version}
634
Requires: clang-tools >= %{version}
635
Requires: libclang%{_soclang} >= %{version}
636
Requires: libclang-cpp%{_sonum} = %{version}
637
Conflicts: cmake(Clang)
638
639
%description -n clang%{_sonum}-devel
640
This package contains the clang (C language) frontend for LLVM.
641
(development files)
642
643
%package -n clang%{_sonum}-doc
644
Summary: Documentation for Clang
645
Group: Documentation/HTML
646
Conflicts: clang-doc-provider < %{version}
647
# The docs used to be contained in the devel package.
648
Conflicts: clang5-devel
649
Conflicts: clang6-devel
650
Conflicts: clang7-devel
651
Conflicts: clang8-devel
652
Provides: clang-doc-provider = %{version}
653
BuildArch: noarch
654
655
%description -n clang%{_sonum}-doc
656
This package contains documentation for the Clang compiler.
657
658
%package -n libLTO%{_sonum}
659
Summary: Link-time optimizer for LLVM
660
Group: System/Libraries
661
662
%description -n libLTO%{_sonum}
663
This package contains the link-time optimizer for LLVM.
664
665
%package gold
666
Summary: LLVM LTO plugin for ld.bfd and ld.gold
667
Group: Development/Tools/Building
668
Conflicts: llvm-gold-provider < %{version}
669
Provides: llvm-gold-provider = %{version}
670
Supplements: packageand(clang%{_sonum}:binutils)
671
Supplements: packageand(clang%{_sonum}:binutils-gold)
672
673
%description gold
674
This package contains a plugin for link-time optimization in binutils linkers.
675
676
Despite the name, it can also be used with ld.bfd. It is required for using
677
Clang with -flto=full or -flto=thin when linking with one of those linkers.
678
679
%package -n libomp%{_sonum}-devel
680
Summary: MPI plugin for LLVM
681
Group: Development/Libraries/C and C++
682
# Used instead of libomp-devel-provider previously, now a metapackage.
683
Conflicts: libomp-devel < 18
684
Conflicts: libomp-devel-provider < %{version}
685
Provides: libomp-devel-provider = %{version}
686
687
%description -n libomp%{_sonum}-devel
688
This package contains the OpenMP MPI plugin for LLVM.
689
690
%package %{multisource libcxx%{_socxx}} libc++%{_socxx}
691
Summary: C++ standard library implementation
692
Group: System/Libraries
693
URL: https://libcxx.llvm.org/
694
Requires: libc++abi%{_socxx} = %{version}
695
Conflicts: libc++%{_socxx} < %{version}
696
Provides: libc++%{_socxx} = %{version}
697
698
%description %{multisource libcxx%{_socxx}} libc++%{_socxx}
699
This package contains libc++, a new implementation of the C++
700
standard library, targeting C++11.
701
702
%package %{multisource libcxx_devel} libc++-devel
703
Summary: C++ standard library implementation (devel package)
704
Group: Development/Libraries/C and C++
705
Requires: libc++%{_socxx} >= %{version}
706
Requires: libc++abi.so >= %{version}
707
Conflicts: libc++.so < %{version}
708
Provides: libc++.so = %{version}
709
710
%description %{multisource libcxx_devel} libc++-devel
711
This package contains libc++, a new implementation of the C++
712
standard library, targeting C++11. (development files)
713
714
%package %{multisource libcxxabi%{_socxx}} libc++abi%{_socxx}
715
Summary: C++ standard library ABI
716
Group: System/Libraries
717
URL: https://libcxxabi.llvm.org/
718
Conflicts: libc++abi%{_socxx} < %{version}
719
Provides: libc++abi%{_socxx} = %{version}
720
721
%description %{multisource libcxxabi%{_socxx}} libc++abi%{_socxx}
722
This package contains the ABI for libc++, a new implementation
723
of the C++ standard library, targeting C++11.
724
725
%package %{multisource libcxx_devel} libc++abi-devel
726
Summary: C++ standard library ABI (devel package)
727
Group: Development/Libraries/C and C++
728
Requires: libc++abi%{_socxx} >= %{version}
729
Conflicts: libc++abi.so < %{version}
730
Provides: libc++abi.so = %{version}
731
732
%description %{multisource libcxx_devel} libc++abi-devel
733
This package contains the ABI for libc++, a new implementation
734
of the C++ standard library, targeting C++11.
735
(development files)
736
737
%package vim-plugins
738
Summary: Vim plugins for LLVM
739
Group: Productivity/Text/Editors
740
Supplements: packageand(llvm%{_sonum}:vim)
741
Conflicts: vim-plugin-llvm < %{version}
742
Provides: vim-plugin-llvm = %{version}
743
BuildArch: noarch
744
745
%description vim-plugins
746
This package contains vim plugins for LLVM like syntax highlighting.
747
748
%package -n python3-clang%{_sonum}
749
Summary: Python bindings for libclang
750
Group: Development/Libraries/Python
751
Requires: libclang%{_soclang} >= %{version}
752
%if %{suse_version} > 1500
753
Conflicts: %{python_pkg_sitelib}/clang/
754
Provides: %{python_pkg_sitelib}/clang/
755
%else
756
Conflicts: %{python_pkg_sitearch}/clang/
757
Provides: %{python_pkg_sitearch}/clang/
758
%endif
759
BuildArch: noarch
760
761
%description -n python3-clang%{_sonum}
762
This package contains the Python bindings to clang (C language)
763
frontend for LLVM.
764
765
%package -n lld%{_sonum}
766
Summary: Linker for Clang/LLVM
767
Group: Development/Tools/Building
768
URL: https://lld.llvm.org/
769
Requires(post): update-alternatives
770
Requires(postun): update-alternatives
771
772
%description -n lld%{_sonum}
773
LLD is a linker from the LLVM project. That is a drop-in replacement for system linkers and runs much faster than them. It also provides features that are useful for toolchain developers.
774
775
%package opt-viewer
776
Summary: Tools for visualising the LLVM optimization records
777
Group: Development/Languages/Other
778
Requires: %{python_pkg}-PyYAML
779
Requires: %{python_pkg}-Pygments
780
Conflicts: opt-viewer < %{version}
781
Provides: opt-viewer = %{version}
782
BuildArch: noarch
783
784
%description opt-viewer
785
Set of tools for visualising the LLVM optimization records generated with -fsave-optimization-record. Used for compiler-assisted performance analysis.
786
787
%if %{with lldb}
788
%package -n lldb%{_sonum}
789
Summary: Software debugger built using LLVM libraries
790
Group: Development/Tools/Debuggers
791
URL: https://lldb.llvm.org/
792
BuildRequires: %{python_pkg}-devel
793
BuildRequires: pkgconfig
794
BuildRequires: pkgconfig(libedit)
795
BuildRequires: pkgconfig(libffi)
796
BuildRequires: pkgconfig(libxml-2.0)
797
BuildRequires: pkgconfig(ncurses)
798
BuildRequires: pkgconfig(panel)
799
BuildRequires: pkgconfig(zlib)
800
Requires(post): update-alternatives
801
Requires(postun): update-alternatives
802
Recommends: python3-lldb%{_sonum}
803
804
%description -n lldb%{_sonum}
805
LLDB is a next generation, high-performance debugger. It is built as a set
806
of reusable components which highly leverage existing libraries in the
807
larger LLVM Project, such as the Clang expression parser and LLVM
808
disassembler.
809
810
%package -n liblldb%{_sonum}
811
Summary: LLDB software debugger runtime library
812
Group: System/Libraries
813
814
%description -n liblldb%{_sonum}
815
This subpackage contains the main LLDB component.
816
817
%package -n lldb%{_sonum}-devel
818
Summary: Development files for LLDB
819
Group: Development/Libraries/C and C++
820
Requires: clang%{_sonum}-devel = %{version}
821
Requires: liblldb%{_sonum} = %{version}
822
Requires: llvm%{_sonum}-devel = %{version}
823
Requires: pkgconfig(libedit)
824
Requires: pkgconfig(libxml-2.0)
825
Conflicts: lldb-devel-provider < %{version}
826
Provides: lldb-devel-provider = %{version}
827
828
%description -n lldb%{_sonum}-devel
829
This package contains the development files for LLDB.
830
831
%if %{with lldb_python}
832
%package -n python3-lldb%{_sonum}
833
Summary: Python bindings for liblldb
834
Group: Development/Libraries/Python
835
BuildRequires: swig >= 3.0.11
836
Requires: liblldb%{_sonum} = %{version}
837
Conflicts: %{python_pkg_sitearch}/lldb/
838
Provides: %{python_pkg_sitearch}/lldb/
839
840
%description -n python3-lldb%{_sonum}
841
This package contains the Python bindings for LLDB. It also contains
842
pretty printers for the C++ standard library.
843
%endif
844
845
%endif
846
847
%if %{with polly}
848
%package polly
849
Summary: LLVM Framework for High-Level Loop and Data-Locality Optimizations
850
Group: Development/Languages/Other
851
URL: https://polly.llvm.org/
852
Conflicts: llvm-polly-provider < %{version}
853
Provides: llvm-polly-provider = %{version}
854
855
%description polly
856
Polly is a high-level loop and data-locality optimizer and optimization
857
infrastructure for LLVM. It uses an abstract mathematical representation based
858
on integer polyhedra to analyze and optimize the memory access pattern of a
859
program. Polly can currently perform classical loop transformations, especially
860
tiling and loop fusion to improve data-locality. It can also exploit OpenMP
861
level parallelism and expose SIMDization opportunities.
862
863
%package polly-devel
864
Summary: Development files for Polly
865
Group: Development/Libraries/C and C++
866
Requires: llvm%{_sonum}-devel = %{version}
867
Requires: llvm%{_sonum}-polly = %{version}
868
Conflicts: llvm-polly-devel-provider < %{version}
869
Provides: llvm-polly-devel-provider = %{version}
870
871
%description polly-devel
872
This package contains the development files for Polly.
873
%endif
874
875
%prep
876
%setup -q -a 1 -a 2 -a 3 -a 4 -a 5 -a 6 -a 7 -a 8 -a 9 -a 10 -a 11 -a 12 -a 13 -b 50 -b 51 -n llvm-%{_version}.src
877
%patch -P 0 -p2
878
%patch -P 1 -p2
879
%patch -P 13 -p1
880
%patch -P 14 -p1
881
%patch -P 16 -p2
882
%patch -P 17 -p2
883
%patch -P 20 -p1
884
%patch -P 21 -p1
885
%patch -P 24 -p1
886
%patch -P 25 -p2
887
%patch -P 28 -p2
888
889
pushd clang-%{_version}.src
890
%patch -P 2 -p1
891
%patch -P 3 -p1
892
%patch -P 4 -p1
893
%patch -P 6 -p1
894
%patch -P 9 -p2
895
%patch -P 27 -p2
896
897
# We hardcode openSUSE
898
rm unittests/Driver/DistroTest.cpp
899
900
# We hardcode i586
901
rm test/Driver/x86_features.c
902
rm test/Driver/nacl-direct.c
903
popd
904
905
pushd clang-tools-extra-%{_version}.src
906
%patch -P 10 -p2
907
popd
908
909
pushd lld-%{_version}.src
910
# lld got a compile-time dependency on libunwind that we don't want. (https://reviews.llvm.org/D86805)
911
mkdir include/mach-o
912
cp %{SOURCE14} include/mach-o
913
popd
914
915
%if %{with lldb}
916
pushd lldb-%{_version}.src
917
%patch -P 11 -p1
918
popd
919
%endif
920
921
sed -i '/set(LLVM_COMMON_CMAKE_UTILS/ s/CMAKE_CURRENT_SOURCE_DIR/CMAKE_SOURCE_DIR/g' {runtimes,compiler-rt}-%{_version}.src/CMakeLists.txt \
922
%if %{with libcxx}
923
libcxx{,abi}-%{_version}.src/CMakeLists.txt
924
sed -i '\"runtimes/cmake/Modules" s/CMAKE_CURRENT_SOURCE_DIR/CMAKE_SOURCE_DIR/g' libcxx{,abi}-%{_version}.src/CMakeLists.txt
925
pushd libcxx-%{_version}.src
926
%patch -P 15 -p2
927
rm test/libcxx/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp
928
rm test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp
929
rm test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp
930
931
# These tests often verify timing and can randomly fail if the system is under heavy load. It happens sometimes on our build machines.
932
rm -rf test/std/thread/
933
popd
934
%endif
935
936
# Move into right place
937
mv cmake-%{_version}.src ../cmake
938
mv clang-%{_version}.src tools/clang
939
mv compiler-rt-%{_version}.src projects/compiler-rt
940
mv clang-tools-extra-%{_version}.src tools/clang/tools/extra
941
%if %{with lld}
942
mv lld-%{_version}.src tools/lld
943
%endif
944
%if %{with polly}
945
mv polly-%{_version}.src tools/polly
946
%endif
947
948
%if %{with lldb}
949
mv lldb-%{_version}.src tools/lldb
950
%endif
951
952
%if %{with openmp}
953
mv openmp-%{_version}.src projects/openmp
954
%endif
955
956
%if %{with libcxx}
957
mv libc-%{_version}.src ../libc
958
mv libcxx-%{_version}.src projects/libcxx
959
mv libcxxabi-%{_version}.src projects/libcxxabi
960
%endif
961
962
mv runtimes-%{_version}.src ../runtimes
963
mv third-party-%{_version}.src ../third-party
964
965
%build
966
%global sourcedir %{_builddir}/%{buildsubdir}
967
968
%define _lto_cflags %{nil}
969
970
# Use optflags, but:
971
# 1) Remove the -D_FORTIFY_SOURCE=2 because llvm does not build correctly with
972
# hardening. The problem is in sanitizers from compiler-rt.
973
# 2) Remove the -g. We don't want it in stage1 and it will be added by cmake in
974
# the following stage.
975
%global cleaned_flags %(echo %{optflags} | sed 's/-D_FORTIFY_SOURCE=./-D_FORTIFY_SOURCE=0/;s/\\B-g\\b//g')
976
977
%global flags %{cleaned_flags}
978
%ifarch armv6hl
979
%global flags %{cleaned_flags} -mfloat-abi=hard -mcpu=arm1176jzf-s -mfpu=vfpv2
980
%endif
981
%ifarch armv7hl
982
%global flags %{cleaned_flags} -mfloat-abi=hard -march=armv7-a -mtune=cortex-a17 -mfpu=vfpv3-d16
983
%endif
984
985
CFLAGS="%flags"
986
CXXFLAGS="%flags"
987
988
mem_per_compile_job=1200000
989
%ifarch i586 ppc armv6hl armv7hl
990
# 32-bit arches need less memory than 64-bit arches.
991
mem_per_compile_job=700000
992
%endif
993
994
mem_per_link_job=3000000
995
%ifarch riscv64
996
# Give RISCV link jobs more memory.
997
mem_per_link_job=4000000
998
%endif
999
1000
echo "Available memory:"
1001
cat /proc/meminfo
1002
echo "System limits:"
1003
ulimit -a
1004
avail_mem=$(awk '/MemAvailable/ { print $2 }' /proc/meminfo)
1005
%set_jobs link $mem_per_link_job
1006
%set_jobs compile $mem_per_compile_job
1007
1008
%define __builder ninja
1009
%define __builddir stage1
1010
%define build_ldflags -Wl,--no-keep-memory
1011
%cmake \
1012
-DCMAKE_BUILD_TYPE=Release \
1013
-DCMAKE_C_COMPILER=gcc%{?gcc_version:-%{gcc_version}} \
1014
-DCMAKE_CXX_COMPILER=g++%{?gcc_version:-%{gcc_version}} \
1015
-DBUILD_SHARED_LIBS:BOOL=OFF \
1016
-DLLVM_HOST_TRIPLE=%{host_triple} \
1017
-DLLVM_BUILD_LLVM_DYLIB:BOOL=OFF \
1018
-DLLVM_LINK_LLVM_DYLIB:BOOL=OFF \
1019
-DLLVM_PARALLEL_COMPILE_JOBS="$max_compile_jobs" \
1020
-DLLVM_PARALLEL_LINK_JOBS="$max_link_jobs" \
1021
-DENABLE_LINKER_BUILD_ID=ON \
1022
-DLLVM_BINUTILS_INCDIR=%{_includedir} \
1023
-DPython3_EXECUTABLE=%{_bindir}/%{python_bin} \
1024
-DLLVM_BUILD_TOOLS:BOOL=OFF \
1025
-DLLVM_BUILD_UTILS:BOOL=OFF \
1026
-DLLVM_BUILD_EXAMPLES:BOOL=OFF \
1027
-DLLVM_BUILD_RUNTIME:BOOL=OFF \
1028
-DLLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD:BOOL=OFF \
1029
-DLLVM_INCLUDE_BENCHMARKS:BOOL=OFF \
1030
-DLLVM_INCLUDE_TESTS:BOOL=OFF \
1031
-DLLVM_TARGETS_TO_BUILD=Native \
1032
-DCLANG_ENABLE_ARCMT:BOOL=OFF \
1033
-DCLANG_ENABLE_STATIC_ANALYZER:BOOL=OFF
1034
ninja -v %{?_smp_mflags} clang llvm-tblgen clang-tblgen \
1035
%if %{with thin_lto}
1036
llvm-ar llvm-ranlib \
1037
%if %{with use_lld}
1038
lld
1039
%else
1040
LLVMgold
1041
%endif
1042
%endif
1043
1044
cd ..
1045
1046
# Remove files that won't be needed anymore.
1047
# This reduces the total amount of disk space used during build. (bnc#1074625)
1048
find ./stage1 \( -name '*.o' -or -name '*.a' \) -delete
1049
1050
# 3) Remove -fstack-clash-protection on architectures where it isn't supported.
1051
# Using it just prints a warning, but that warning prevents the configuration
1052
# step, which uses -Werror, from recognizing the availability of other flags.
1053
if ! ./stage1/bin/clang -c -xc -Werror -fstack-clash-protection -o /dev/null /dev/null;
1054
then
1055
flags=$(echo %flags | sed 's/-fstack-clash-protection//');
1056
fi
1057
# 4) Add -fno-plt: With -Wl,-z,now the PLT is basically dead code, so we can
1058
# now go the direct route for quite frequent cross-DSO calls. This reduces
1059
# branches in a typical execution by ~5 percent, instructions/cycles
1060
# by ~4 percent, and reduces pressure on the instruction cache. We do this
1061
# only on x86_64 where it doesn't increase the code size significantly.
1062
%ifarch x86_64
1063
flags="$flags -fno-plt"
1064
%endif
1065
1066
CFLAGS=$flags
1067
CXXFLAGS=$flags
1068
1069
# Clang uses a bit less memory.
1070
mem_per_compile_job=700000
1071
%ifarch %{arm} i586 ppc
1072
# 32-bit arches need less memory than 64-bit arches.
1073
mem_per_compile_job=500000
1074
%endif
1075
1076
%set_jobs compile $mem_per_compile_job
1077
%if %{with thin_lto}
1078
# A single ThinLTO job is fully parallel already.
1079
max_link_jobs=1
1080
%endif
1081
1082
%define __builddir build
1083
%if %{with thin_lto} && %{with use_lld}
1084
%global lld_ldflag --ld-path=%{sourcedir}/stage1/bin/ld.lld
1085
%ifarch %{arm} i586 ppc
1086
%if %{jobs} > 8
1087
%global lto_limit_threads -Wl,--thinlto-jobs=8
1088
%endif
1089
%endif
1090
%endif
1091
%define build_ldflags -Wl,--build-id=sha1 %{?lld_ldflag} %{?lto_limit_threads}
1092
# The build occasionally uses tools linking against previously built
1093
# libraries (mostly libLLVM.so), but we don't want to set RUNPATHs.
1094
export LD_LIBRARY_PATH=%{sourcedir}/build/%{_lib}
1095
%cmake \
1096
-DCMAKE_C_COMPILER="%{sourcedir}/stage1/bin/clang" \
1097
-DCMAKE_CXX_COMPILER="%{sourcedir}/stage1/bin/clang++" \
1098
-DBUILD_SHARED_LIBS:BOOL=OFF \
1099
-DLLVM_HOST_TRIPLE=%{host_triple} \
1100
-DLLVM_BUILD_LLVM_DYLIB:BOOL=ON \
1101
-DLLVM_LINK_LLVM_DYLIB:BOOL=ON \
1102
-DCLANG_LINK_CLANG_DYLIB:BOOL=ON \
1103
-DLLVM_PARALLEL_COMPILE_JOBS="$max_compile_jobs" \
1104
-DLLVM_PARALLEL_LINK_JOBS="$max_link_jobs" \
1105
%if %{with thin_lto}
1106
-DLLVM_ENABLE_LTO=Thin \
1107
-DCMAKE_AR="%{sourcedir}/stage1/bin/llvm-ar" \
1108
-DCMAKE_RANLIB="%{sourcedir}/stage1/bin/llvm-ranlib" \
1109
%endif
1110
%ifarch %arm ppc s390 %{ix86}
1111
-DCMAKE_C_FLAGS_RELWITHDEBINFO="-O2 -g1 -DNDEBUG" \
1112
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2 -g1 -DNDEBUG" \
1113
%endif
1114
-DENABLE_LINKER_BUILD_ID=ON \
1115
-DLLVM_TABLEGEN="%{sourcedir}/stage1/bin/llvm-tblgen" \
1116
-DCLANG_TABLEGEN="%{sourcedir}/stage1/bin/clang-tblgen" \
1117
-DLLVM_ENABLE_RTTI:BOOL=ON \
1118
-DLLVM_ENABLE_PIC=ON \
1119
-DLLVM_BINUTILS_INCDIR=%{_includedir} \
1120
-DPython3_EXECUTABLE=%{_bindir}/%{python_bin} \
1121
-DLLVM_TARGETS_TO_BUILD=%{llvm_targets} \
1122
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=%{llvm_experimental_targets} \
1123
-DLLVM_TOOL_LLVM_EXEGESIS_BUILD:BOOL=OFF \
1124
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR:BOOL=OFF \
1125
-DLLVM_INCLUDE_BENCHMARKS:BOOL=OFF \
1126
-DCLANG_FORCE_MATCHING_LIBCLANG_SOVERSION:BOOL=OFF \
1127
-DCLANG_CONFIG_FILE_SYSTEM_DIR="%{_sysconfdir}/clang" \
1128
-DCLANG_CONFIG_FILE_USER_DIR="~/.config/clang" \
1129
-DCOMPILER_RT_USE_LIBCXX:BOOL=OFF \
1130
-DLIBCXX_INCLUDE_BENCHMARKS:BOOL=OFF \
1131
%if %{with libcxx}
1132
-DLIBCXX_ENABLE_SHARED=YES \
1133
-DLIBCXX_ENABLE_STATIC=NO \
1134
-DLIBCXX_INSTALL_MODULES=ON \
1135
-DLIBCXXABI_ENABLE_SHARED=YES \
1136
-DLIBCXXABI_ENABLE_STATIC=NO \
1137
-DLIBCXXABI_USE_LLVM_UNWINDER:BOOL=OFF \
1138
%endif
1139
%if "%{_lib}" == "lib64"
1140
-DLLVM_LIBDIR_SUFFIX=64 \
1141
%endif
1142
%if %{with ffi}
1143
-DLLVM_ENABLE_FFI=ON \
1144
%endif
1145
%if %{with oprofile}
1146
-DLLVM_USE_OPROFILE=ON \
1147
%endif
1148
%if %{without lldb_python}
1149
-DLLDB_DISABLE_PYTHON=ON \
1150
%endif
1151
-DLIBOMP_OMPD_GDB_SUPPORT:BOOL=OFF \
1152
-DCMAKE_SKIP_RPATH:BOOL=ON \
1153
-DLLVM_POLLY_LINK_INTO_TOOLS=OFF \
1154
-DPOLLY_BUNDLED_ISL:BOOL=ON
1155
1156
# ThinLTO uses multiple threads from the linker process for optimizations, which
1157
# causes an extremely high lock contention on allocations due to MALLOC_CHECK_,
1158
# so we deactivate it for compilation. The tests will have it activated again.
1159
%if %{with thin_lto}
1160
MALLOC_CHECK_BACK=$MALLOC_CHECK_
1161
unset MALLOC_CHECK_
1162
%endif
1163
1164
ninja -v %{?_smp_mflags}
1165
1166
%if %{with thin_lto}
1167
MALLOC_CHECK_=$MALLOC_CHECK_BACK
1168
%endif
1169
1170
cd ..
1171
1172
%install
1173
# Installation seems to build some files not contained in "all".
1174
export LD_LIBRARY_PATH=%{sourcedir}/build/%{_lib}
1175
%cmake_install
1176
1177
# Install FileCheck needed for testing Rust boo#1192629
1178
install -m 0755 build/bin/FileCheck %{buildroot}%{_bindir}/FileCheck
1179
1180
# Remove files that won't be needed anymore.
1181
# This reduces the total amount of disk space used during build. (bnc#1074625)
1182
find ./build \( -name '*.o' -or -name '*.a' \) -delete
1183
1184
# Docs are prebuilt due to sphinx dependency
1185
#
1186
# tar xf cmake-%{_version}.src.tar.xz
1187
# mv cmake-%{_version}.src cmake
1188
# tar xf llvm-%{_version}.src.tar.xz
1189
# pushd llvm-%{_version}.src/tools
1190
# tar xf ../../clang-%{_version}.src.tar.xz
1191
# mv clang-%{_version}.src clang
1192
# cd ..
1193
# ln -s ../../../build/tools/clang/docs/{Attribute,Diagnostics}Reference.rst tools/clang/docs
1194
# mkdir build; cd build
1195
# cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_SPHINX:BOOL=ON -DLLVM_BUILD_DOCS:BOOL=ON \
1196
# -DSPHINX_WARNINGS_AS_ERRORS:BOOL=OFF -DLLVM_INCLUDE_TESTS:BOOL=OFF -DLLVM_INCLUDE_BENCHMARKS:BOOL=OFF ..
1197
# ninja gen-{Attribute,Diagnostics}Reference.rst
1198
# ninja -j1 docs-{llvm,clang}-{html,man}
1199
# popd
1200
# tar --sort=name --owner=0 --group=0 --mtime="@${SOURCE_DATE_EPOCH}" \
1201
# --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime \
1202
# -cJf llvm-docs-%{_version}.src.tar.xz llvm-%{_version}.src/build/docs/{man,html}
1203
# tar --sort=name --owner=0 --group=0 --mtime="@${SOURCE_DATE_EPOCH}" \
1204
# --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime \
1205
# -cJf clang-docs-%{_version}.src.tar.xz llvm-%{_version}.src/build/tools/clang/docs/{man,html}
1206
1207
# Build man/html pages
1208
pushd build/docs
1209
rm -rf %{buildroot}%{_prefix}/docs
1210
mkdir -p %{buildroot}%{_docdir}/llvm
1211
mkdir -p %{buildroot}%{_mandir}/man1
1212
cp -r man/* %{buildroot}%{_mandir}/man1
1213
cp -r html/* %{buildroot}%{_docdir}/llvm
1214
rm -r %{buildroot}%{_docdir}/llvm/_sources
1215
popd
1216
1217
pushd build/tools/clang/docs
1218
mkdir -p %{buildroot}%{_docdir}/llvm-clang
1219
cp -r man/* %{buildroot}%{_mandir}/man1
1220
cp -r html/* %{buildroot}%{_docdir}/llvm-clang
1221
rm -r %{buildroot}%{_docdir}/llvm-clang/_sources
1222
popd
1223
1224
# install python bindings
1225
install -d %{buildroot}%{python_pkg_sitelib}/clang
1226
pushd tools/clang/bindings/python
1227
cp clang/*.py %{buildroot}%{python_pkg_sitelib}/clang
1228
# Make the bindings use the current so number, so that we don't need an unversioned libclang.so.
1229
sed -i "s/file = 'libclang\.so'/file = 'libclang.so.%{_soclang}'/" %{buildroot}%{python_pkg_sitelib}/clang/cindex.py
1230
install -d %{buildroot}%{_docdir}/python-clang/examples/cindex
1231
cp -r examples %{buildroot}%{_docdir}/python-clang
1232
install -d %{buildroot}%{_docdir}/python-clang/tests/cindex/INPUTS
1233
cp -r tests %{buildroot}%{_docdir}/python-clang
1234
popd
1235
1236
# Scripts for clang use unversioned executables, so it doesn't make sense to
1237
# have multiple versions of them. We package them only for the default version.
1238
%if %{_plv} == %{_sonum}
1239
mv %{buildroot}%{_datadir}/clang/clang-format-diff.py %{buildroot}%{_bindir}/clang-format-diff
1240
mv %{buildroot}%{_datadir}/clang/clang-tidy-diff.py %{buildroot}%{_bindir}/clang-tidy-diff
1241
mv %{buildroot}%{_datadir}/clang/run-find-all-symbols.py %{buildroot}%{_bindir}/run-find-all-symbols
1242
1243
# Fix paths to internal binaries.
1244
sed -i "s|COMPILER_WRAPPER_\([A-Z]*\) = 'intercept-\([^']*\)'|COMPILER_WRAPPER_\1 = '%{_libexecdir}/intercept-\2'|" \
1245
%{buildroot}%{_prefix}/lib/libscanbuild/intercept.py
1246
%if "%{_libexecdir}" != "%{_prefix}/libexec"
1247
LIBEXEC=%{_libexecdir}
1248
RELATIVE_LIBEXEC=${LIBEXEC#%{_prefix}/}
1249
sed -i "s|\$AbsRealBin/../libexec/\([^-]*\)-analyzer|\$AbsRealBin/../$RELATIVE_LIBEXEC/\1-analyzer|" \
1250
%{buildroot}%{_bindir}/scan-build
1251
RELATIVE_LIBEXEC_COMMA=${RELATIVE_LIBEXEC//\//\', \'}
1252
sed -i "s|os.path.join(scanbuild_dir, '..', 'libexec', 'analyze-\([^']*\)')|os.path.join(scanbuild_dir, '..', '$RELATIVE_LIBEXEC_COMMA', 'analyze-\1')|" \
1253
%{buildroot}%{_prefix}/lib/libscanbuild/analyze.py
1254
%endif
1255
1256
mkdir -p %{buildroot}%{_datadir}/bash-completion/completions
1257
mv %{buildroot}%{_datadir}/clang/bash-autocomplete.sh %{buildroot}%{_datadir}/bash-completion/completions/clang
1258
1259
# We don't care about applescript or sublime text
1260
rm %{buildroot}%{_datadir}/clang/*.applescript
1261
rm %{buildroot}%{_datadir}/clang/clang-format-sublime.py
1262
%else
1263
rm %{buildroot}%{_bindir}/{analyze,intercept}-build
1264
rm %{buildroot}%{_bindir}/clang-doc
1265
rm %{buildroot}%{_bindir}/git-clang-format
1266
rm %{buildroot}%{_bindir}/hmaptool
1267
rm %{buildroot}%{_bindir}/run-clang-tidy
1268
rm %{buildroot}%{_bindir}/scan-{build,build-py,view}
1269
rm -r %{buildroot}%{_prefix}/lib/lib{ear,scanbuild}
1270
rm %{buildroot}%{_libexecdir}/{c++,ccc}-analyzer
1271
rm %{buildroot}%{_libexecdir}/{analyze,intercept}-{cc,c++}
1272
rm -r %{buildroot}%{_datadir}/{clang,clang-doc,scan-build,scan-view}/
1273
rm %{buildroot}%{_mandir}/man1/scan-build.1
1274
%endif
1275
1276
# Note that bfd-plugins is in /usr/lib/bfd-plugins before binutils 2.33.1
1277
mkdir -p %{buildroot}%{_libdir}/bfd-plugins
1278
ln -s %{_libdir}/LLVMgold.so %{buildroot}%{_libdir}/bfd-plugins/
1279
1280
install -m 755 -d %{buildroot}%{_datadir}/vim/site/
1281
for i in ftdetect ftplugin indent syntax; do
1282
cp -r utils/vim/$i %{buildroot}%{_datadir}/vim/site/
1283
done
1284
mv utils/vim/README utils/vim/README.vim
1285
1286
install -d %{buildroot}%{python_pkg_sitelib}
1287
mv %{buildroot}%{_datadir}/opt-viewer/opt-diff.py %{buildroot}%{_bindir}/opt-diff
1288
mv %{buildroot}%{_datadir}/opt-viewer/opt-stats.py %{buildroot}%{_bindir}/opt-stats
1289
mv %{buildroot}%{_datadir}/opt-viewer/opt-viewer.py %{buildroot}%{_bindir}/opt-viewer
1290
mv %{buildroot}%{_datadir}/opt-viewer/optpmap.py %{buildroot}%{python_pkg_sitelib}/optpmap.py
1291
mv %{buildroot}%{_datadir}/opt-viewer/optrecord.py %{buildroot}%{python_pkg_sitelib}/optrecord.py
1292
1293
rm %{buildroot}%{_mandir}/man1/{,clang-,lldb-,mlir-}tblgen.1
1294
rm %{buildroot}%{_mandir}/man1/llvm-{exegesis,locstats}.1
1295
1296
%if %{with lldb_python}
1297
# Python: fix binary libraries location.
1298
%global cpython_pkg_soabi %(%{python_bin} -c "import sysconfig; print(sysconfig.get_config_var('SOABI'))")
1299
# TODO: SMAR NOTE: This rm failed. I think this gets picked up for something else...
1300
#rm %%{buildroot}%%{python_pkg_sitearch}/lldb/_lldb.%%{cpython_pkg_soabi}.so
1301
#liblldb=$(basename $(readlink -e %{buildroot}%{_libdir}/liblldb.so))
1302
#ln -vsf "../../../${liblldb}" %{buildroot}%{python3_sitearch}/lldb/_lldb.%{cpython_pkg_soabi}.so
1303
%endif
1304
1305
# Stuff we don't want to include
1306
rm %{buildroot}%{_includedir}/mach-o/compact_unwind_encoding.h
1307
rm %{buildroot}%{_mandir}/man1/lit.1
1308
1309
# These are only available as static libraries, which we don't ship.
1310
rm -rf %{buildroot}%{_includedir}/{clang-tidy,lld}
1311
rm -rf %{buildroot}%{_libdir}/cmake/lld/
1312
1313
%if %{with openmp}
1314
rm %{buildroot}%{_libdir}/libgomp.so*
1315
rm %{buildroot}%{_libdir}/libiomp*.so
1316
rm %{buildroot}%{_libdir}/libarcher_static.a
1317
%endif
1318
1319
# Prepare for update-alternatives usage
1320
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
1321
1322
# For installing lld as ld alternative.
1323
ln -s %{_sysconfdir}/alternatives/ld %{buildroot}%{_bindir}/ld
1324
1325
# Fix the clang -> clang-X symlink to work with update-alternatives
1326
mv %{buildroot}%{_bindir}/clang-%{_sonum} %{buildroot}%{_bindir}/clang
1327
1328
# Rewrite symlinks to point to new location
1329
for p in %{shrink:%binfiles} ; do
1330
if [ -h "%{buildroot}%{_bindir}/$p" ] ; then
1331
ln -f -s %{_bindir}/$(readlink %{buildroot}%{_bindir}/$p)-%{_sonum} %{buildroot}%{_bindir}/$p
1332
fi
1333
done
1334
for p in %{shrink:%binfiles} ; do
1335
mv %{buildroot}%{_bindir}/$p %{buildroot}%{_bindir}/$p-%{_sonum}
1336
ln -s -f %{_sysconfdir}/alternatives/$p %{buildroot}%{_bindir}/$p
1337
done
1338
for p in %{shrink:%manfiles} ; do
1339
mv %{buildroot}%{_mandir}/man1/$p.1 %{buildroot}%{_mandir}/man1/$p-%{_sonum}.1
1340
ln -s -f %{_sysconfdir}/alternatives/$p.1%{ext_man} %{buildroot}%{_mandir}/man1/$p.1%{ext_man}
1341
done
1342
1343
# Also rewrite the CMake files referring to the binaries.
1344
sed -i "$(
1345
for p in %{shrink:%binfiles}; do
1346
echo "s|\"\${_IMPORT_PREFIX}/bin/$p\"|\"\${_IMPORT_PREFIX}/bin/$p-%{_sonum}\"|g"
1347
done
1348
)" %{buildroot}%{_libdir}/cmake/{llvm/LLVMExports,clang/ClangTargets}-relwithdebinfo.cmake
1349
1350
# For libclang, have the CMake export list refer to the library via soname.
1351
# The original library might not be available. (We might have a newer version.)
1352
sed -i "s|\"\${_IMPORT_PREFIX}/%{_lib}/libclang.so.%{_version}\"|\"\${_IMPORT_PREFIX}/%{_lib}/libclang.so.%{_soclang}\"|g" \
1353
%{buildroot}%{_libdir}/cmake/clang/ClangTargets-relwithdebinfo.cmake
1354
1355
# rpm macro for version checking
1356
mkdir -p %{buildroot}%{_rpmconfigdir}/macros.d/
1357
cat > %{buildroot}%{_rpmconfigdir}/macros.d/macros.llvm <<EOF
1358
#
1359
# RPM macros for LLVM/Clang packaging
1360
#
1361
1362
# Version information
1363
%_llvm_version %{version}
1364
%_llvm_relver %{_relver}
1365
%_llvm_minorver %{_minor}
1366
%_llvm_sonum %{_sonum}
1367
%_libclang_sonum %{_soclang}
1368
%_libcxx_sonum %{_socxx}
1369
1370
# Build information
1371
%_llvm_with_libcxx %{with libcxx}
1372
%_llvm_with_openmp %{with openmp}
1373
%_llvm_with_ffi %{with ffi}
1374
%_llvm_with_oprofile %{with oprofile}
1375
%_llvm_with_valgrind %{with valgrind}
1376
%_llvm_with_lldb %{with lldb}
1377
EOF
1378
1379
# Don't use env in shebangs, and prefer python3.X. (https://www.python.org/dev/peps/pep-0394/#for-python-runtime-distributors)
1380
sed -i -E "1s|/usr/bin/env *|/usr/bin/|; 1s|/usr/bin/python3?\$|$(realpath /usr/bin/%{python_bin})|" \
1381
%if %{_plv} == %{_sonum}
1382
%{buildroot}%{_bindir}/{{analyze,intercept}-build,clang-{format,tidy}-diff,git-clang-format,hmaptool,run-{clang-tidy,find-all-symbols},scan-{build,build-py,view}} \
1383
%{buildroot}%{_libexecdir}/{{analyze,intercept}-{c++,cc},{c++,ccc}-analyzer} \
1384
%endif
1385
%ifarch aarch64 x86_64
1386
%{buildroot}%{_libdir}/clang/%{_sonum}/bin/hwasan_symbolize \
1387
%endif
1388
%{buildroot}%{_bindir}/opt-{diff,stats,viewer}
1389
1390
# Remove shebangs where not needed.
1391
sed -i '1{ /^#!/d }' \
1392
%if %{_plv} == %{_sonum}
1393
%{buildroot}%{_datadir}/scan-view/{Reporter,startfile}.py \
1394
%endif
1395
%if %{with lldb_python}
1396
%{buildroot}%{python_pkg_sitearch}/lldb/utils/{in_call_stack,symbolication}.py \
1397
%endif
1398
%{buildroot}%{python_pkg_sitelib}/optrecord.py
1399
1400
# Remove executable bit where not needed.
1401
chmod -x \
1402
%{buildroot}%{python_pkg_sitelib}/opt{pmap,record}.py \
1403
%{buildroot}%{_datadir}/opt-viewer/style.css \
1404
%if %{_plv} == %{_sonum}
1405
%{buildroot}%{_datadir}/bash-completion/completions/clang \
1406
%{buildroot}%{_datadir}/clang/clang-{format,include-fixer}.{el,py} \
1407
%{buildroot}%{_mandir}/man1/scan-build.1
1408
find %{buildroot}%{_prefix}/lib/{libear,libscanbuild} -type f -executable -exec chmod -x {} +
1409
%endif
1410
1411
%fdupes -s %{buildroot}%{_docdir}/llvm
1412
%fdupes -s %{buildroot}%{_docdir}/llvm-clang
1413
%fdupes %{_includedir}/%{name}/Host/
1414
1415
%check
1416
# We don't want to set RUNPATHs, and running tests against installed libraries
1417
# should be more representative of the actual behavior of the installed packages.
1418
export LD_LIBRARY_PATH=%{buildroot}%{_libdir}
1419
# LLVM test suite is written in python and has troubles with encoding if
1420
# python 3 is used because it is written with assumption that python will
1421
# default to UTF-8 encoding. However, it only does if the current locale is
1422
# UTF-8.
1423
export LANG=C.UTF-8
1424
1425
# NOTE: We're not running the tests via ninja, because we've removed object
1426
# files and static libraries already.
1427
pushd build
1428
%if !0%{?qemu_user_space_build}
1429
# we just do not have enough memory with qemu emulation
1430
1431
# We don't build llvm-exegesis.
1432
rm -r ../test/tools/llvm-exegesis
1433
# On armv6l, fpext frem(12.0f, 5.0f) to double = inf for some reason. On ppc relocation errors.
1434
sed -i '1i; XFAIL: target=armv6{{.*}}, target=powerpc-{{.*}}' ../test/ExecutionEngine/MCJIT/frem.ll
1435
# Disable tests that seem to hang (armv6) or fail with relocation errors (ppc).
1436
sed -i '1i; UNSUPPORTED: target=armv6{{.*}}' ../test/{CodeGen/Generic/PBQP.ll,ExecutionEngine/Orc/global-ctor-with-cast.ll}
1437
sed -i '1i; UNSUPPORTED: target=armv6{{.*}}\n; XFAIL: target=powerpc-{{.*}}' \
1438
../test/ExecutionEngine/MCJIT/{mov64zext32,test-interp-vec-{arithm_{float,int},logical,setcond-{fp,int}}}.ll
1439
# WebAssembly tests seem to require x86. (https://github.com/llvm/llvm-project/issues/106876)
1440
sed -i 's/REQUIRES: webassembly-registered-target/REQUIRES: webassembly-registered-target,x86-registered-target/' \
1441
../test/tools/llvm-debuginfo-analyzer/WebAssembly/{01-wasm-compare-logical-elements,01-wasm-select-logical-elements,03-wasm-incorrect-lexical-scope-typedef,04-wasm-missing-nested-enumerators,05-wasm-incorrect-lexical-scope-variable}.test
1442
%ifarch ppc64le
1443
# Sporadic failures, possibly races?
1444
rm ../test/tools/llvm-cov/{multithreaded-report,sources-specified}.test
1445
%endif
1446
%{python_bin} bin/llvm-lit -sv test/
1447
1448
# TODO: investigate!
1449
sed -i '1i// XFAIL: *' ../tools/clang/test/Driver/linux-ld.c
1450
# On ppc, these tests fails with "fatal error: error in backend: Relocation type not implemented yet!"
1451
sed -i '1i// XFAIL: target=powerpc-{{.*}}' ../tools/clang/test/Interpreter/{code-undo,execute{,-stmts,-weak},fail,global-dtor,lambda,simple-exception}.cpp
1452
# Tests hang on armv6l.
1453
sed -i '1i// UNSUPPORTED: target=armv6{{.*}}' \
1454
../tools/clang/test/{Interpreter/{code-undo,execute,execute-weak}.cpp,Modules/{preprocess-{build-diamond.m,decluse.cpp,module.cpp},string_names.cpp}}
1455
%ifarch ppc64le
1456
# Sporadic failures, possibly races?
1457
rm -r ../tools/clang/test/ClangScanDeps
1458
%endif
1459
%{python_bin} bin/llvm-lit -sv --param clang_site_config=tools/clang/test/lit.site.cfg \
1460
--param USE_Z3_SOLVER=0 tools/clang/test/
1461
1462
# The implementation of abseil-duration-factory-scale breaks with extended
1463
# precision, and the Altera test assumes 8-byte alignment for double.
1464
sed -i '1i// XFAIL: target=i586-{{.*}}' ../tools/clang/tools/extra/test/clang-tidy/checkers/{abseil/duration-factory-scale.cpp,altera/struct-pack-align.cpp}
1465
# Test expects the monorepo layout.
1466
sed -i 's#clang-tools-extra#tools/clang/tools/extra#g' ../tools/clang/tools/extra/test/clang-doc/{enum,namespace}.cpp
1467
%{python_bin} bin/llvm-lit -sv tools/clang/tools/extra/test/
1468
%{python_bin} bin/llvm-lit -sv tools/clang/tools/extra/clangd/test/
1469
1470
%{python_bin} bin/llvm-lit -sv tools/lld/test/
1471
1472
%if %{with libcxx}
1473
# libcxx tests run too long for what they're worth to us.
1474
# So let's just run them for new versions only.
1475
%if 0
1476
# FIXME: investigate those
1477
sed -i '1i# XFAIL: *' ../projects/libcxx/test/libcxx/selftest/dsl/dsl.sh.py
1478
# Several tests seem to hang on armv6l.
1479
sed -i '1i// UNSUPPORTED: target=armv6{{.*}}' \
1480
../projects/libcxx/test/libcxx/utilities/memory/util.smartptr/race_condition.pass.cpp \
1481
../projects/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.{enab/enable_shared_from_this,shared/util.smartptr.shared.const/{deduction,weak_ptr},weak/util.smartptr.weak.{const/shared_ptr_deduction,mod/swap,obs/lock,spec/swap}}.pass.cpp
1482
# No support for std::strong_order on long double for armv{6,7}.
1483
sed -i '1i// XFAIL: target=armv{{(6|7).*}}' ../projects/libcxx/test/std/language.support/cmp/cmp.alg/strong_order_long_double.verify.cpp
1484
%{python_bin} bin/llvm-lit -sv --param enable_experimental=False projects/libcxx/test/
1485
1486
# There are undefined references to __cxa_* functions and "typeinfo for int".
1487
sed -i '1i@ XFAIL: target=arm{{.*}}' ../projects/libcxxabi/test/native/arm-linux-eabi/ttype-encoding-{0,9}0.pass.sh.s
1488
%{python_bin} bin/llvm-lit -sv projects/libcxxabi/test/
1489
%endif
1490
%endif
1491
%endif
1492
popd
1493
1494
# Remove files that won't be needed anymore.
1495
# This reduces the total amount of disk space used during build. (bnc#1074625)
1496
# This is meant to happen after build, install and check, but before
1497
# creating the final RPMs.
1498
rm -rf ./stage1 ./build
1499
1500
%post -n libLLVM%{_sonum} -p /sbin/ldconfig
1501
%postun -n libLLVM%{_sonum} -p /sbin/ldconfig
1502
%post %{multisource libclang%{_soclang}} libclang%{_soclang} -p /sbin/ldconfig
1503
%postun %{multisource libclang%{_soclang}} libclang%{_soclang} -p /sbin/ldconfig
1504
%post -n libclang-cpp%{_sonum} -p /sbin/ldconfig
1505
%postun -n libclang-cpp%{_sonum} -p /sbin/ldconfig
1506
%post -n libLTO%{_sonum} -p /sbin/ldconfig
1507
%postun -n libLTO%{_sonum} -p /sbin/ldconfig
1508
%post -n clang%{_sonum}-devel -p /sbin/ldconfig
1509
%postun -n clang%{_sonum}-devel -p /sbin/ldconfig
1510
1511
%if %{with lldb}
1512
%post -n liblldb%{_sonum} -p /sbin/ldconfig
1513
%postun -n liblldb%{_sonum} -p /sbin/ldconfig
1514
%endif
1515
1516
%post gold -p /sbin/ldconfig
1517
%postun gold -p /sbin/ldconfig
1518
%post devel -p /sbin/ldconfig
1519
%postun devel -p /sbin/ldconfig
1520
1521
%if %{with openmp}
1522
%post -n libomp%{_sonum}-devel -p /sbin/ldconfig
1523
%postun -n libomp%{_sonum}-devel -p /sbin/ldconfig
1524
%endif
1525
1526
%if %{with libcxx}
1527
%post %{multisource libcxx%{_socxx}} libc++%{_socxx} -p /sbin/ldconfig
1528
%postun %{multisource libcxx%{_socxx}} libc++%{_socxx} -p /sbin/ldconfig
1529
%post %{multisource libcxxabi%{_socxx}} libc++abi%{_socxx} -p /sbin/ldconfig
1530
%postun %{multisource libcxxabi%{_socxx}} libc++abi%{_socxx} -p /sbin/ldconfig
1531
%post %{multisource libcxx_devel} libc++-devel -p /sbin/ldconfig
1532
%postun %{multisource libcxx_devel} libc++-devel -p /sbin/ldconfig
1533
%post %{multisource libcxx_devel} libc++abi-devel -p /sbin/ldconfig
1534
%postun %{multisource libcxx_devel} libc++abi-devel -p /sbin/ldconfig
1535
%endif
1536
1537
%if %{with polly}
1538
%post polly -p /sbin/ldconfig
1539
%postun polly -p /sbin/ldconfig
1540
%post polly-devel -p /sbin/ldconfig
1541
%postun polly-devel -p /sbin/ldconfig
1542
%endif
1543
1544
%global ua_install() %{_sbindir}/update-alternatives \\\
1545
--install %{_bindir}/%1 %1 %{_bindir}/%1-%{_sonum} %{_uaver}
1546
%global ua_bin_slave() \\\
1547
--slave %{_bindir}/%1 %1 %{_bindir}/%1-%{_sonum}
1548
%global ua_man_slave() \\\
1549
--slave %{_mandir}/man1/%1.1%{ext_man} %1.1%{ext_man} %{_mandir}/man1/%1-%{_sonum}.1%{ext_man}
1550
%global ua_remove() \
1551
if [ ! -f %{_bindir}/%1-%{_sonum} ] ; then \
1552
%{_sbindir}/update-alternatives --remove %1 %{_bindir}/%1-%{_sonum} \
1553
fi
1554
1555
%post
1556
%{ua_install %llvm_ua_anchor} \
1557
%{lapply -p ua_bin_slave %llvm_tools} \
1558
%{lapply -p ua_bin_slave %llvm_elf_dwarf_tools} \
1559
%{lapply -p ua_bin_slave %llvm_abi_coff_macho_tools} \
1560
%{lapply -p ua_bin_slave %llvm_instr_devel_tools} \
1561
%{lapply -p ua_man_slave %llvm_man} \
1562
%{lapply -p ua_man_slave %llvm_bin_utils_man} \
1563
%{lapply -p ua_man_slave %llvm_devel_utils_man}
1564
1565
%postun
1566
%{ua_remove %llvm_ua_anchor}
1567
1568
%post -n clang%{_sonum}
1569
%{ua_install %clang_ua_anchor} \
1570
%{lapply -p ua_bin_slave %clang_binfiles} \
1571
%{lapply -p ua_bin_slave %clang_tools_extra_binfiles} \
1572
%{lapply -p ua_man_slave %clang_manfiles}
1573
1574
%postun -n clang%{_sonum}
1575
%{ua_remove %clang_ua_anchor}
1576
1577
%if %{with lld}
1578
%post -n lld%{_sonum}
1579
%{ua_install %lld_ua_anchor} \
1580
%{lapply -p ua_bin_slave %lld_binfiles}
1581
%{_sbindir}/update-alternatives --install %{_bindir}/ld ld %{_bindir}/ld.lld 1
1582
1583
%postun -n lld%{_sonum}
1584
%{ua_remove %lld_ua_anchor}
1585
if [ ! -f %{_bindir}/lld ] ; then
1586
%{_sbindir}/update-alternatives --remove ld %{_bindir}/ld.lld
1587
fi
1588
%endif
1589
1590
%if %{with lldb}
1591
%post -n lldb%{_sonum}
1592
%{ua_install %lldb_ua_anchor} \
1593
%{lapply -p ua_bin_slave %lldb_binfiles}
1594
1595
%postun -n lldb%{_sonum}
1596
%{ua_remove %lldb_ua_anchor}
1597
%endif
1598
1599
%global bin_path() \
1600
%{_bindir}/%1
1601
%global bin_sonum_path() \
1602
%{_bindir}/%1-%{_sonum}
1603
%global ghost_ua_bin_link() \
1604
%ghost %{_sysconfdir}/alternatives/%1
1605
%global man_path() \
1606
%{_mandir}/man1/%1.1%{ext_man}
1607
%global man_sonum_path() \
1608
%{_mandir}/man1/%1-%{_sonum}.1%{ext_man}
1609
%global ghost_ua_man_link() \
1610
%ghost %{_sysconfdir}/alternatives/%1.1%{ext_man}
1611
1612
%files
1613
%license CREDITS.TXT LICENSE.TXT
1614
%{lapply -p bin_path %llvm_ua_anchor %llvm_tools}
1615
%{lapply -p bin_path %llvm_elf_dwarf_tools}
1616
%{lapply -p bin_path %llvm_abi_coff_macho_tools}
1617
%{lapply -p bin_path %llvm_instr_devel_tools}
1618
%{lapply -p bin_sonum_path %llvm_ua_anchor %llvm_tools}
1619
%{lapply -p bin_sonum_path %llvm_elf_dwarf_tools}
1620
%{lapply -p bin_sonum_path %llvm_abi_coff_macho_tools}
1621
%{lapply -p bin_sonum_path %llvm_instr_devel_tools}
1622
%{lapply -p ghost_ua_bin_link %llvm_ua_anchor %llvm_tools}
1623
%{lapply -p ghost_ua_bin_link %llvm_elf_dwarf_tools}
1624
%{lapply -p ghost_ua_bin_link %llvm_abi_coff_macho_tools}
1625
%{lapply -p ghost_ua_bin_link %llvm_instr_devel_tools}
1626
1627
%{lapply -p man_path %llvm_man}
1628
%{lapply -p man_path %llvm_bin_utils_man}
1629
%{lapply -p man_path %llvm_devel_utils_man}
1630
%{lapply -p man_sonum_path %llvm_man}
1631
%{lapply -p man_sonum_path %llvm_bin_utils_man}
1632
%{lapply -p man_sonum_path %llvm_devel_utils_man}
1633
%{lapply -p ghost_ua_man_link %llvm_man}
1634
%{lapply -p ghost_ua_man_link %llvm_bin_utils_man}
1635
%{lapply -p ghost_ua_man_link %llvm_devel_utils_man}
1636
1637
%files -n clang%{_sonum}
1638
%license CREDITS.TXT LICENSE.TXT
1639
%{lapply -p bin_path %clang_ua_anchor %clang_binfiles}
1640
%{lapply -p bin_path %clang_tools_extra_binfiles}
1641
%{lapply -p bin_sonum_path %clang_ua_anchor %clang_binfiles}
1642
%{lapply -p bin_sonum_path %clang_tools_extra_binfiles}
1643
%{lapply -p ghost_ua_bin_link %clang_ua_anchor %clang_binfiles}
1644
%{lapply -p ghost_ua_bin_link %clang_tools_extra_binfiles}
1645
1646
%{lapply -p man_path %clang_manfiles}
1647
%{lapply -p man_sonum_path %clang_manfiles}
1648
%{lapply -p ghost_ua_man_link %clang_manfiles}
1649
1650
%dir %{_libdir}/clang
1651
%dir %{_libdir}/clang/%{_sonum}
1652
%dir %{_libdir}/clang/%{_sonum}/lib
1653
%dir %{_libdir}/clang/%{_sonum}/lib/linux
1654
%ifnarch s390x
1655
%{_libdir}/clang/%{_sonum}/lib/linux/clang_rt.*.o
1656
%endif
1657
%{_libdir}/clang/%{_sonum}/lib/linux/libclang_rt.*.a
1658
%ifnarch %{ix86}
1659
%{_libdir}/clang/%{_sonum}/lib/linux/libclang_rt.*.a.syms
1660
%endif
1661
%ifarch aarch64 %{arm} ppc64le x86_64
1662
%{_libdir}/clang/%{_sonum}/lib/linux/liborc_rt-*.a
1663
%endif
1664
1665
%files -n libclang_rt%{_sonum}
1666
%license CREDITS.TXT LICENSE.TXT
1667
%dir %{_libdir}/clang
1668
%dir %{_libdir}/clang/%{_sonum}
1669
%ifarch aarch64 riscv64 x86_64
1670
%{_libdir}/clang/%{_sonum}/bin
1671
%endif
1672
%dir %{_libdir}/clang/%{_sonum}/lib
1673
%dir %{_libdir}/clang/%{_sonum}/lib/linux
1674
%{_libdir}/clang/%{_sonum}/lib/linux/libclang_rt.*.so
1675
# The sanitizer runtime is not available for ppc.
1676
%ifnarch ppc
1677
%{_libdir}/clang/%{_sonum}/share
1678
%endif
1679
1680
%if %{_plv} == %{_sonum}
1681
%files -n clang-tools
1682
%license CREDITS.TXT LICENSE.TXT
1683
%{_bindir}/analyze-build
1684
%{_bindir}/clang-doc
1685
%{_bindir}/clang-format-diff
1686
%{_bindir}/clang-tidy-diff
1687
%{_bindir}/git-clang-format
1688
%{_bindir}/hmaptool
1689
%{_bindir}/intercept-build
1690
%{_bindir}/run-clang-tidy
1691
%{_bindir}/run-find-all-symbols
1692
%{_bindir}/scan-build
1693
%{_bindir}/scan-build-py
1694
%{_bindir}/scan-view
1695
%{_libexecdir}/analyze-c++
1696
%{_libexecdir}/analyze-cc
1697
%{_libexecdir}/c++-analyzer
1698
%{_libexecdir}/ccc-analyzer
1699
%{_libexecdir}/intercept-c++
1700
%{_libexecdir}/intercept-cc
1701
%{_prefix}/lib/libear
1702
%{_prefix}/lib/libscanbuild
1703
%{_datadir}/bash-completion/completions/clang
1704
%{_datadir}/clang/
1705
%{_datadir}/clang-doc/
1706
%{_datadir}/scan-build/
1707
%{_datadir}/scan-view/
1708
%{_mandir}/man1/scan-build.1%{ext_man}
1709
%endif
1710
1711
%files opt-viewer
1712
%license CREDITS.TXT LICENSE.TXT
1713
%{_bindir}/opt-diff
1714
%{_bindir}/opt-stats
1715
%{_bindir}/opt-viewer
1716
%{python_pkg_sitelib}/optpmap.py
1717
%{python_pkg_sitelib}/optrecord.py
1718
%{_datadir}/opt-viewer/
1719
1720
%files -n libLLVM%{_sonum}
1721
%license CREDITS.TXT LICENSE.TXT
1722
%{_libdir}/libLLVM.so.%{_soname}
1723
%{_libdir}/libLLVMTableGen.so.%{_soname}
1724
%{_libdir}/libRemarks.so.%{_soname}
1725
1726
%files %{multisource libclang%{_soclang}} libclang%{_soclang}
1727
%license CREDITS.TXT LICENSE.TXT
1728
%{_libdir}/libclang.so.%{_soclang}
1729
%{_libdir}/libclang.so.%{_version}
1730
1731
%files -n libclang-cpp%{_sonum}
1732
%license CREDITS.TXT LICENSE.TXT
1733
%{_libdir}/libclang-cpp.so.%{_soname}
1734
%dir %{_libdir}/clang/
1735
%dir %{_libdir}/clang/%{_sonum}/
1736
%{_libdir}/clang/%{_sonum}/include
1737
1738
%files -n libLTO%{_sonum}
1739
%license CREDITS.TXT LICENSE.TXT
1740
%{_libdir}/libLTO.so.%{_soname}
1741
1742
%files gold
1743
%license CREDITS.TXT LICENSE.TXT
1744
%{_libdir}/LLVMgold.so
1745
# Note that bfd-plugins is in /usr/lib/bfd-plugins before binutils 2.33.1
1746
%dir %{_libdir}/bfd-plugins/
1747
%{_libdir}/bfd-plugins/LLVMgold.so
1748
1749
%if %{with openmp}
1750
%files -n libomp%{_sonum}-devel
1751
%license CREDITS.TXT LICENSE.TXT
1752
%{_libdir}/libarcher.so
1753
%{_libdir}/libomp.so
1754
%{_libdir}/libompd.so
1755
%{_libdir}/cmake/openmp
1756
%endif
1757
1758
%if %{with libcxx}
1759
%files %{multisource libcxx%{_socxx}} libc++%{_socxx}
1760
%license CREDITS.TXT LICENSE.TXT
1761
%{_libdir}/libc++.so.*
1762
1763
%files %{multisource libcxxabi%{_socxx}} libc++abi%{_socxx}
1764
%license CREDITS.TXT LICENSE.TXT
1765
%{_libdir}/libc++abi.so.*
1766
1767
%files %{multisource libcxx_devel} libc++-devel
1768
%license CREDITS.TXT LICENSE.TXT
1769
%{_libdir}/libc++.modules.json
1770
%{_libdir}/libc++.so
1771
%{_libdir}/libc++experimental.a
1772
%dir %{_includedir}/c++/
1773
%{_includedir}/c++/v%{_socxx}
1774
%dir %{_datadir}/libc++/
1775
%{_datadir}/libc++/v%{_socxx}
1776
1777
%files %{multisource libcxx_devel} libc++abi-devel
1778
%license CREDITS.TXT LICENSE.TXT
1779
%{_libdir}/libc++abi.so
1780
%endif
1781
1782
%files devel
1783
%license CREDITS.TXT LICENSE.TXT
1784
%{_bindir}/FileCheck
1785
%{_bindir}/llvm-config
1786
%{_libdir}/libLLVM.so
1787
%{_libdir}/libLLVMTableGen.so
1788
%{_libdir}/libLTO.so
1789
%{_libdir}/libRemarks.so
1790
%{_includedir}/llvm/
1791
%{_includedir}/llvm-c/
1792
%{_libdir}/cmake/llvm
1793
%{_mandir}/man1/FileCheck.1%{ext_man}
1794
%{_mandir}/man1/llvm-config.1%{ext_man}
1795
%{_rpmconfigdir}/macros.d/macros.llvm
1796
1797
%files doc
1798
%{_docdir}/llvm/
1799
1800
%files -n clang%{_sonum}-devel
1801
%license CREDITS.TXT LICENSE.TXT
1802
%{_libdir}/libclang*.so
1803
%{_includedir}/clang/
1804
%{_includedir}/clang-c/
1805
%{_libdir}/cmake/clang
1806
1807
%files -n clang%{_sonum}-doc
1808
%{_docdir}/llvm-clang/
1809
1810
%files vim-plugins
1811
%license CREDITS.TXT LICENSE.TXT
1812
%doc utils/vim/README.vim
1813
%{_datadir}/vim/
1814
1815
%files -n python3-clang%{_sonum}
1816
%license CREDITS.TXT LICENSE.TXT
1817
%{python_pkg_sitelib}/clang/
1818
%{_docdir}/python-clang/
1819
1820
%if %{with lld}
1821
%files -n lld%{_sonum}
1822
%license CREDITS.TXT LICENSE.TXT
1823
%{_bindir}/ld
1824
%ghost %{_sysconfdir}/alternatives/ld
1825
%{lapply -p bin_path %lld_ua_anchor %lld_binfiles}
1826
%{lapply -p bin_sonum_path %lld_ua_anchor %lld_binfiles}
1827
%{lapply -p ghost_ua_bin_link %lld_ua_anchor %lld_binfiles}
1828
%endif
1829
1830
%if %{with lldb}
1831
%files -n lldb%{_sonum}
1832
%license CREDITS.TXT LICENSE.TXT
1833
%{lapply -p bin_path %lldb_ua_anchor %lldb_binfiles}
1834
%{lapply -p bin_sonum_path %lldb_ua_anchor %lldb_binfiles}
1835
%{lapply -p ghost_ua_bin_link %lldb_ua_anchor %lldb_binfiles}
1836
1837
%if %{with lldb_python}
1838
%files -n python3-lldb%{_sonum}
1839
%license CREDITS.TXT LICENSE.TXT
1840
%{python_pkg_sitearch}/lldb/
1841
%endif
1842
1843
%files -n liblldb%{_sonum}
1844
%license CREDITS.TXT LICENSE.TXT
1845
%{_libdir}/liblldb.so.%{_soname}
1846
%{_libdir}/liblldb.so.%{_version}
1847
%{_libdir}/liblldbIntelFeatures.so.%{_soname}
1848
1849
%files -n lldb%{_sonum}-devel
1850
%license CREDITS.TXT LICENSE.TXT
1851
%{_includedir}/lldb/
1852
%{_libdir}/liblldb.so
1853
%{_libdir}/liblldbIntelFeatures.so
1854
%endif
1855
1856
%if %{with polly}
1857
%files polly
1858
%license CREDITS.TXT LICENSE.TXT
1859
%{_libdir}/LLVMPolly.so
1860
1861
%files polly-devel
1862
%license CREDITS.TXT LICENSE.TXT
1863
%{_includedir}/polly
1864
%{_libdir}/cmake/polly
1865
%endif
1866
1867
%changelog
1868