Commit Graph

268 Commits

Author SHA1 Message Date
Cameron Katri
81fa5c4a82 llvm-strings: Install as strings when WITH_LLVM_BINUTILS=YES
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D32065
2023-04-21 16:13:40 -04:00
Ed Maste
41df1d60e3 llvm: fix some llvm-* tool links when WITH_LLVM_BINUTILS is set
A few Makefiles overrode LINKS and MLINKS when WITH_LLVM_BINUTILS was
set, which caused some llvm- prefixed tools to disappear.  One such case
was llvm-ranlib, which some ports invoke explicitly.

Use += when adding to LINKS and MLINKS under WITH_LLVM_BINUTILS.

PR:		270955, 270956, 270959
Submitted by:	jbeich
Reviewed by:	arichardson
Fixes: 021385aba5 ("Add WITH_LLVM_BINUTILS to install LLVM binuti...")
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39747
2023-04-21 12:49:05 -04:00
Ed Maste
5cb402cc89 llvm-objcopy: link man page as strip.1 when WITH_LLVM_BINUTILS is set
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39429
2023-04-06 10:12:21 -04:00
John Baldwin
eeedaefab5 Remove LLVM build glue for MIPS as a native architecture.
This does not remove LLVM_TARGET_MIPS.  Note that the only
MACHINE_ARCH values ending in 'hf' were all MIPS architectures, hence
removing the pattern matches for 'hf'.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D39331
2023-03-29 15:06:15 -07:00
Dimitry Andric
4dc3b1fa1b Revert "Ensure .inc files are regenerated when llvm/clang tblgen binaries change"
This reverts commit ab80f0b21f. The intent
of this change was to avoid possible compilation errors when certain
.inc files were not regenerated, but the method turns out to cause way
more rebuilds than anticipated. Another method will have to be found,
and in the mean time, WITH_CLEAN is the solution that always works.

Fixes:		ab80f0b21f
2023-03-29 20:37:02 +02:00
Dimitry Andric
d8ed7fa3d5 Revert "Rework {clang,lldb,llvm}-tblgen invocations to add --write-if-changed"
This reverts commit 8f391d9098. There are
still a bunch of problems, and apparently ${.ALLSRC} does not work as I
expected.

Fixes:          8f391d9098
2023-03-29 20:31:33 +02:00
Dimitry Andric
8f391d9098 Rework {clang,lldb,llvm}-tblgen invocations to add --write-if-changed
This flag ensures that the tblgen tools do not actually touch the
produced .inc file, if there are no changes to the contents. In turn,
this may prevent a number of rebuilds of files that include such .inc
files, saving build time.

While here, ensure that the shell invocations to locate the used tblgen
binary do not show unnecessary error messages.

Reported by:	des
MFC after:	1 week
2023-03-29 19:49:49 +02:00
Dimitry Andric
ab80f0b21f Ensure .inc files are regenerated when llvm/clang tblgen binaries change
When doing a fully incremental build (with WITHOUT_CLEAN enabled), from
a commit before llvm 15 was merged (3264f6b88f), to a commit after
that, a number of .inc files were not regenerated. This could lead to
unexpected compilation errors when these .inc files were included from
llvm-project sources, similar to:

  In file included from /usr/src/contrib/llvm-project/clang/lib/CodeGen/CGBuiltin.cpp:8268:
  /usr/obj/usr/src/amd64.amd64/lib/clang/libclang/clang/Basic/arm_mve_builtin_cg.inc:279:18: error: no matching constructor for initialization of 'clang::CodeGen::Address'
    Address Val2 = Address(Val1, CharUnits::fromQuantity(2));
                   ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Work around this by making the .inc files dependent on the tblgen binary
used for generating them. E.g., we can relatively safely assume that if
the binary gets updated, the .inc files must also be updated. (Although
this is not 100% optimal, the gain by complicating things even more is
probaby not worth the effort.)

MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D38770
2023-02-26 15:56:07 +01:00
Dimitry Andric
fcaf7f8644 Merge llvm-project main llvmorg-15-init-17485-ga3e38b4a206b
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15-init-17485-ga3e38b4a206b.

PR:		265425
MFC after:	2 weeks
2023-02-08 20:04:38 +01:00
Dimitry Andric
81ad626541 Merge llvm-project main llvmorg-15-init-15358-g53dc0f10787
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15-init-15358-g53dc0f10787.

PR:		265425
MFC after:	2 weeks
2023-02-08 20:02:26 +01:00
Ed Maste
86edb11e74 Always install llvm-objdump as objdump
Instead of providing no /usr/bin/objdump when LLVM_BINUTILS is false.

PR:		267854 [exp-run]
Reviewed by:	dim
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37445
2022-12-12 10:36:02 -05:00
Ed Maste
20a66ab4bf Retire CLANG_IS_CC option
A small reduction in build infrastructure complexity; when we had both
Clang and GCC in the tree it was useful to have both built, and choose
one or the other to install as /usr/bin/cc.  Now only Clang is in the
tree, and there is no point in building and installing base Clang but
not providing it as cc (and c++, cpp).

Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37075
2022-11-21 14:56:13 -05:00
Ed Maste
61957f3a6f clang: remove as(1) cross-reference from man page
PR:		265232
Reviewed by:	dim
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differntial Revision:	https://reviews.freebsd.org/D36634
2022-09-25 15:21:25 -04:00
Dimitry Andric
04eeddc0aa Merge llvm-project main llvmorg-14-init-17616-g024a1fab5c35
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14-init-17616-g024a1fab5c35.

PR:		261742
MFC after:	2 weeks
2022-05-14 13:44:34 +02:00
Dimitry Andric
5e801ac66d Merge llvm-project main llvmorg-14-init-10223-g401b76fdf2b3
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14-init-10223-g401b76fdf2b3.

PR:		261742
MFC after:	2 weeks
2022-05-14 13:43:32 +02:00
Dimitry Andric
28a41182c0 Merge llvm-project 13.0.0 release
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-13.0.0-0-gd7b669b3a303, aka 13.0.0 release.

PR:		258209
MFC after:	2 weeks
2021-11-13 21:49:29 +01:00
Dimitry Andric
fe6060f10f Merge llvm-project main llvmorg-13-init-16847-g88e66fa60ae5
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-13-init-16847-g88e66fa60ae5, the last commit before
the upstream release/13.x branch was created.

PR:		258209
MFC after:	2 weeks
2021-11-13 21:39:49 +01:00
Alex Richardson
367ec75323 Fix a syntax error in 1b85b68da0
Reported by:	Michael Butler, jenkins
2021-10-14 17:46:28 +01:00
Cameron Katri
1b85b68da0 llvm-readobj: Attach to buildsystem
Also install it as readelf when MK_LLVM_BINUTILS is set.

Reviewed By:	dim, arichardson
Differential Revision: https://reviews.freebsd.org/D32058
2021-10-14 17:18:05 +01:00
Baptiste Daroussin
cbc83e378a ncurses: chase dependency changes in the source tree
Differential Revision:	https://reviews.freebsd.org/D32098
2021-10-04 11:38:24 +02:00
Jessica Clarke
f28c1d0c5c llvm-objcopy: Install llvm-strip, and optionally strip, links
Just as elftoolchain's objcopy doubles as strip, so does LLVM's. This
ensures that a strip binary is still present for WITH_LLVM_BINUTILS
builds. Note that we do not currently have a committed copy of the
manpage generated from the rST source so no manpage is installed for
(llvm-)strip.

Reported by:	Shawn Webb <shawn.webb@hardenedbsd.org>
Tested by:	Shawn Webb <shawn.webb@hardenedbsd.org>
MFC after:	1 week
2021-09-13 21:52:40 +01:00
Alex Richardson
021385aba5 Add WITH_LLVM_BINUTILS to install LLVM binutils instead of Elftoolchain
When WITH_LLVM_BINUTILS is set, we will install the LLVM binutils as
ar/ranlib/nm/objcopy/etc. instead of the elftoolchain ones.
Having the LLVM binutils instead of the elftoolchain ones allows us to use
features such as LTO that depend on binutils that understand LLVM IR.
Another benefit will be an improved user-experience when compiling with
AddressSanitizer, since ASAN does not symbolize backtraces correctly if
addr2line is elftoolchain addr2line instead of llvm-symbolizer.
See https://lists.freebsd.org/archives/freebsd-toolchain/2021-July/000062.html
for more details.

This is currently off by default but will be turned on by default at some
point in the near future.

Reviewed By:	emaste

Differential Revision: https://reviews.freebsd.org/D31060
2021-09-06 09:49:49 +01:00
Alex Richardson
8e1c989abb Don't build and install {llvm,clang,lldb}-tblgen for the target
The tablegen binaries are only needed to build software that uses
LLVM's infrastructure for command line options,
disassembler tables, etc. They are not user-facing binaries and
should therefore not be installed by default.

Reviewed By:	emaste
Differential Revision: https://reviews.freebsd.org/D31058
2021-09-06 09:32:41 +01:00
Jessica Clarke
c8edd05426 clang: Support building with GCC and DEBUG_FILES disabled
If MK_DEBUG_FILES=no then the Clang link rule has clang as .TARGET,
rather than clang.full, causing the implicit ${CFLAGS.${.TARGET:T}} to
be CFLAGS.clang, and thus pull in flags intended for when your compiler
is Clang, not when linking Clang itself. This doesn't matter if your
compiler is in fact Clang, but it breaks using GCC as, for example,
bsd.sys.mk adds -Qunused-arguments to CFLAGS.clang. This is seen when
trying to build a bootstrap toolchain on Linux where GCC is the system
compiler.

Thus, introduce a new internal NO_TARGET_FLAGS variable that is set by
Clang to disable the addition of these implicit flags. This is a bigger
hammer than necessary, as flags for .o files would be safe, but that is
not needed for Clang.

Note that the same problem does not arise for LDFLAGS when building LLD
with BFD, since our build produces a program called ld.lld, not plain
lld (unlike upstream, where ld.lld is a symlink to lld so they can
support multiple different flavours in one binary).

Suggested by:	sjg
Fixes:		31ba4ce889 ("Allow bootstrapping llvm-tblgen on macOS and Linux")
MFC after:	1 week
Reviewed by:	dim, imp, emaste
Differential Revision:	https://reviews.freebsd.org/D31532
2021-08-24 15:04:25 +01:00
Alex Richardson
31ba4ce889 Allow bootstrapping llvm-tblgen on macOS and Linux
This is needed in order to build various LLVM binutils (e.g. addr2line)
as well as clang/lld/lldb.

Co-authored-by: Jessica Clarke <jrtc27@FreeBSD.org>
Test Plan:	Compiles on ubuntu 18.04 and macOS 11.4
Reviewed By:	dim
Differential Revision: https://reviews.freebsd.org/D31057
2021-08-02 14:36:03 +01:00
Dimitry Andric
d409305fa3 Merge llvm-project 12.0.0 release
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-12.0.0-0-gd28af7c654d8, a.k.a. 12.0.0 release.

PR:		255570
MFC after:	6 weeks
2021-06-13 22:01:15 +02:00
Dimitry Andric
e8d8bef961 Merge llvm-project main llvmorg-12-init-17869-g8e464dd76bef
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-12-init-17869-g8e464dd76bef, the last commit before the
upstream release/12.x branch was created.

PR:		255570
MFC after:	6 weeks
2021-06-13 21:37:19 +02:00
Dimitry Andric
07bab4417d Add WITH_LLVM_CXXFILT option to install llvm-cxxfilt as c++filt
Since elftoolchain's cxxfilt is rather far behind on features, and we
ran into several bugs, add an option to use llvm-cxxfilt as an drop-in
replacement.

It supports the same options as elftoolchain cxxfilt, though it doesn't
have support for old ARM (C++ Annotated Reference Manual, not the CPU)
and GNU v2 manglings. But these are irrelevant in 2020.

Note: as we already compile the required libraries as part of libllvm,
this will not add any significant build time either.

PR:		250702
Reviewed by:	emaste, yuri
Differential Revision: https://reviews.freebsd.org/D27071
MFC after:	2 weeks
2020-11-03 19:57:28 +00:00
Dimitry Andric
48aaf27bca Update Makefiles under lib/clang and usr.bin/clang for 11.0.0 builds,
and also bump the version in the mtree files.
2020-08-06 19:30:00 +00:00
Dimitry Andric
874d8270d9 Fix llvm-strings.1 not installing, this was a copy/paste error.
MFC after:	3 weeks
2020-06-28 18:02:51 +00:00
Dimitry Andric
62cfcf62f6 Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
llvmorg-10.0.1-rc2-0-g77d76b71d7d.

Also add a few more llvm utilities under WITH_CLANG_EXTRAS:

* llvm-dwp, a utility for merging DWARF 5 Split DWARF .dwo files into
  .dwp (DWARF package files)
* llvm-size, a size(1) replacement
* llvm-strings, a strings(1) replacement

MFC after:	3 weeks
2020-06-28 07:43:43 +00:00
Dimitry Andric
bd74205d6a Regenerate ReStructuredText based manpages for llvm-project tools:
* bugpoint.1
* clang.1
* llc.1
* lldb.1
* lli.1
* llvm-ar.1
* llvm-as.1
* llvm-bcanalyzer.1
* llvm-cov.1
* llvm-diff.1
* llvm-dis.1
* llvm-dwarfdump.1
* llvm-extract.1
* llvm-link.1
* llvm-mca.1
* llvm-nm.1
* llvm-pdbutil.1
* llvm-profdata.1
* llvm-symbolizer.1
* llvm-tblgen.1
* opt.1

Add newly generated manpages for:

* llvm-addr2line.1 (this is an alias of llvm-symbolizer)
* llvm-cxxfilt.1
* llvm-objcopy.1
* llvm-ranlib.1 (this is an alias of llvm-ar)

Note that llvm-objdump.1 is an exception, as upstream has both a plain
.1 file, and a .rst variant. These will have to be reconciled upstream
first.

MFC after:	3 days
2020-06-27 11:56:49 +00:00
Conrad Meyer
0a9ab9f549 Add WITH_CLANG_FORMAT option
clang-format is enabled conditional on either WITH_CLANG_EXTRAS or
WITH_CLANG_FORMAT.  Some sources in libclang are build conditional on
either rule, and obviously the clang-format binary itself depends on the
rule.

clang-format could still use a manual page.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D25427
2020-06-24 17:03:42 +00:00
Ed Maste
652a974885 lldb: build and enable lua script bindings
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D24266
2020-04-03 16:54:13 +00:00
Dimitry Andric
da759cfa32 Remove -mlong-calls vhen building arm libraries and llvm.
Clang from 9.0.0 onwards already has the necessary relocation range
extenders, so this workaround is no longer needed (it produces longer
and slower code). Tested on real hardware, and in cross-compile
environment.

Submitted by:	mmel
2020-03-10 06:49:43 +00:00
Dimitry Andric
91019ea7d4 Merge ^/head r358400 through r358465. 2020-02-29 15:08:14 +00:00
Ed Maste
57f804675e remove GCC 4.2.1 build infrastructure
As described in Warner's email message[1] to the FreeBSD-arch mailing
list we have reached GCC 4.2.1's retirement date.  At this time all
supported architectures either use in-tree Clang, or rely on external
toolchain (i.e., a contemporary GCC version from ports).

GCC 4.2.1 was released July 18, 2007 and was imported into FreeBSD later
that year, in r171825.  GCC has served us well, but version 4.2.1 is
obsolete and not used by default on any architecture in FreeBSD.  It
does not support modern C and does not support arm64 or RISC-V.

Thanks to everyone responsible for maintaining, updating, and testing
GCC in the FreeBSD base system over the years.

So long, and thanks for all the fish.

[1] https://lists.freebsd.org/pipermail/freebsd-arch/2020-January/019823.html

PR:		228919
Reviewed by:	brooks, imp
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D23124
2020-02-29 03:25:51 +00:00
Dimitry Andric
f46f1d2836 Update build glue for lldb (MK_LLDB=yes). Also update lldb's generated
Config.h, disable a few more parts in the code we don't use, and add a
pre-generated man page.
2020-01-27 16:52:44 +00:00
Dimitry Andric
56e766af41 Update build glue for lld (MK_LLD=yes). Also update invocation of
elf::link() in lld.cpp.
2020-01-26 21:55:17 +00:00
Dimitry Andric
b1ae91026f Update build glue for extra clang/llvm tools (MK_CLANG_EXTRAS=yes). 2020-01-26 20:57:29 +00:00
Dimitry Andric
38b6f45657 Adjust libllvmminimal and tblgen Makefiles so all the tblgen executables
build.
2020-01-25 16:46:39 +00:00
Dimitry Andric
0b57cec536 Move all sources from the llvm project into contrib/llvm-project.
This uses the new layout of the upstream repository, which was recently
migrated to GitHub, and converted into a "monorepo".  That is, most of
the earlier separate sub-projects with their own branches and tags were
consolidated into one top-level directory, and are now branched and
tagged together.

Updating the vendor area to match this layout is next.
2019-12-20 19:53:05 +00:00
Dimitry Andric
fd9d16bddb Ensure lld respects the WITH/WITHOUT_SHARED_TOOLCHAIN option
Traditionally, toolchain components such as cc, as, and ld have been
built as static executables.  The WITH_SHARED_TOOLCHAIN option from
src.conf(5) is meant to link these as regular executables, e.g. using
shared libraries.

The build of ld.lld did not yet check this option.  Fix the Makefile so
it will do so now.

Reported by:	Mike Cui <cuicui@gmail.com>
PR:		241257
MFC after:	3 days
2019-10-16 17:11:18 +00:00
Dimitry Andric
8b3bc70a2b Merge ^/head r352764 through r353315. 2019-10-08 18:17:02 +00:00
Kyle Evans
4f68b172e1 clang: use -mxgot for 32-bit mips
Various bits in usr.bin/clang/* will fail to compile without -mxgot due to
truncated relocations. -mxgot entails a speed penalty, but I suspect we
don't care as much about compiler performance in 32-bit mips land.

Reviewed by:	arichardson
Differential Revision:	https://reviews.freebsd.org/D21698
2019-10-02 17:15:38 +00:00
Dimitry Andric
a32f82c2c1 Update build glue for a build of clang plus lldb (enabled via MK_LLDB). 2019-08-26 21:00:14 +00:00
Dimitry Andric
560bf0c7df Add lldb-tblgen tool. 2019-08-26 20:57:45 +00:00
Dimitry Andric
390be9fc05 Update build glue for a build of clang plus lld (enabled via MK_LLD). 2019-08-24 22:07:38 +00:00
Dimitry Andric
24b8043ea5 Update build glue for a build of clang plus the extra tools (enabled via
MK_CLANG_EXTRAS).
2019-08-24 19:21:11 +00:00
Dimitry Andric
4014a71fd2 Update build glue for a minimal build of the clang executable. 2019-08-23 22:17:36 +00:00