History log of /freebsd-current/lib/clang/include/lld/Common/Version.inc
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 3a079333 24-May-2024 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/18.x llvmorg-18.1.6-0-g1118c2e05e67

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project release/18.x llvmorg-18.1.6-0-g1118c2e05e67.

PR: 276104
MFC after: 3 days


# 894cb08f 03-May-2024 Dimitry Andric <dim@FreeBSD.org>

Fixup: Merge llvm-project release/18.x llvmorg-18.1.5-0-g617a15a9eac9

Update version numbers, config headers, etc. Git tricked me into losing
these before pushing.

PR: 276104
Fixes: d67fc74b9249
MFC after: 3 days

# dfa39133 20-Apr-2024 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/18.x llvmorg-18.1.4-0-ge6c3289804a6

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project release/18.x llvmorg-18.1.4-0-ge6c3289804a6.

PR: 276104
MFC after: 3 days

# 439352ac 05-Apr-2024 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/18.x llvmorg-18.1.3-0-gc13b7485b879

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project release/18.x llvmorg-18.1.3-0-gc13b7485b879.

PR: 276104
MFC after: 1 month


# 4c2d3b02 10-Mar-2024 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/18.x llvmorg-18.1.1-0-gdba2a75e9c7e

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project release/18.x llvmorg-18.1.1-0-gdba2a75e9c7e.

PR: 276104
MFC after: 1 month


# 56727255 21-Feb-2024 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/18.x llvmorg-18.1.0-rc3-0-g6c90f8dd5463

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project release/18.x llvmorg-18.1.0-rc3-0-g6c90f8dd5463.

PR: 276104
MFC after: 1 month


# 74626c16 20-Feb-2024 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/18.x llvmorg-18.1.0-rc2-53-gc7b0a6ecd442

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project release/18.x llvmorg-18.1.0-rc2-53-gc7b0a6ecd442.

PR: 276104
MFC after: 1 month


# b3edf446 07-Feb-2024 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/18.x llvmorg-18.1.0-rc2-0-gc6c86965d967

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project release/18.x llvmorg-18.1.0-rc2-0-gc6c86965d967.

PR: 276104
MFC after: 1 month


# 878ed495 26-Jan-2024 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/18.x llvmorg-18-init-18361-g22683463740e

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project release/18.x llvmorg-18-init-18361-g22683463740e.

PR: 276104
MFC after: 1 month


# 7a6dacac 24-Jan-2024 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-18-init-18359-g93248729cfae

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project main llvmorg-18-init-18359-g93248729cfae, the
last commit before the upstream release/18.x branch was created.

PR: 276104
MFC after: 1 month


# 297eecfb 11-Jan-2024 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-18-init-16864-g3b3ee1f53424

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project main llvmorg-18-init-16864-g3b3ee1f53424.

PR: 276104
MFC after: 1 month


# 1db9f3b2 09-Jan-2024 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-18-init-16595-g7c00a5be5cde

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project main llvmorg-18-init-16595-g7c00a5be5cde.

PR: 276104
MFC after: 1 month


# 647cbc5d 03-Jan-2024 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-18-init-16003-gfc5f51cf5af4

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project main llvmorg-18-init-16003-gfc5f51cf5af4.

PR: 276104
MFC after: 1 month


# cb14a3fe 25-Dec-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-18-init-15692-g007ed0dccd6a

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project main llvmorg-18-init-15692-g007ed0dccd6a.

PR: 276104
MFC after: 1 month


# 5f757f3f 18-Dec-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-18-init-15088-gd14ee76181fb

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project main llvmorg-18-init-15088-gd14ee76181fb.

PR: 276104
MFC after: 1 month


# 5c16e71d 30-Nov-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/17.x llvmorg-17.0.6-0-g6009708b4367

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.6-0-g6009708b4367.

PR: 273753
MFC after: 1 month


# b121cb00 16-Nov-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/17.x llvmorg-17.0.5-0-g98bfdac5ce82

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.5-0-g98bfdac5ce82.

PR: 273753
MFC after: 1 month


# bdb86d1a 21-Oct-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/17.x llvmorg-17.0.3-0-g888437e1b600

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.3-0-g888437e1b600.

PR: 273753
MFC after: 1 month


# 3bd749db 04-Oct-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/17.x llvmorg-17.0.2-0-gb2417f51dbbd

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.2-0-gb2417f51dbbd.

PR: 273753
MFC after: 1 month


# 4542f901 29-Sep-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/17.x llvmorg-17.0.1-25-g098e653a5bed

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.1-25-g098e653a5bed.

PR: 273753
MFC after: 1 month


# 8a4dda33 11-Sep-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/17.x llvmorg-17.0.0-rc4-10-g0176e8729ea4

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.0-rc4-10-g0176e8729ea4.

PR: 273753
MFC after: 1 month


# 06c3fb27 02-Sep-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-17-init-19304-gd0b54bb50e51

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project main llvmorg-17-init-19304-gd0b54bb50e51, the
last commit before the upstream release/17.x branch was created.

PR: 273753
MFC after: 1 month


# aee253d8 24-Aug-2023 Glen Barber <gjb@FreeBSD.org>

update main to 15

Approved by: re (implicit)
Sponsored by: GoFundMe https://www.gofundme.com/f/gjbbsd
Sponsored by: PayPal https://paypal.me/gjbbsd

# e048f78b 22-Jun-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/16.x llvmorg-16.0.6-0-g7cbf1a259152

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.6-0-g7cbf1a259152 (aka 16.0.6 release).

PR: 271047
MFC after: 1 month


# 2efbaac7 04-Jun-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/16.x llvmorg-16.0.5-0-g185b81e034ba

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.5-0-g185b81e034ba (aka 16.0.5 release).

PR: 271047
MFC after: 1 month


# a324c340 22-May-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/16.x llvmorg-16.0.4-0-gae42196bc493

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.4-0-gae42196bc493 (aka 16.0.4 release).

PR: 271047
MFC after: 1 month


# cbe9438c 05-May-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/16.x llvmorg-16.0.3-0-gda3cd333bea5

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.3-0-gda3cd333bea5 (aka 16.0.3 release).

PR: 271047
MFC after: 1 month


# 9e7101a8 22-Apr-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/16.x llvmorg-16.0.2-0-g18ddebe1a1a9

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.2-0-g18ddebe1a1a9 (aka 16.0.2 release).

PR: 271047
MFC after: 1 month


# 1ac55f4c 17-Apr-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/16.x llvmorg-16.0.1-0-gcd89023f7979

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.1-0-gcd89023f7979 (aka 16.0.1 release).

PR: 271047
MFC after: 1 month


# bdd1243d 14-Apr-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-16-init-18548-gb0daacf58f41

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16-init-18548-gb0daacf58f41.

PR: 271047
MFC after: 1 month


# 50d7464c 14-Jan-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/15.x llvmorg-15.0.7-0-g8dfdcc7b7bf6

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15.0.7-0-g8dfdcc7b7bf6.

PR: 265425
MFC after: 2 weeks


# f3fd488f 04-Dec-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/15.x llvmorg-15.0.6-0-g088f33605d8a

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15.0.6-0-g088f33605d8a.

PR: 265425
MFC after: 2 weeks


# 6246ae0b 16-Oct-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/15.x llvmorg-15.0.2-10-gf3c5289e7846

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15.0.2-10-gf3c5289e7846.

PR: 265425
MFC after: 2 weeks


# a4a491e2 10-Sep-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/15.x llvmorg-15.0.0-9-g1c73596d3454

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15.0.0-9-g1c73596d3454.

PR: 265425
MFC after: 2 weeks


# 61cfbce3 13-Aug-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/15.x llvmorg-15.0.0-rc2-40-gfbd2950d8d0d

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15.0.0-rc2-40-gfbd2950d8d0d.

PR: 265425
MFC after: 2 weeks


# 972a253a 27-Jul-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-15-init-17826-g1f8ae9d7e7e4

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15-init-17826-g1f8ae9d7e7e4, the last commit before
the upstream release/16.x branch was created.

PR: 265425
MFC after: 2 weeks


# fcaf7f86 24-Jul-2022 Dimitry Andric <dim@FreeBSD.org>

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


# 753f127f 14-Jul-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-15-init-16436-g18a6ab5b8d1f

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15-init-16436-g18a6ab5b8d1f.

PR: 265425
MFC after: 2 weeks


# 81ad6265 04-Jul-2022 Dimitry Andric <dim@FreeBSD.org>

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


# 56f451bb 12-Jun-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.5-0-gc12386ae247c

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.5-0-gc12386ae247c, aka 14.0.5 release.

PR: 261742
MFC after: 3 days


# 809922b0 05-Jun-2022 Dimitry Andric <dim@FreeBSD.org>

Update rest of llvm-project build glue for 14.0.4

I completely forgot about updating the generated llvm-project config
files, which also contain version numbers, etc. Sorry for the churn.

PR: 261742
Fixes: ab9d54731f43
MFC after: 3 days

# ab9d5473 04-Jun-2022 Dimitry Andric <dim@FreeBSD.org>

Bump versions llvm-project release/14.x llvmorg-14.0.4-0-g29f1039a7285

Somehow git rebase made this squashed commit disappear. Restore it.

PR: 261742
MFC after: 3 days

# 3a9a9c0c 28-Apr-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.3-0-g1f9140064dfb

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.3-0-g1f9140064dfb.

PR: 261742
MFC after: 2 weeks


# dbc822f3 29-Mar-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.0-2-g3f43d803382d

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-2-g3f43d803382d.

PR: 261742
MFC after: 2 weeks


# fb03ea46 17-Mar-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.0-rc4-2-gadd3ab7f4c8a

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-rc4-2-gadd3ab7f4c8a.

PR: 261742
MFC after: 2 weeks


# d781ede6 05-Mar-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.0-rc2-12-g09546e1b5103

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-rc2-12-g09546e1b5103.

PR: 261742
MFC after: 2 weeks


# d56accc7 18-Feb-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.0-rc1-74-g4dc3cb8e3255

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-rc1-74-g4dc3cb8e3255.

PR: 261742
MFC after: 2 weeks


# 1838bd0f 05-Feb-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14-init-18315-g190be5457c90

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14-init-18315-g190be5457c90.

PR: 261742
MFC after: 2 weeks


# 5e801ac6 20-Nov-2021 Dimitry Andric <dim@FreeBSD.org>

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


# fe6060f1 22-Aug-2021 Dimitry Andric <dim@FreeBSD.org>

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


# 23408297 18-Jun-2021 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project 12.0.1 rc2

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-12.0.1-rc2-0-ge7dac564cd0e, a.k.a. 12.0.1 rc2.

PR: 255570
MFC after: 6 weeks


# e8d8bef9 13-Jun-2021 Dimitry Andric <dim@FreeBSD.org>

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


# f9a66922 21-Jan-2021 Glen Barber <gjb@FreeBSD.org>

fix incorrect LLD_VERSION_STRING from previous commit

Reported by: Oliver Pinter
Sponsored by: Rubicon Communications, LLC ("Netgate")

# a53ce3fc 21-Jan-2021 Glen Barber <gjb@FreeBSD.org>

Bump CURRENT to 14.0

This one goes to 14.

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC ("Netgate")

# eaeb601b 03-Jan-2021 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
release/11.x llvmorg-11.0.1-rc2-0-g43ff75f2c3f (aka 11.0.1 rc2).

MFC after: 4 weeks
X-MFC-With: r364284


# 5f24ef21 06-Aug-2020 Dimitry Andric <dim@FreeBSD.org>

Update generated llvm-project related version headers, config.h files
and add a newly generated lldb Plugins.def file too.

# d65cd7a5 23-May-2020 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
llvmorg-10.0.1-rc1-0-gf79cd71e145 (aka 10.0.1 rc1).

MFC after: 3 weeks


# 0b37c159 25-Jan-2020 Dimitry Andric <dim@FreeBSD.org>

* Bump version numbers to 10.0.0
* Update UPDATING
* Update (Optional)ObsoleteFiles.inc
* Update VCS(Revision|Version) files
* Update generated config headers
* Update clang internal headers Makefile

# c14a5a88 22-Dec-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
9.0.1 final release c1a0a213378a458fbea1a5c77b315c7dce08fd05.

Release notes for llvm, clang, lld and libc++ 9.0.1 will become
available here:

https://releases.llvm.org/9.0.1/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.1/tools/clang/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.1/tools/lld/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.1/projects/libcxx/docs/ReleaseNotes.html

PR: 240629
MFC after: 1 month


# fb3a446a 06-Sep-2019 Dimitry Andric <dim@FreeBSD.org>

Add a VCSVersion.inc header with revision and repository defines,
similar to what upstream generates via CMake. Though for us it is
handier to have everything in one file.

# 6a82ac86 02-Sep-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb, and openmp
release_90 branch r370514, and update version numbers.


# 22f75ae7 02-Sep-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb, and openmp
release_90 branch r369369, and update version numbers.


# 86aa9539 23-Aug-2019 Dimitry Andric <dim@FreeBSD.org>

Regenerate config and version headers.

# 87c8ef55 20-Jul-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
8.0.1 final release r366581. The only functional change is a fix for a
mismerge of upstream r360816, which properly restores the r2 register
when unwinding on PowerPC64 (See https://reviews.freebsd.org/D20337).

Relnotes: yes
PR: 236062
MFC after: 3 days
X-MFC-With: r349004


# ec38f4f9 06-Jul-2019 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt, libc++,
libunwind and openmp to the upstream release_80 branch r364487
(effectively, 8.0.1 rc3). The 8.0.1 release will most likely
have no further changes.

MFC after: 1 week
X-MFC-With: r349004


# efc5c442 12-Jun-2019 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt, libc++,
libunwind and openmp to the upstream release_80 branch r363030
(effectively, 8.0.1 rc2). The 8.0.1 release should follow this within a
week or so.

MFC after: 2 weeks


# c3e6b9d3 20-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Pull in r352826 from upstream lld trunk (by Fangrui Song):

[ELF] Support --{,no-}allow-shlib-undefined

Summary:
In ld.bfd/gold, --no-allow-shlib-undefined is the default when
linking an executable. This patch implements a check to error on
undefined symbols in a shared object, if all of its DT_NEEDED entries
are seen.

Our approach resembles the one used in gold, achieves a good balance
to be useful but not too smart (ld.bfd traces all DSOs and emulates
the behavior of a dynamic linker to catch more cases).

The error is issued based on the symbol table, different from
undefined reference errors issued for relocations. It is most
effective when there are DSOs that were not linked with -z defs (e.g.
when static sanitizers runtime is used).

gold has a comment that some system libraries on GNU/Linux may have
spurious undefined references and thus system libraries should be
excluded (https://sourceware.org/bugzilla/show_bug.cgi?id=6811). The
story may have changed now but we make --allow-shlib-undefined the
default for now. Its interaction with -shared can be discussed in the
future.

Reviewers: ruiu, grimar, pcc, espindola

Reviewed By: ruiu

Subscribers: joerg, emaste, arichardson, llvm-commits

Differential Revision: https://reviews.llvm.org/D57385

Pull in r352943 from upstream lld trunk (by Fangrui Song):

[ELF] Default to --no-allow-shlib-undefined for executables

Summary:
This follows the ld.bfd/gold behavior.

The error check is useful as it captures a common type of ld.so
undefined symbol errors as link-time errors:

// a.cc => a.so (not linked with -z defs)
void f(); // f is undefined
void g() { f(); }

// b.cc => executable with a DT_NEEDED entry on a.so
void g();
int main() { g(); }

// ld.so errors when g() is executed (lazy binding) or when the program is started (-z now)
// symbol lookup error: ... undefined symbol: f

Reviewers: ruiu, grimar, pcc, espindola

Reviewed By: ruiu

Subscribers: llvm-commits, emaste, arichardson

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D57569

Together, these add support for --no-allow-shlib-undefined, and make it
the default for executables, so they will fail to link if any symbols
from needed shared libraries are undefined.

Reported by: jbeich
PR: 236062, 236141
MFC after: 1 month
X-MFC-With: r344779

# fb7e42b9 20-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
8.0.0 final release r356365. There were no functional changes since the
most recent merge, of 8.0.0 rc5.

Release notes for llvm, clang, lld and libc++ 8.0.0 are now available:

https://llvm.org/releases/8.0.0/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/tools/clang/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/tools/lld/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/projects/libcxx/docs/ReleaseNotes.html

PR: 236062
MFC after: 1 month
X-MFC-With: r344779


# 2352f970 14-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, and lldb
release_80 branch r356034 (effectively, 8.0.0 rc5), resolve conflicts,
and bump version numbers.

PR: 236062
MFC after: 1 month
X-MFC-With: r344779


# b3ed818e 08-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r355677 (effectively, 8.0.0 rc4), resolve conflicts, and bump version
numbers.

PR: 236062
MFC after: 1 month
X-MFC-With: r344779


# 3087b115 04-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r355313, resolve conflicts, and bump version numbers.


# da18572f 25-Feb-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r354799, resolve conflicts, and bump version numbers.


# 640dd76f 15-Feb-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r354130, resolve conflicts, and bump version numbers.


# c8630eab 05-Feb-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r353167, resolve conflicts, and bump version numbers.


# af44a011 22-Jan-2019 Dimitry Andric <dim@FreeBSD.org>

Now for the release_80 branch, update version numbers for llvm, clang
and lld, and regenerate config headers.

# 0bf31f1f 20-Jan-2019 Dimitry Andric <dim@FreeBSD.org>

Update version numbers, and regenerate config headers for llvm, clang,
lld and lldb. Update ObsoleteFiles.inc and OptionalObsoleteFiles.inc.

# 176fdeee 15-Dec-2018 Dimitry Andric <dim@FreeBSD.org>

Update clang, llvm, lld, lldb, compiler-rt and libc++ version number to
7.0.1 release r349250. There were no functional changes since the 7.0.1
rc3 import.

PR: 230240, 230355
Relnotes: yes
MFC after: 2 months
X-MFC-With: r341825


# 0b9890fc 09-Dec-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r348686 (effectively 7.0.1 rc3), resolve conflicts, and bump version
numbers.

PR: 230240, 230355


# 68948600 04-Nov-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r346007 (effectively 7.0.1 rc2), resolve conflicts, and bump version
numbers.

PR: 230240, 230355


# c6879c6c 23-Oct-2018 Dimitry Andric <dim@FreeBSD.org>

Merge ^/head r339015 through r339669.


# b0bffd12 20-Oct-2018 Ed Maste <emaste@FreeBSD.org>

Bump LLD_REVISION_STRING for 13-CURRENT

# b371a9f0 11-Oct-2018 Ed Maste <emaste@FreeBSD.org>

lld: set sh_link and sh_info for .rela.plt sections

ELF spec says that for SHT_REL and SHT_RELA sh_link should reference the
associated string table and sh_info should reference the "section to
which the relocation applies." ELF Tool Chain's elfcopy / strip use
this (in part) to control whether or not the relocation entry is copied
to the output.

LLVM PR 37538 https://bugs.llvm.org/show_bug.cgi?id=37538

Approved by: re (kib)
Obtained from: llvm r344226 (backported for 6.0)

# 38fb4010 17-Sep-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ 7.0.0 release
r342383, and bump version numbers.

PR: 230240, 230355


# c826f0db 11-Sep-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r341916, resolve conflicts, and bump version numbers.

PR: 230240, 230355


# 8ba00cf9 29-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r340910, resolve conflicts, and bump version numbers.

PR: 230240, 230355


# 7726714d 17-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r339999, resolve conflicts, and bump version numbers.

PR: 230240,230355


# 3beb5372 11-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r339355, resolve conflicts, and bump version numbers.


# 84ba35dc 04-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Bump clang and lld upstream revision numbers.

# 0fecf001 02-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Bump revisions to r338536, and also bump lld version again.

# 837f3385 31-Jul-2018 Ed Maste <emaste@FreeBSD.org>

bump lld version number after r336972 arm(v7) VFP tag support

Reported by: kevans
Sponsored by: The FreeBSD Foundation

# 6dfa117f 31-Jul-2018 Dimitry Andric <dim@FreeBSD.org>

Update llvm/clang version numbers in various files.

# fbfca78e 30-Jun-2018 Dimitry Andric <dim@FreeBSD.org>

Follow-up to r335799 (llvm/clang 6.0.1 update), by regenerating various
headers with new version information defines.

MFC after: 2 weeks
X-MFC-With: r335799

# 6ccc06f6 29-Jun-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.1 release (upstream r335540).

Relnotes: yes
MFC after: 2 weeks


# 19703503 09-May-2018 Ed Maste <emaste@FreeBSD.org>

lld: Omit PT_NOTE for SHT_NOTE without SHF_ALLOC

A non-alloc note section should not have a PT_NOTE program header.

Found while linking ghc (Haskell compiler) with lld on FreeBSD. Haskell
emits a .debug-ghc-link-info note section (as the name suggests, it
contains link info) as a SHT_NOTE section without SHF_ALLOC set.

For this case ld.bfd does not emit a PT_NOTE segment for
.debug-ghc-link-info. lld previously emitted a PT_NOTE with p_vaddr = 0
and FreeBSD's rtld segfaulted when trying to parse a note at address 0.

LLVM PR: https://llvm.org/pr37361
LLVM review: https://reviews.llvm.org/D46623

PR: 226872
Reviewed by: dim
Sponsored by: The FreeBSD Foundation

# 08730804 19-Apr-2018 Ed Maste <emaste@FreeBSD.org>

lld: use correct number of digits in __FreeBSD_version-style ID

__FreeBSD_version-style IDs should have 5 digits following the major.

# 12881601 17-Apr-2018 Ed Maste <emaste@FreeBSD.org>

lld: add a __FreeBSD_version-style identifier to version

This will faciliate a WITH_SYSTEM_LINKER option.

Reviewed by: dim
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D15110

# c5a4cd4f 04-Mar-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 release (upstream r326565).

Release notes for llvm, clang and lld will be available here soon:
<http://releases.llvm.org/6.0.0/docs/ReleaseNotes.html>
<http://releases.llvm.org/6.0.0/tools/clang/docs/ReleaseNotes.html>
<http://releases.llvm.org/6.0.0/tools/lld/docs/ReleaseNotes.html>

Relnotes: yes
MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 4f8786af 25-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r325932). This corresponds to 6.0.0 rc3.

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 954b921d 16-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r325330).

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 07577dfe 02-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r324090).

This introduces retpoline support, with the -mretpoline flag. The
upstream initial commit message (r323155 by Chandler Carruth) contains
quite a bit of explanation. Quoting:

Introduce the "retpoline" x86 mitigation technique for variant #2 of
the speculative execution vulnerabilities disclosed today,
specifically identified by CVE-2017-5715, "Branch Target Injection",
and is one of the two halves to Spectre.

Summary:
First, we need to explain the core of the vulnerability. Note that
this is a very incomplete description, please see the Project Zero
blog post for details:
https://googleprojectzero.blogspot.com/2018/01/reading-privileged-memory-with-side.html

The basis for branch target injection is to direct speculative
execution of the processor to some "gadget" of executable code by
poisoning the prediction of indirect branches with the address of
that gadget. The gadget in turn contains an operation that provides a
side channel for reading data. Most commonly, this will look like a
load of secret data followed by a branch on the loaded value and then
a load of some predictable cache line. The attacker then uses timing
of the processors cache to determine which direction the branch took
*in the speculative execution*, and in turn what one bit of the
loaded value was. Due to the nature of these timing side channels and
the branch predictor on Intel processors, this allows an attacker to
leak data only accessible to a privileged domain (like the kernel)
back into an unprivileged domain.

The goal is simple: avoid generating code which contains an indirect
branch that could have its prediction poisoned by an attacker. In
many cases, the compiler can simply use directed conditional branches
and a small search tree. LLVM already has support for lowering
switches in this way and the first step of this patch is to disable
jump-table lowering of switches and introduce a pass to rewrite
explicit indirectbr sequences into a switch over integers.

However, there is no fully general alternative to indirect calls. We
introduce a new construct we call a "retpoline" to implement indirect
calls in a non-speculatable way. It can be thought of loosely as a
trampoline for indirect calls which uses the RET instruction on x86.
Further, we arrange for a specific call->ret sequence which ensures
the processor predicts the return to go to a controlled, known
location. The retpoline then "smashes" the return address pushed onto
the stack by the call with the desired target of the original
indirect call. The result is a predicted return to the next
instruction after a call (which can be used to trap speculative
execution within an infinite loop) and an actual indirect branch to
an arbitrary address.

On 64-bit x86 ABIs, this is especially easily done in the compiler by
using a guaranteed scratch register to pass the target into this
device. For 32-bit ABIs there isn't a guaranteed scratch register
and so several different retpoline variants are introduced to use a
scratch register if one is available in the calling convention and to
otherwise use direct stack push/pop sequences to pass the target
address.

This "retpoline" mitigation is fully described in the following blog
post: https://support.google.com/faqs/answer/7625886

We also support a target feature that disables emission of the
retpoline thunk by the compiler to allow for custom thunks if users
want them. These are particularly useful in environments like
kernels that routinely do hot-patching on boot and want to hot-patch
their thunk to different code sequences. They can write this custom
thunk and use `-mretpoline-external-thunk` *in addition* to
`-mretpoline`. In this case, on x86-64 thu thunk names must be:
```
__llvm_external_retpoline_r11
```
or on 32-bit:
```
__llvm_external_retpoline_eax
__llvm_external_retpoline_ecx
__llvm_external_retpoline_edx
__llvm_external_retpoline_push
```
And the target of the retpoline is passed in the named register, or in
the case of the `push` suffix on the top of the stack via a `pushl`
instruction.

There is one other important source of indirect branches in x86 ELF
binaries: the PLT. These patches also include support for LLD to
generate PLT entries that perform a retpoline-style indirection.

The only other indirect branches remaining that we are aware of are
from precompiled runtimes (such as crt0.o and similar). The ones we
have found are not really attackable, and so we have not focused on
them here, but eventually these runtimes should also be replicated for
retpoline-ed configurations for completeness.

For kernels or other freestanding or fully static executables, the
compiler switch `-mretpoline` is sufficient to fully mitigate this
particular attack. For dynamic executables, you must compile *all*
libraries with `-mretpoline` and additionally link the dynamic
executable and all shared libraries with LLD and pass `-z
retpolineplt` (or use similar functionality from some other linker).
We strongly recommend also using `-z now` as non-lazy binding allows
the retpoline-mitigated PLT to be substantially smaller.

When manually apply similar transformations to `-mretpoline` to the
Linux kernel we observed very small performance hits to applications
running typic al workloads, and relatively minor hits (approximately
2%) even for extremely syscall-heavy applications. This is largely
due to the small number of indirect branches that occur in
performance sensitive paths of the kernel.

When using these patches on statically linked applications,
especially C++ applications, you should expect to see a much more
dramatic performance hit. For microbenchmarks that are switch,
indirect-, or virtual-call heavy we have seen overheads ranging from
10% to 50%.

However, real-world workloads exhibit substantially lower performance
impact. Notably, techniques such as PGO and ThinLTO dramatically
reduce the impact of hot indirect calls (by speculatively promoting
them to direct calls) and allow optimized search trees to be used to
lower switches. If you need to deploy these techniques in C++
applications, we *strongly* recommend that you ensure all hot call
targets are statically linked (avoiding PLT indirection) and use both
PGO and ThinLTO. Well tuned servers using all of these techniques saw
5% - 10% overhead from the use of retpoline.

We will add detailed documentation covering these components in
subsequent patches, but wanted to make the core functionality
available as soon as possible. Happy for more code review, but we'd
really like to get these patches landed and backported ASAP for
obvious reasons. We're planning to backport this to both 6.0 and 5.0
release streams and get a 5.0 release with just this cherry picked
ASAP for distros and vendors.

This patch is the work of a number of people over the past month:
Eric, Reid, Rui, and myself. I'm mailing it out as a single commit
due to the time sensitive nature of landing this and the need to
backport it. Huge thanks to everyone who helped out here, and
everyone at Intel who helped out in discussions about how to craft
this. Also, credit goes to Paul Turner (at Google, but not an LLVM
contributor) for much of the underlying retpoline design.

Reviewers: echristo, rnk, ruiu, craig.topper, DavidKreitzer

Subscribers: sanjoy, emaste, mcrosier, mgorny, mehdi_amini, hiraditya, llvm-commits

Differential Revision: https://reviews.llvm.org/D41723

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 842d113b 01-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r323948).

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 042b1c2e 24-Jan-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r323338).

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 30785c0e 06-Jan-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_60 r321788,
update build glue and version numbers.


# fe4fed2e 28-Dec-2017 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ trunk r321545,
update build glue and version numbers, add new intrinsics headers, and
update OptionalObsoleteFiles.inc.


# 2757ff7e 23-Dec-2017 Dimitry Andric <dim@FreeBSD.org>

Update clang, lld and llvm version numbers for r321414, and update build
glue.

# 02d2ad99 20-Dec-2017 Dimitry Andric <dim@FreeBSD.org>

Update generated config headers, and version numbers.

# 894cb08f 03-May-2024 Dimitry Andric <dim@FreeBSD.org>

Fixup: Merge llvm-project release/18.x llvmorg-18.1.5-0-g617a15a9eac9

Update version numbers, config headers, etc. Git tricked me into losing
these before pushing.

PR: 276104
Fixes: d67fc74b9249
MFC after: 3 days


# dfa39133 20-Apr-2024 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/18.x llvmorg-18.1.4-0-ge6c3289804a6

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project release/18.x llvmorg-18.1.4-0-ge6c3289804a6.

PR: 276104
MFC after: 3 days


# 439352ac 05-Apr-2024 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/18.x llvmorg-18.1.3-0-gc13b7485b879

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project release/18.x llvmorg-18.1.3-0-gc13b7485b879.

PR: 276104
MFC after: 1 month


# 4c2d3b02 10-Mar-2024 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/18.x llvmorg-18.1.1-0-gdba2a75e9c7e

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project release/18.x llvmorg-18.1.1-0-gdba2a75e9c7e.

PR: 276104
MFC after: 1 month


# 56727255 21-Feb-2024 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/18.x llvmorg-18.1.0-rc3-0-g6c90f8dd5463

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project release/18.x llvmorg-18.1.0-rc3-0-g6c90f8dd5463.

PR: 276104
MFC after: 1 month


# 74626c16 20-Feb-2024 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/18.x llvmorg-18.1.0-rc2-53-gc7b0a6ecd442

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project release/18.x llvmorg-18.1.0-rc2-53-gc7b0a6ecd442.

PR: 276104
MFC after: 1 month


# b3edf446 07-Feb-2024 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/18.x llvmorg-18.1.0-rc2-0-gc6c86965d967

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project release/18.x llvmorg-18.1.0-rc2-0-gc6c86965d967.

PR: 276104
MFC after: 1 month


# 878ed495 26-Jan-2024 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/18.x llvmorg-18-init-18361-g22683463740e

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project release/18.x llvmorg-18-init-18361-g22683463740e.

PR: 276104
MFC after: 1 month


# 7a6dacac 24-Jan-2024 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-18-init-18359-g93248729cfae

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project main llvmorg-18-init-18359-g93248729cfae, the
last commit before the upstream release/18.x branch was created.

PR: 276104
MFC after: 1 month


# 297eecfb 11-Jan-2024 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-18-init-16864-g3b3ee1f53424

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project main llvmorg-18-init-16864-g3b3ee1f53424.

PR: 276104
MFC after: 1 month


# 1db9f3b2 09-Jan-2024 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-18-init-16595-g7c00a5be5cde

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project main llvmorg-18-init-16595-g7c00a5be5cde.

PR: 276104
MFC after: 1 month


# 647cbc5d 03-Jan-2024 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-18-init-16003-gfc5f51cf5af4

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project main llvmorg-18-init-16003-gfc5f51cf5af4.

PR: 276104
MFC after: 1 month


# cb14a3fe 25-Dec-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-18-init-15692-g007ed0dccd6a

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project main llvmorg-18-init-15692-g007ed0dccd6a.

PR: 276104
MFC after: 1 month


# 5f757f3f 18-Dec-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-18-init-15088-gd14ee76181fb

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project main llvmorg-18-init-15088-gd14ee76181fb.

PR: 276104
MFC after: 1 month


# 5c16e71d 30-Nov-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/17.x llvmorg-17.0.6-0-g6009708b4367

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.6-0-g6009708b4367.

PR: 273753
MFC after: 1 month


# b121cb00 16-Nov-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/17.x llvmorg-17.0.5-0-g98bfdac5ce82

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.5-0-g98bfdac5ce82.

PR: 273753
MFC after: 1 month


# bdb86d1a 21-Oct-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/17.x llvmorg-17.0.3-0-g888437e1b600

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.3-0-g888437e1b600.

PR: 273753
MFC after: 1 month


# 3bd749db 04-Oct-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/17.x llvmorg-17.0.2-0-gb2417f51dbbd

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.2-0-gb2417f51dbbd.

PR: 273753
MFC after: 1 month


# 4542f901 29-Sep-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/17.x llvmorg-17.0.1-25-g098e653a5bed

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.1-25-g098e653a5bed.

PR: 273753
MFC after: 1 month


# 8a4dda33 11-Sep-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/17.x llvmorg-17.0.0-rc4-10-g0176e8729ea4

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.0-rc4-10-g0176e8729ea4.

PR: 273753
MFC after: 1 month


# 06c3fb27 02-Sep-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-17-init-19304-gd0b54bb50e51

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project main llvmorg-17-init-19304-gd0b54bb50e51, the
last commit before the upstream release/17.x branch was created.

PR: 273753
MFC after: 1 month


# aee253d8 24-Aug-2023 Glen Barber <gjb@FreeBSD.org>

update main to 15

Approved by: re (implicit)
Sponsored by: GoFundMe https://www.gofundme.com/f/gjbbsd
Sponsored by: PayPal https://paypal.me/gjbbsd

# e048f78b 22-Jun-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/16.x llvmorg-16.0.6-0-g7cbf1a259152

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.6-0-g7cbf1a259152 (aka 16.0.6 release).

PR: 271047
MFC after: 1 month


# 2efbaac7 04-Jun-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/16.x llvmorg-16.0.5-0-g185b81e034ba

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.5-0-g185b81e034ba (aka 16.0.5 release).

PR: 271047
MFC after: 1 month


# a324c340 22-May-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/16.x llvmorg-16.0.4-0-gae42196bc493

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.4-0-gae42196bc493 (aka 16.0.4 release).

PR: 271047
MFC after: 1 month


# cbe9438c 05-May-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/16.x llvmorg-16.0.3-0-gda3cd333bea5

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.3-0-gda3cd333bea5 (aka 16.0.3 release).

PR: 271047
MFC after: 1 month


# 9e7101a8 22-Apr-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/16.x llvmorg-16.0.2-0-g18ddebe1a1a9

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.2-0-g18ddebe1a1a9 (aka 16.0.2 release).

PR: 271047
MFC after: 1 month


# 1ac55f4c 17-Apr-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/16.x llvmorg-16.0.1-0-gcd89023f7979

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.1-0-gcd89023f7979 (aka 16.0.1 release).

PR: 271047
MFC after: 1 month


# bdd1243d 14-Apr-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-16-init-18548-gb0daacf58f41

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16-init-18548-gb0daacf58f41.

PR: 271047
MFC after: 1 month


# 50d7464c 14-Jan-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/15.x llvmorg-15.0.7-0-g8dfdcc7b7bf6

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15.0.7-0-g8dfdcc7b7bf6.

PR: 265425
MFC after: 2 weeks


# f3fd488f 04-Dec-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/15.x llvmorg-15.0.6-0-g088f33605d8a

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15.0.6-0-g088f33605d8a.

PR: 265425
MFC after: 2 weeks


# 6246ae0b 16-Oct-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/15.x llvmorg-15.0.2-10-gf3c5289e7846

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15.0.2-10-gf3c5289e7846.

PR: 265425
MFC after: 2 weeks


# a4a491e2 10-Sep-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/15.x llvmorg-15.0.0-9-g1c73596d3454

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15.0.0-9-g1c73596d3454.

PR: 265425
MFC after: 2 weeks


# 61cfbce3 13-Aug-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/15.x llvmorg-15.0.0-rc2-40-gfbd2950d8d0d

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15.0.0-rc2-40-gfbd2950d8d0d.

PR: 265425
MFC after: 2 weeks


# 972a253a 27-Jul-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-15-init-17826-g1f8ae9d7e7e4

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15-init-17826-g1f8ae9d7e7e4, the last commit before
the upstream release/16.x branch was created.

PR: 265425
MFC after: 2 weeks


# fcaf7f86 24-Jul-2022 Dimitry Andric <dim@FreeBSD.org>

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


# 753f127f 14-Jul-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-15-init-16436-g18a6ab5b8d1f

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15-init-16436-g18a6ab5b8d1f.

PR: 265425
MFC after: 2 weeks


# 81ad6265 04-Jul-2022 Dimitry Andric <dim@FreeBSD.org>

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


# 56f451bb 12-Jun-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.5-0-gc12386ae247c

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.5-0-gc12386ae247c, aka 14.0.5 release.

PR: 261742
MFC after: 3 days


# 809922b0 05-Jun-2022 Dimitry Andric <dim@FreeBSD.org>

Update rest of llvm-project build glue for 14.0.4

I completely forgot about updating the generated llvm-project config
files, which also contain version numbers, etc. Sorry for the churn.

PR: 261742
Fixes: ab9d54731f43
MFC after: 3 days

# ab9d5473 04-Jun-2022 Dimitry Andric <dim@FreeBSD.org>

Bump versions llvm-project release/14.x llvmorg-14.0.4-0-g29f1039a7285

Somehow git rebase made this squashed commit disappear. Restore it.

PR: 261742
MFC after: 3 days

# 3a9a9c0c 28-Apr-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.3-0-g1f9140064dfb

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.3-0-g1f9140064dfb.

PR: 261742
MFC after: 2 weeks


# dbc822f3 29-Mar-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.0-2-g3f43d803382d

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-2-g3f43d803382d.

PR: 261742
MFC after: 2 weeks


# fb03ea46 17-Mar-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.0-rc4-2-gadd3ab7f4c8a

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-rc4-2-gadd3ab7f4c8a.

PR: 261742
MFC after: 2 weeks


# d781ede6 05-Mar-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.0-rc2-12-g09546e1b5103

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-rc2-12-g09546e1b5103.

PR: 261742
MFC after: 2 weeks


# d56accc7 18-Feb-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.0-rc1-74-g4dc3cb8e3255

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-rc1-74-g4dc3cb8e3255.

PR: 261742
MFC after: 2 weeks


# 1838bd0f 05-Feb-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14-init-18315-g190be5457c90

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14-init-18315-g190be5457c90.

PR: 261742
MFC after: 2 weeks


# 5e801ac6 20-Nov-2021 Dimitry Andric <dim@FreeBSD.org>

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


# fe6060f1 22-Aug-2021 Dimitry Andric <dim@FreeBSD.org>

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


# 23408297 18-Jun-2021 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project 12.0.1 rc2

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-12.0.1-rc2-0-ge7dac564cd0e, a.k.a. 12.0.1 rc2.

PR: 255570
MFC after: 6 weeks


# e8d8bef9 13-Jun-2021 Dimitry Andric <dim@FreeBSD.org>

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


# f9a66922 21-Jan-2021 Glen Barber <gjb@FreeBSD.org>

fix incorrect LLD_VERSION_STRING from previous commit

Reported by: Oliver Pinter
Sponsored by: Rubicon Communications, LLC ("Netgate")

# a53ce3fc 21-Jan-2021 Glen Barber <gjb@FreeBSD.org>

Bump CURRENT to 14.0

This one goes to 14.

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC ("Netgate")

# eaeb601b 03-Jan-2021 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
release/11.x llvmorg-11.0.1-rc2-0-g43ff75f2c3f (aka 11.0.1 rc2).

MFC after: 4 weeks
X-MFC-With: r364284


# 5f24ef21 06-Aug-2020 Dimitry Andric <dim@FreeBSD.org>

Update generated llvm-project related version headers, config.h files
and add a newly generated lldb Plugins.def file too.

# d65cd7a5 23-May-2020 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
llvmorg-10.0.1-rc1-0-gf79cd71e145 (aka 10.0.1 rc1).

MFC after: 3 weeks


# 0b37c159 25-Jan-2020 Dimitry Andric <dim@FreeBSD.org>

* Bump version numbers to 10.0.0
* Update UPDATING
* Update (Optional)ObsoleteFiles.inc
* Update VCS(Revision|Version) files
* Update generated config headers
* Update clang internal headers Makefile

# c14a5a88 22-Dec-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
9.0.1 final release c1a0a213378a458fbea1a5c77b315c7dce08fd05.

Release notes for llvm, clang, lld and libc++ 9.0.1 will become
available here:

https://releases.llvm.org/9.0.1/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.1/tools/clang/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.1/tools/lld/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.1/projects/libcxx/docs/ReleaseNotes.html

PR: 240629
MFC after: 1 month


# fb3a446a 06-Sep-2019 Dimitry Andric <dim@FreeBSD.org>

Add a VCSVersion.inc header with revision and repository defines,
similar to what upstream generates via CMake. Though for us it is
handier to have everything in one file.

# 6a82ac86 02-Sep-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb, and openmp
release_90 branch r370514, and update version numbers.


# 22f75ae7 02-Sep-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb, and openmp
release_90 branch r369369, and update version numbers.


# 86aa9539 23-Aug-2019 Dimitry Andric <dim@FreeBSD.org>

Regenerate config and version headers.

# 87c8ef55 20-Jul-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
8.0.1 final release r366581. The only functional change is a fix for a
mismerge of upstream r360816, which properly restores the r2 register
when unwinding on PowerPC64 (See https://reviews.freebsd.org/D20337).

Relnotes: yes
PR: 236062
MFC after: 3 days
X-MFC-With: r349004


# ec38f4f9 06-Jul-2019 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt, libc++,
libunwind and openmp to the upstream release_80 branch r364487
(effectively, 8.0.1 rc3). The 8.0.1 release will most likely
have no further changes.

MFC after: 1 week
X-MFC-With: r349004


# efc5c442 12-Jun-2019 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt, libc++,
libunwind and openmp to the upstream release_80 branch r363030
(effectively, 8.0.1 rc2). The 8.0.1 release should follow this within a
week or so.

MFC after: 2 weeks


# c3e6b9d3 20-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Pull in r352826 from upstream lld trunk (by Fangrui Song):

[ELF] Support --{,no-}allow-shlib-undefined

Summary:
In ld.bfd/gold, --no-allow-shlib-undefined is the default when
linking an executable. This patch implements a check to error on
undefined symbols in a shared object, if all of its DT_NEEDED entries
are seen.

Our approach resembles the one used in gold, achieves a good balance
to be useful but not too smart (ld.bfd traces all DSOs and emulates
the behavior of a dynamic linker to catch more cases).

The error is issued based on the symbol table, different from
undefined reference errors issued for relocations. It is most
effective when there are DSOs that were not linked with -z defs (e.g.
when static sanitizers runtime is used).

gold has a comment that some system libraries on GNU/Linux may have
spurious undefined references and thus system libraries should be
excluded (https://sourceware.org/bugzilla/show_bug.cgi?id=6811). The
story may have changed now but we make --allow-shlib-undefined the
default for now. Its interaction with -shared can be discussed in the
future.

Reviewers: ruiu, grimar, pcc, espindola

Reviewed By: ruiu

Subscribers: joerg, emaste, arichardson, llvm-commits

Differential Revision: https://reviews.llvm.org/D57385

Pull in r352943 from upstream lld trunk (by Fangrui Song):

[ELF] Default to --no-allow-shlib-undefined for executables

Summary:
This follows the ld.bfd/gold behavior.

The error check is useful as it captures a common type of ld.so
undefined symbol errors as link-time errors:

// a.cc => a.so (not linked with -z defs)
void f(); // f is undefined
void g() { f(); }

// b.cc => executable with a DT_NEEDED entry on a.so
void g();
int main() { g(); }

// ld.so errors when g() is executed (lazy binding) or when the program is started (-z now)
// symbol lookup error: ... undefined symbol: f

Reviewers: ruiu, grimar, pcc, espindola

Reviewed By: ruiu

Subscribers: llvm-commits, emaste, arichardson

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D57569

Together, these add support for --no-allow-shlib-undefined, and make it
the default for executables, so they will fail to link if any symbols
from needed shared libraries are undefined.

Reported by: jbeich
PR: 236062, 236141
MFC after: 1 month
X-MFC-With: r344779

# fb7e42b9 20-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
8.0.0 final release r356365. There were no functional changes since the
most recent merge, of 8.0.0 rc5.

Release notes for llvm, clang, lld and libc++ 8.0.0 are now available:

https://llvm.org/releases/8.0.0/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/tools/clang/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/tools/lld/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/projects/libcxx/docs/ReleaseNotes.html

PR: 236062
MFC after: 1 month
X-MFC-With: r344779


# 2352f970 14-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, and lldb
release_80 branch r356034 (effectively, 8.0.0 rc5), resolve conflicts,
and bump version numbers.

PR: 236062
MFC after: 1 month
X-MFC-With: r344779


# b3ed818e 08-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r355677 (effectively, 8.0.0 rc4), resolve conflicts, and bump version
numbers.

PR: 236062
MFC after: 1 month
X-MFC-With: r344779


# 3087b115 04-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r355313, resolve conflicts, and bump version numbers.


# da18572f 25-Feb-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r354799, resolve conflicts, and bump version numbers.


# 640dd76f 15-Feb-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r354130, resolve conflicts, and bump version numbers.


# c8630eab 05-Feb-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r353167, resolve conflicts, and bump version numbers.


# af44a011 22-Jan-2019 Dimitry Andric <dim@FreeBSD.org>

Now for the release_80 branch, update version numbers for llvm, clang
and lld, and regenerate config headers.

# 0bf31f1f 20-Jan-2019 Dimitry Andric <dim@FreeBSD.org>

Update version numbers, and regenerate config headers for llvm, clang,
lld and lldb. Update ObsoleteFiles.inc and OptionalObsoleteFiles.inc.

# 176fdeee 15-Dec-2018 Dimitry Andric <dim@FreeBSD.org>

Update clang, llvm, lld, lldb, compiler-rt and libc++ version number to
7.0.1 release r349250. There were no functional changes since the 7.0.1
rc3 import.

PR: 230240, 230355
Relnotes: yes
MFC after: 2 months
X-MFC-With: r341825


# 0b9890fc 09-Dec-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r348686 (effectively 7.0.1 rc3), resolve conflicts, and bump version
numbers.

PR: 230240, 230355


# 68948600 04-Nov-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r346007 (effectively 7.0.1 rc2), resolve conflicts, and bump version
numbers.

PR: 230240, 230355


# c6879c6c 23-Oct-2018 Dimitry Andric <dim@FreeBSD.org>

Merge ^/head r339015 through r339669.


# b0bffd12 20-Oct-2018 Ed Maste <emaste@FreeBSD.org>

Bump LLD_REVISION_STRING for 13-CURRENT

# b371a9f0 11-Oct-2018 Ed Maste <emaste@FreeBSD.org>

lld: set sh_link and sh_info for .rela.plt sections

ELF spec says that for SHT_REL and SHT_RELA sh_link should reference the
associated string table and sh_info should reference the "section to
which the relocation applies." ELF Tool Chain's elfcopy / strip use
this (in part) to control whether or not the relocation entry is copied
to the output.

LLVM PR 37538 https://bugs.llvm.org/show_bug.cgi?id=37538

Approved by: re (kib)
Obtained from: llvm r344226 (backported for 6.0)

# 38fb4010 17-Sep-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ 7.0.0 release
r342383, and bump version numbers.

PR: 230240, 230355


# c826f0db 11-Sep-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r341916, resolve conflicts, and bump version numbers.

PR: 230240, 230355


# 8ba00cf9 29-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r340910, resolve conflicts, and bump version numbers.

PR: 230240, 230355


# 7726714d 17-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r339999, resolve conflicts, and bump version numbers.

PR: 230240,230355


# 3beb5372 11-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r339355, resolve conflicts, and bump version numbers.


# 84ba35dc 04-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Bump clang and lld upstream revision numbers.

# 0fecf001 02-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Bump revisions to r338536, and also bump lld version again.

# 837f3385 31-Jul-2018 Ed Maste <emaste@FreeBSD.org>

bump lld version number after r336972 arm(v7) VFP tag support

Reported by: kevans
Sponsored by: The FreeBSD Foundation

# 6dfa117f 31-Jul-2018 Dimitry Andric <dim@FreeBSD.org>

Update llvm/clang version numbers in various files.

# fbfca78e 30-Jun-2018 Dimitry Andric <dim@FreeBSD.org>

Follow-up to r335799 (llvm/clang 6.0.1 update), by regenerating various
headers with new version information defines.

MFC after: 2 weeks
X-MFC-With: r335799

# 6ccc06f6 29-Jun-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.1 release (upstream r335540).

Relnotes: yes
MFC after: 2 weeks


# 19703503 09-May-2018 Ed Maste <emaste@FreeBSD.org>

lld: Omit PT_NOTE for SHT_NOTE without SHF_ALLOC

A non-alloc note section should not have a PT_NOTE program header.

Found while linking ghc (Haskell compiler) with lld on FreeBSD. Haskell
emits a .debug-ghc-link-info note section (as the name suggests, it
contains link info) as a SHT_NOTE section without SHF_ALLOC set.

For this case ld.bfd does not emit a PT_NOTE segment for
.debug-ghc-link-info. lld previously emitted a PT_NOTE with p_vaddr = 0
and FreeBSD's rtld segfaulted when trying to parse a note at address 0.

LLVM PR: https://llvm.org/pr37361
LLVM review: https://reviews.llvm.org/D46623

PR: 226872
Reviewed by: dim
Sponsored by: The FreeBSD Foundation

# 08730804 19-Apr-2018 Ed Maste <emaste@FreeBSD.org>

lld: use correct number of digits in __FreeBSD_version-style ID

__FreeBSD_version-style IDs should have 5 digits following the major.

# 12881601 17-Apr-2018 Ed Maste <emaste@FreeBSD.org>

lld: add a __FreeBSD_version-style identifier to version

This will faciliate a WITH_SYSTEM_LINKER option.

Reviewed by: dim
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D15110

# c5a4cd4f 04-Mar-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 release (upstream r326565).

Release notes for llvm, clang and lld will be available here soon:
<http://releases.llvm.org/6.0.0/docs/ReleaseNotes.html>
<http://releases.llvm.org/6.0.0/tools/clang/docs/ReleaseNotes.html>
<http://releases.llvm.org/6.0.0/tools/lld/docs/ReleaseNotes.html>

Relnotes: yes
MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 4f8786af 25-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r325932). This corresponds to 6.0.0 rc3.

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 954b921d 16-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r325330).

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 07577dfe 02-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r324090).

This introduces retpoline support, with the -mretpoline flag. The
upstream initial commit message (r323155 by Chandler Carruth) contains
quite a bit of explanation. Quoting:

Introduce the "retpoline" x86 mitigation technique for variant #2 of
the speculative execution vulnerabilities disclosed today,
specifically identified by CVE-2017-5715, "Branch Target Injection",
and is one of the two halves to Spectre.

Summary:
First, we need to explain the core of the vulnerability. Note that
this is a very incomplete description, please see the Project Zero
blog post for details:
https://googleprojectzero.blogspot.com/2018/01/reading-privileged-memory-with-side.html

The basis for branch target injection is to direct speculative
execution of the processor to some "gadget" of executable code by
poisoning the prediction of indirect branches with the address of
that gadget. The gadget in turn contains an operation that provides a
side channel for reading data. Most commonly, this will look like a
load of secret data followed by a branch on the loaded value and then
a load of some predictable cache line. The attacker then uses timing
of the processors cache to determine which direction the branch took
*in the speculative execution*, and in turn what one bit of the
loaded value was. Due to the nature of these timing side channels and
the branch predictor on Intel processors, this allows an attacker to
leak data only accessible to a privileged domain (like the kernel)
back into an unprivileged domain.

The goal is simple: avoid generating code which contains an indirect
branch that could have its prediction poisoned by an attacker. In
many cases, the compiler can simply use directed conditional branches
and a small search tree. LLVM already has support for lowering
switches in this way and the first step of this patch is to disable
jump-table lowering of switches and introduce a pass to rewrite
explicit indirectbr sequences into a switch over integers.

However, there is no fully general alternative to indirect calls. We
introduce a new construct we call a "retpoline" to implement indirect
calls in a non-speculatable way. It can be thought of loosely as a
trampoline for indirect calls which uses the RET instruction on x86.
Further, we arrange for a specific call->ret sequence which ensures
the processor predicts the return to go to a controlled, known
location. The retpoline then "smashes" the return address pushed onto
the stack by the call with the desired target of the original
indirect call. The result is a predicted return to the next
instruction after a call (which can be used to trap speculative
execution within an infinite loop) and an actual indirect branch to
an arbitrary address.

On 64-bit x86 ABIs, this is especially easily done in the compiler by
using a guaranteed scratch register to pass the target into this
device. For 32-bit ABIs there isn't a guaranteed scratch register
and so several different retpoline variants are introduced to use a
scratch register if one is available in the calling convention and to
otherwise use direct stack push/pop sequences to pass the target
address.

This "retpoline" mitigation is fully described in the following blog
post: https://support.google.com/faqs/answer/7625886

We also support a target feature that disables emission of the
retpoline thunk by the compiler to allow for custom thunks if users
want them. These are particularly useful in environments like
kernels that routinely do hot-patching on boot and want to hot-patch
their thunk to different code sequences. They can write this custom
thunk and use `-mretpoline-external-thunk` *in addition* to
`-mretpoline`. In this case, on x86-64 thu thunk names must be:
```
__llvm_external_retpoline_r11
```
or on 32-bit:
```
__llvm_external_retpoline_eax
__llvm_external_retpoline_ecx
__llvm_external_retpoline_edx
__llvm_external_retpoline_push
```
And the target of the retpoline is passed in the named register, or in
the case of the `push` suffix on the top of the stack via a `pushl`
instruction.

There is one other important source of indirect branches in x86 ELF
binaries: the PLT. These patches also include support for LLD to
generate PLT entries that perform a retpoline-style indirection.

The only other indirect branches remaining that we are aware of are
from precompiled runtimes (such as crt0.o and similar). The ones we
have found are not really attackable, and so we have not focused on
them here, but eventually these runtimes should also be replicated for
retpoline-ed configurations for completeness.

For kernels or other freestanding or fully static executables, the
compiler switch `-mretpoline` is sufficient to fully mitigate this
particular attack. For dynamic executables, you must compile *all*
libraries with `-mretpoline` and additionally link the dynamic
executable and all shared libraries with LLD and pass `-z
retpolineplt` (or use similar functionality from some other linker).
We strongly recommend also using `-z now` as non-lazy binding allows
the retpoline-mitigated PLT to be substantially smaller.

When manually apply similar transformations to `-mretpoline` to the
Linux kernel we observed very small performance hits to applications
running typic al workloads, and relatively minor hits (approximately
2%) even for extremely syscall-heavy applications. This is largely
due to the small number of indirect branches that occur in
performance sensitive paths of the kernel.

When using these patches on statically linked applications,
especially C++ applications, you should expect to see a much more
dramatic performance hit. For microbenchmarks that are switch,
indirect-, or virtual-call heavy we have seen overheads ranging from
10% to 50%.

However, real-world workloads exhibit substantially lower performance
impact. Notably, techniques such as PGO and ThinLTO dramatically
reduce the impact of hot indirect calls (by speculatively promoting
them to direct calls) and allow optimized search trees to be used to
lower switches. If you need to deploy these techniques in C++
applications, we *strongly* recommend that you ensure all hot call
targets are statically linked (avoiding PLT indirection) and use both
PGO and ThinLTO. Well tuned servers using all of these techniques saw
5% - 10% overhead from the use of retpoline.

We will add detailed documentation covering these components in
subsequent patches, but wanted to make the core functionality
available as soon as possible. Happy for more code review, but we'd
really like to get these patches landed and backported ASAP for
obvious reasons. We're planning to backport this to both 6.0 and 5.0
release streams and get a 5.0 release with just this cherry picked
ASAP for distros and vendors.

This patch is the work of a number of people over the past month:
Eric, Reid, Rui, and myself. I'm mailing it out as a single commit
due to the time sensitive nature of landing this and the need to
backport it. Huge thanks to everyone who helped out here, and
everyone at Intel who helped out in discussions about how to craft
this. Also, credit goes to Paul Turner (at Google, but not an LLVM
contributor) for much of the underlying retpoline design.

Reviewers: echristo, rnk, ruiu, craig.topper, DavidKreitzer

Subscribers: sanjoy, emaste, mcrosier, mgorny, mehdi_amini, hiraditya, llvm-commits

Differential Revision: https://reviews.llvm.org/D41723

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 842d113b 01-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r323948).

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 042b1c2e 24-Jan-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r323338).

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 30785c0e 06-Jan-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_60 r321788,
update build glue and version numbers.


# fe4fed2e 28-Dec-2017 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ trunk r321545,
update build glue and version numbers, add new intrinsics headers, and
update OptionalObsoleteFiles.inc.


# 2757ff7e 23-Dec-2017 Dimitry Andric <dim@FreeBSD.org>

Update clang, lld and llvm version numbers for r321414, and update build
glue.

# 02d2ad99 20-Dec-2017 Dimitry Andric <dim@FreeBSD.org>

Update generated config headers, and version numbers.

# 5c16e71d 30-Nov-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/17.x llvmorg-17.0.6-0-g6009708b4367

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.6-0-g6009708b4367.

PR: 273753
MFC after: 1 month


# b121cb00 16-Nov-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/17.x llvmorg-17.0.5-0-g98bfdac5ce82

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.5-0-g98bfdac5ce82.

PR: 273753
MFC after: 1 month


# bdb86d1a 21-Oct-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/17.x llvmorg-17.0.3-0-g888437e1b600

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.3-0-g888437e1b600.

PR: 273753
MFC after: 1 month


# 3bd749db 04-Oct-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/17.x llvmorg-17.0.2-0-gb2417f51dbbd

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.2-0-gb2417f51dbbd.

PR: 273753
MFC after: 1 month


# 4542f901 29-Sep-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/17.x llvmorg-17.0.1-25-g098e653a5bed

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.1-25-g098e653a5bed.

PR: 273753
MFC after: 1 month


# 8a4dda33 11-Sep-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/17.x llvmorg-17.0.0-rc4-10-g0176e8729ea4

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.0-rc4-10-g0176e8729ea4.

PR: 273753
MFC after: 1 month


# 06c3fb27 02-Sep-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-17-init-19304-gd0b54bb50e51

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project main llvmorg-17-init-19304-gd0b54bb50e51, the
last commit before the upstream release/17.x branch was created.

PR: 273753
MFC after: 1 month


# aee253d8 24-Aug-2023 Glen Barber <gjb@FreeBSD.org>

update main to 15

Approved by: re (implicit)
Sponsored by: GoFundMe https://www.gofundme.com/f/gjbbsd
Sponsored by: PayPal https://paypal.me/gjbbsd

# e048f78b 22-Jun-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/16.x llvmorg-16.0.6-0-g7cbf1a259152

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.6-0-g7cbf1a259152 (aka 16.0.6 release).

PR: 271047
MFC after: 1 month


# 2efbaac7 04-Jun-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/16.x llvmorg-16.0.5-0-g185b81e034ba

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.5-0-g185b81e034ba (aka 16.0.5 release).

PR: 271047
MFC after: 1 month


# a324c340 22-May-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/16.x llvmorg-16.0.4-0-gae42196bc493

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.4-0-gae42196bc493 (aka 16.0.4 release).

PR: 271047
MFC after: 1 month


# cbe9438c 05-May-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/16.x llvmorg-16.0.3-0-gda3cd333bea5

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.3-0-gda3cd333bea5 (aka 16.0.3 release).

PR: 271047
MFC after: 1 month


# 9e7101a8 22-Apr-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/16.x llvmorg-16.0.2-0-g18ddebe1a1a9

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.2-0-g18ddebe1a1a9 (aka 16.0.2 release).

PR: 271047
MFC after: 1 month


# 1ac55f4c 17-Apr-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/16.x llvmorg-16.0.1-0-gcd89023f7979

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.1-0-gcd89023f7979 (aka 16.0.1 release).

PR: 271047
MFC after: 1 month


# bdd1243d 14-Apr-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-16-init-18548-gb0daacf58f41

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16-init-18548-gb0daacf58f41.

PR: 271047
MFC after: 1 month


# 50d7464c 14-Jan-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/15.x llvmorg-15.0.7-0-g8dfdcc7b7bf6

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15.0.7-0-g8dfdcc7b7bf6.

PR: 265425
MFC after: 2 weeks


# f3fd488f 04-Dec-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/15.x llvmorg-15.0.6-0-g088f33605d8a

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15.0.6-0-g088f33605d8a.

PR: 265425
MFC after: 2 weeks


# 6246ae0b 16-Oct-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/15.x llvmorg-15.0.2-10-gf3c5289e7846

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15.0.2-10-gf3c5289e7846.

PR: 265425
MFC after: 2 weeks


# a4a491e2 10-Sep-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/15.x llvmorg-15.0.0-9-g1c73596d3454

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15.0.0-9-g1c73596d3454.

PR: 265425
MFC after: 2 weeks


# 61cfbce3 13-Aug-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/15.x llvmorg-15.0.0-rc2-40-gfbd2950d8d0d

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15.0.0-rc2-40-gfbd2950d8d0d.

PR: 265425
MFC after: 2 weeks


# 972a253a 27-Jul-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-15-init-17826-g1f8ae9d7e7e4

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15-init-17826-g1f8ae9d7e7e4, the last commit before
the upstream release/16.x branch was created.

PR: 265425
MFC after: 2 weeks


# fcaf7f86 24-Jul-2022 Dimitry Andric <dim@FreeBSD.org>

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


# 753f127f 14-Jul-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-15-init-16436-g18a6ab5b8d1f

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15-init-16436-g18a6ab5b8d1f.

PR: 265425
MFC after: 2 weeks


# 81ad6265 04-Jul-2022 Dimitry Andric <dim@FreeBSD.org>

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


# 56f451bb 12-Jun-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.5-0-gc12386ae247c

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.5-0-gc12386ae247c, aka 14.0.5 release.

PR: 261742
MFC after: 3 days


# 809922b0 05-Jun-2022 Dimitry Andric <dim@FreeBSD.org>

Update rest of llvm-project build glue for 14.0.4

I completely forgot about updating the generated llvm-project config
files, which also contain version numbers, etc. Sorry for the churn.

PR: 261742
Fixes: ab9d54731f43
MFC after: 3 days

# ab9d5473 04-Jun-2022 Dimitry Andric <dim@FreeBSD.org>

Bump versions llvm-project release/14.x llvmorg-14.0.4-0-g29f1039a7285

Somehow git rebase made this squashed commit disappear. Restore it.

PR: 261742
MFC after: 3 days

# 3a9a9c0c 28-Apr-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.3-0-g1f9140064dfb

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.3-0-g1f9140064dfb.

PR: 261742
MFC after: 2 weeks


# dbc822f3 29-Mar-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.0-2-g3f43d803382d

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-2-g3f43d803382d.

PR: 261742
MFC after: 2 weeks


# fb03ea46 17-Mar-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.0-rc4-2-gadd3ab7f4c8a

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-rc4-2-gadd3ab7f4c8a.

PR: 261742
MFC after: 2 weeks


# d781ede6 05-Mar-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.0-rc2-12-g09546e1b5103

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-rc2-12-g09546e1b5103.

PR: 261742
MFC after: 2 weeks


# d56accc7 18-Feb-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.0-rc1-74-g4dc3cb8e3255

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-rc1-74-g4dc3cb8e3255.

PR: 261742
MFC after: 2 weeks


# 1838bd0f 05-Feb-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14-init-18315-g190be5457c90

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14-init-18315-g190be5457c90.

PR: 261742
MFC after: 2 weeks


# 5e801ac6 20-Nov-2021 Dimitry Andric <dim@FreeBSD.org>

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


# fe6060f1 22-Aug-2021 Dimitry Andric <dim@FreeBSD.org>

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


# 23408297 18-Jun-2021 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project 12.0.1 rc2

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-12.0.1-rc2-0-ge7dac564cd0e, a.k.a. 12.0.1 rc2.

PR: 255570
MFC after: 6 weeks


# e8d8bef9 13-Jun-2021 Dimitry Andric <dim@FreeBSD.org>

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


# f9a66922 21-Jan-2021 Glen Barber <gjb@FreeBSD.org>

fix incorrect LLD_VERSION_STRING from previous commit

Reported by: Oliver Pinter
Sponsored by: Rubicon Communications, LLC ("Netgate")

# a53ce3fc 21-Jan-2021 Glen Barber <gjb@FreeBSD.org>

Bump CURRENT to 14.0

This one goes to 14.

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC ("Netgate")

# eaeb601b 03-Jan-2021 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
release/11.x llvmorg-11.0.1-rc2-0-g43ff75f2c3f (aka 11.0.1 rc2).

MFC after: 4 weeks
X-MFC-With: r364284


# 5f24ef21 06-Aug-2020 Dimitry Andric <dim@FreeBSD.org>

Update generated llvm-project related version headers, config.h files
and add a newly generated lldb Plugins.def file too.

# d65cd7a5 23-May-2020 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
llvmorg-10.0.1-rc1-0-gf79cd71e145 (aka 10.0.1 rc1).

MFC after: 3 weeks


# 0b37c159 25-Jan-2020 Dimitry Andric <dim@FreeBSD.org>

* Bump version numbers to 10.0.0
* Update UPDATING
* Update (Optional)ObsoleteFiles.inc
* Update VCS(Revision|Version) files
* Update generated config headers
* Update clang internal headers Makefile

# c14a5a88 22-Dec-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
9.0.1 final release c1a0a213378a458fbea1a5c77b315c7dce08fd05.

Release notes for llvm, clang, lld and libc++ 9.0.1 will become
available here:

https://releases.llvm.org/9.0.1/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.1/tools/clang/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.1/tools/lld/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.1/projects/libcxx/docs/ReleaseNotes.html

PR: 240629
MFC after: 1 month


# fb3a446a 06-Sep-2019 Dimitry Andric <dim@FreeBSD.org>

Add a VCSVersion.inc header with revision and repository defines,
similar to what upstream generates via CMake. Though for us it is
handier to have everything in one file.

# 6a82ac86 02-Sep-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb, and openmp
release_90 branch r370514, and update version numbers.


# 22f75ae7 02-Sep-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb, and openmp
release_90 branch r369369, and update version numbers.


# 86aa9539 23-Aug-2019 Dimitry Andric <dim@FreeBSD.org>

Regenerate config and version headers.

# 87c8ef55 20-Jul-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
8.0.1 final release r366581. The only functional change is a fix for a
mismerge of upstream r360816, which properly restores the r2 register
when unwinding on PowerPC64 (See https://reviews.freebsd.org/D20337).

Relnotes: yes
PR: 236062
MFC after: 3 days
X-MFC-With: r349004


# ec38f4f9 06-Jul-2019 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt, libc++,
libunwind and openmp to the upstream release_80 branch r364487
(effectively, 8.0.1 rc3). The 8.0.1 release will most likely
have no further changes.

MFC after: 1 week
X-MFC-With: r349004


# efc5c442 12-Jun-2019 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt, libc++,
libunwind and openmp to the upstream release_80 branch r363030
(effectively, 8.0.1 rc2). The 8.0.1 release should follow this within a
week or so.

MFC after: 2 weeks


# c3e6b9d3 20-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Pull in r352826 from upstream lld trunk (by Fangrui Song):

[ELF] Support --{,no-}allow-shlib-undefined

Summary:
In ld.bfd/gold, --no-allow-shlib-undefined is the default when
linking an executable. This patch implements a check to error on
undefined symbols in a shared object, if all of its DT_NEEDED entries
are seen.

Our approach resembles the one used in gold, achieves a good balance
to be useful but not too smart (ld.bfd traces all DSOs and emulates
the behavior of a dynamic linker to catch more cases).

The error is issued based on the symbol table, different from
undefined reference errors issued for relocations. It is most
effective when there are DSOs that were not linked with -z defs (e.g.
when static sanitizers runtime is used).

gold has a comment that some system libraries on GNU/Linux may have
spurious undefined references and thus system libraries should be
excluded (https://sourceware.org/bugzilla/show_bug.cgi?id=6811). The
story may have changed now but we make --allow-shlib-undefined the
default for now. Its interaction with -shared can be discussed in the
future.

Reviewers: ruiu, grimar, pcc, espindola

Reviewed By: ruiu

Subscribers: joerg, emaste, arichardson, llvm-commits

Differential Revision: https://reviews.llvm.org/D57385

Pull in r352943 from upstream lld trunk (by Fangrui Song):

[ELF] Default to --no-allow-shlib-undefined for executables

Summary:
This follows the ld.bfd/gold behavior.

The error check is useful as it captures a common type of ld.so
undefined symbol errors as link-time errors:

// a.cc => a.so (not linked with -z defs)
void f(); // f is undefined
void g() { f(); }

// b.cc => executable with a DT_NEEDED entry on a.so
void g();
int main() { g(); }

// ld.so errors when g() is executed (lazy binding) or when the program is started (-z now)
// symbol lookup error: ... undefined symbol: f

Reviewers: ruiu, grimar, pcc, espindola

Reviewed By: ruiu

Subscribers: llvm-commits, emaste, arichardson

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D57569

Together, these add support for --no-allow-shlib-undefined, and make it
the default for executables, so they will fail to link if any symbols
from needed shared libraries are undefined.

Reported by: jbeich
PR: 236062, 236141
MFC after: 1 month
X-MFC-With: r344779

# fb7e42b9 20-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
8.0.0 final release r356365. There were no functional changes since the
most recent merge, of 8.0.0 rc5.

Release notes for llvm, clang, lld and libc++ 8.0.0 are now available:

https://llvm.org/releases/8.0.0/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/tools/clang/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/tools/lld/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/projects/libcxx/docs/ReleaseNotes.html

PR: 236062
MFC after: 1 month
X-MFC-With: r344779


# 2352f970 14-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, and lldb
release_80 branch r356034 (effectively, 8.0.0 rc5), resolve conflicts,
and bump version numbers.

PR: 236062
MFC after: 1 month
X-MFC-With: r344779


# b3ed818e 08-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r355677 (effectively, 8.0.0 rc4), resolve conflicts, and bump version
numbers.

PR: 236062
MFC after: 1 month
X-MFC-With: r344779


# 3087b115 04-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r355313, resolve conflicts, and bump version numbers.


# da18572f 25-Feb-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r354799, resolve conflicts, and bump version numbers.


# 640dd76f 15-Feb-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r354130, resolve conflicts, and bump version numbers.


# c8630eab 05-Feb-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r353167, resolve conflicts, and bump version numbers.


# af44a011 22-Jan-2019 Dimitry Andric <dim@FreeBSD.org>

Now for the release_80 branch, update version numbers for llvm, clang
and lld, and regenerate config headers.

# 0bf31f1f 20-Jan-2019 Dimitry Andric <dim@FreeBSD.org>

Update version numbers, and regenerate config headers for llvm, clang,
lld and lldb. Update ObsoleteFiles.inc and OptionalObsoleteFiles.inc.

# 176fdeee 15-Dec-2018 Dimitry Andric <dim@FreeBSD.org>

Update clang, llvm, lld, lldb, compiler-rt and libc++ version number to
7.0.1 release r349250. There were no functional changes since the 7.0.1
rc3 import.

PR: 230240, 230355
Relnotes: yes
MFC after: 2 months
X-MFC-With: r341825


# 0b9890fc 09-Dec-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r348686 (effectively 7.0.1 rc3), resolve conflicts, and bump version
numbers.

PR: 230240, 230355


# 68948600 04-Nov-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r346007 (effectively 7.0.1 rc2), resolve conflicts, and bump version
numbers.

PR: 230240, 230355


# c6879c6c 23-Oct-2018 Dimitry Andric <dim@FreeBSD.org>

Merge ^/head r339015 through r339669.


# b0bffd12 20-Oct-2018 Ed Maste <emaste@FreeBSD.org>

Bump LLD_REVISION_STRING for 13-CURRENT

# b371a9f0 11-Oct-2018 Ed Maste <emaste@FreeBSD.org>

lld: set sh_link and sh_info for .rela.plt sections

ELF spec says that for SHT_REL and SHT_RELA sh_link should reference the
associated string table and sh_info should reference the "section to
which the relocation applies." ELF Tool Chain's elfcopy / strip use
this (in part) to control whether or not the relocation entry is copied
to the output.

LLVM PR 37538 https://bugs.llvm.org/show_bug.cgi?id=37538

Approved by: re (kib)
Obtained from: llvm r344226 (backported for 6.0)

# 38fb4010 17-Sep-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ 7.0.0 release
r342383, and bump version numbers.

PR: 230240, 230355


# c826f0db 11-Sep-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r341916, resolve conflicts, and bump version numbers.

PR: 230240, 230355


# 8ba00cf9 29-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r340910, resolve conflicts, and bump version numbers.

PR: 230240, 230355


# 7726714d 17-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r339999, resolve conflicts, and bump version numbers.

PR: 230240,230355


# 3beb5372 11-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r339355, resolve conflicts, and bump version numbers.


# 84ba35dc 04-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Bump clang and lld upstream revision numbers.

# 0fecf001 02-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Bump revisions to r338536, and also bump lld version again.

# 837f3385 31-Jul-2018 Ed Maste <emaste@FreeBSD.org>

bump lld version number after r336972 arm(v7) VFP tag support

Reported by: kevans
Sponsored by: The FreeBSD Foundation

# 6dfa117f 31-Jul-2018 Dimitry Andric <dim@FreeBSD.org>

Update llvm/clang version numbers in various files.

# fbfca78e 30-Jun-2018 Dimitry Andric <dim@FreeBSD.org>

Follow-up to r335799 (llvm/clang 6.0.1 update), by regenerating various
headers with new version information defines.

MFC after: 2 weeks
X-MFC-With: r335799

# 6ccc06f6 29-Jun-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.1 release (upstream r335540).

Relnotes: yes
MFC after: 2 weeks


# 19703503 09-May-2018 Ed Maste <emaste@FreeBSD.org>

lld: Omit PT_NOTE for SHT_NOTE without SHF_ALLOC

A non-alloc note section should not have a PT_NOTE program header.

Found while linking ghc (Haskell compiler) with lld on FreeBSD. Haskell
emits a .debug-ghc-link-info note section (as the name suggests, it
contains link info) as a SHT_NOTE section without SHF_ALLOC set.

For this case ld.bfd does not emit a PT_NOTE segment for
.debug-ghc-link-info. lld previously emitted a PT_NOTE with p_vaddr = 0
and FreeBSD's rtld segfaulted when trying to parse a note at address 0.

LLVM PR: https://llvm.org/pr37361
LLVM review: https://reviews.llvm.org/D46623

PR: 226872
Reviewed by: dim
Sponsored by: The FreeBSD Foundation

# 08730804 19-Apr-2018 Ed Maste <emaste@FreeBSD.org>

lld: use correct number of digits in __FreeBSD_version-style ID

__FreeBSD_version-style IDs should have 5 digits following the major.

# 12881601 17-Apr-2018 Ed Maste <emaste@FreeBSD.org>

lld: add a __FreeBSD_version-style identifier to version

This will faciliate a WITH_SYSTEM_LINKER option.

Reviewed by: dim
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D15110

# c5a4cd4f 04-Mar-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 release (upstream r326565).

Release notes for llvm, clang and lld will be available here soon:
<http://releases.llvm.org/6.0.0/docs/ReleaseNotes.html>
<http://releases.llvm.org/6.0.0/tools/clang/docs/ReleaseNotes.html>
<http://releases.llvm.org/6.0.0/tools/lld/docs/ReleaseNotes.html>

Relnotes: yes
MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 4f8786af 25-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r325932). This corresponds to 6.0.0 rc3.

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 954b921d 16-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r325330).

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 07577dfe 02-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r324090).

This introduces retpoline support, with the -mretpoline flag. The
upstream initial commit message (r323155 by Chandler Carruth) contains
quite a bit of explanation. Quoting:

Introduce the "retpoline" x86 mitigation technique for variant #2 of
the speculative execution vulnerabilities disclosed today,
specifically identified by CVE-2017-5715, "Branch Target Injection",
and is one of the two halves to Spectre.

Summary:
First, we need to explain the core of the vulnerability. Note that
this is a very incomplete description, please see the Project Zero
blog post for details:
https://googleprojectzero.blogspot.com/2018/01/reading-privileged-memory-with-side.html

The basis for branch target injection is to direct speculative
execution of the processor to some "gadget" of executable code by
poisoning the prediction of indirect branches with the address of
that gadget. The gadget in turn contains an operation that provides a
side channel for reading data. Most commonly, this will look like a
load of secret data followed by a branch on the loaded value and then
a load of some predictable cache line. The attacker then uses timing
of the processors cache to determine which direction the branch took
*in the speculative execution*, and in turn what one bit of the
loaded value was. Due to the nature of these timing side channels and
the branch predictor on Intel processors, this allows an attacker to
leak data only accessible to a privileged domain (like the kernel)
back into an unprivileged domain.

The goal is simple: avoid generating code which contains an indirect
branch that could have its prediction poisoned by an attacker. In
many cases, the compiler can simply use directed conditional branches
and a small search tree. LLVM already has support for lowering
switches in this way and the first step of this patch is to disable
jump-table lowering of switches and introduce a pass to rewrite
explicit indirectbr sequences into a switch over integers.

However, there is no fully general alternative to indirect calls. We
introduce a new construct we call a "retpoline" to implement indirect
calls in a non-speculatable way. It can be thought of loosely as a
trampoline for indirect calls which uses the RET instruction on x86.
Further, we arrange for a specific call->ret sequence which ensures
the processor predicts the return to go to a controlled, known
location. The retpoline then "smashes" the return address pushed onto
the stack by the call with the desired target of the original
indirect call. The result is a predicted return to the next
instruction after a call (which can be used to trap speculative
execution within an infinite loop) and an actual indirect branch to
an arbitrary address.

On 64-bit x86 ABIs, this is especially easily done in the compiler by
using a guaranteed scratch register to pass the target into this
device. For 32-bit ABIs there isn't a guaranteed scratch register
and so several different retpoline variants are introduced to use a
scratch register if one is available in the calling convention and to
otherwise use direct stack push/pop sequences to pass the target
address.

This "retpoline" mitigation is fully described in the following blog
post: https://support.google.com/faqs/answer/7625886

We also support a target feature that disables emission of the
retpoline thunk by the compiler to allow for custom thunks if users
want them. These are particularly useful in environments like
kernels that routinely do hot-patching on boot and want to hot-patch
their thunk to different code sequences. They can write this custom
thunk and use `-mretpoline-external-thunk` *in addition* to
`-mretpoline`. In this case, on x86-64 thu thunk names must be:
```
__llvm_external_retpoline_r11
```
or on 32-bit:
```
__llvm_external_retpoline_eax
__llvm_external_retpoline_ecx
__llvm_external_retpoline_edx
__llvm_external_retpoline_push
```
And the target of the retpoline is passed in the named register, or in
the case of the `push` suffix on the top of the stack via a `pushl`
instruction.

There is one other important source of indirect branches in x86 ELF
binaries: the PLT. These patches also include support for LLD to
generate PLT entries that perform a retpoline-style indirection.

The only other indirect branches remaining that we are aware of are
from precompiled runtimes (such as crt0.o and similar). The ones we
have found are not really attackable, and so we have not focused on
them here, but eventually these runtimes should also be replicated for
retpoline-ed configurations for completeness.

For kernels or other freestanding or fully static executables, the
compiler switch `-mretpoline` is sufficient to fully mitigate this
particular attack. For dynamic executables, you must compile *all*
libraries with `-mretpoline` and additionally link the dynamic
executable and all shared libraries with LLD and pass `-z
retpolineplt` (or use similar functionality from some other linker).
We strongly recommend also using `-z now` as non-lazy binding allows
the retpoline-mitigated PLT to be substantially smaller.

When manually apply similar transformations to `-mretpoline` to the
Linux kernel we observed very small performance hits to applications
running typic al workloads, and relatively minor hits (approximately
2%) even for extremely syscall-heavy applications. This is largely
due to the small number of indirect branches that occur in
performance sensitive paths of the kernel.

When using these patches on statically linked applications,
especially C++ applications, you should expect to see a much more
dramatic performance hit. For microbenchmarks that are switch,
indirect-, or virtual-call heavy we have seen overheads ranging from
10% to 50%.

However, real-world workloads exhibit substantially lower performance
impact. Notably, techniques such as PGO and ThinLTO dramatically
reduce the impact of hot indirect calls (by speculatively promoting
them to direct calls) and allow optimized search trees to be used to
lower switches. If you need to deploy these techniques in C++
applications, we *strongly* recommend that you ensure all hot call
targets are statically linked (avoiding PLT indirection) and use both
PGO and ThinLTO. Well tuned servers using all of these techniques saw
5% - 10% overhead from the use of retpoline.

We will add detailed documentation covering these components in
subsequent patches, but wanted to make the core functionality
available as soon as possible. Happy for more code review, but we'd
really like to get these patches landed and backported ASAP for
obvious reasons. We're planning to backport this to both 6.0 and 5.0
release streams and get a 5.0 release with just this cherry picked
ASAP for distros and vendors.

This patch is the work of a number of people over the past month:
Eric, Reid, Rui, and myself. I'm mailing it out as a single commit
due to the time sensitive nature of landing this and the need to
backport it. Huge thanks to everyone who helped out here, and
everyone at Intel who helped out in discussions about how to craft
this. Also, credit goes to Paul Turner (at Google, but not an LLVM
contributor) for much of the underlying retpoline design.

Reviewers: echristo, rnk, ruiu, craig.topper, DavidKreitzer

Subscribers: sanjoy, emaste, mcrosier, mgorny, mehdi_amini, hiraditya, llvm-commits

Differential Revision: https://reviews.llvm.org/D41723

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 842d113b 01-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r323948).

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 042b1c2e 24-Jan-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r323338).

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 30785c0e 06-Jan-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_60 r321788,
update build glue and version numbers.


# fe4fed2e 28-Dec-2017 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ trunk r321545,
update build glue and version numbers, add new intrinsics headers, and
update OptionalObsoleteFiles.inc.


# 2757ff7e 23-Dec-2017 Dimitry Andric <dim@FreeBSD.org>

Update clang, lld and llvm version numbers for r321414, and update build
glue.

# 02d2ad99 20-Dec-2017 Dimitry Andric <dim@FreeBSD.org>

Update generated config headers, and version numbers.

# aee253d8 24-Aug-2023 Glen Barber <gjb@FreeBSD.org>

update main to 15

Approved by: re (implicit)
Sponsored by: GoFundMe https://www.gofundme.com/f/gjbbsd
Sponsored by: PayPal https://paypal.me/gjbbsd


# e048f78b 22-Jun-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/16.x llvmorg-16.0.6-0-g7cbf1a259152

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.6-0-g7cbf1a259152 (aka 16.0.6 release).

PR: 271047
MFC after: 1 month


# 2efbaac7 04-Jun-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/16.x llvmorg-16.0.5-0-g185b81e034ba

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.5-0-g185b81e034ba (aka 16.0.5 release).

PR: 271047
MFC after: 1 month


# a324c340 22-May-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/16.x llvmorg-16.0.4-0-gae42196bc493

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.4-0-gae42196bc493 (aka 16.0.4 release).

PR: 271047
MFC after: 1 month


# cbe9438c 05-May-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/16.x llvmorg-16.0.3-0-gda3cd333bea5

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.3-0-gda3cd333bea5 (aka 16.0.3 release).

PR: 271047
MFC after: 1 month


# 9e7101a8 22-Apr-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/16.x llvmorg-16.0.2-0-g18ddebe1a1a9

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.2-0-g18ddebe1a1a9 (aka 16.0.2 release).

PR: 271047
MFC after: 1 month


# 1ac55f4c 17-Apr-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/16.x llvmorg-16.0.1-0-gcd89023f7979

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16.0.1-0-gcd89023f7979 (aka 16.0.1 release).

PR: 271047
MFC after: 1 month


# bdd1243d 14-Apr-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-16-init-18548-gb0daacf58f41

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-16-init-18548-gb0daacf58f41.

PR: 271047
MFC after: 1 month


# 50d7464c 14-Jan-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/15.x llvmorg-15.0.7-0-g8dfdcc7b7bf6

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15.0.7-0-g8dfdcc7b7bf6.

PR: 265425
MFC after: 2 weeks


# f3fd488f 04-Dec-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/15.x llvmorg-15.0.6-0-g088f33605d8a

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15.0.6-0-g088f33605d8a.

PR: 265425
MFC after: 2 weeks


# 6246ae0b 16-Oct-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/15.x llvmorg-15.0.2-10-gf3c5289e7846

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15.0.2-10-gf3c5289e7846.

PR: 265425
MFC after: 2 weeks


# a4a491e2 10-Sep-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/15.x llvmorg-15.0.0-9-g1c73596d3454

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15.0.0-9-g1c73596d3454.

PR: 265425
MFC after: 2 weeks


# 61cfbce3 13-Aug-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/15.x llvmorg-15.0.0-rc2-40-gfbd2950d8d0d

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15.0.0-rc2-40-gfbd2950d8d0d.

PR: 265425
MFC after: 2 weeks


# 972a253a 27-Jul-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-15-init-17826-g1f8ae9d7e7e4

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15-init-17826-g1f8ae9d7e7e4, the last commit before
the upstream release/16.x branch was created.

PR: 265425
MFC after: 2 weeks


# fcaf7f86 24-Jul-2022 Dimitry Andric <dim@FreeBSD.org>

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


# 753f127f 14-Jul-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-15-init-16436-g18a6ab5b8d1f

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15-init-16436-g18a6ab5b8d1f.

PR: 265425
MFC after: 2 weeks


# 81ad6265 04-Jul-2022 Dimitry Andric <dim@FreeBSD.org>

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


# 56f451bb 12-Jun-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.5-0-gc12386ae247c

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.5-0-gc12386ae247c, aka 14.0.5 release.

PR: 261742
MFC after: 3 days


# 809922b0 05-Jun-2022 Dimitry Andric <dim@FreeBSD.org>

Update rest of llvm-project build glue for 14.0.4

I completely forgot about updating the generated llvm-project config
files, which also contain version numbers, etc. Sorry for the churn.

PR: 261742
Fixes: ab9d54731f43
MFC after: 3 days

# ab9d5473 04-Jun-2022 Dimitry Andric <dim@FreeBSD.org>

Bump versions llvm-project release/14.x llvmorg-14.0.4-0-g29f1039a7285

Somehow git rebase made this squashed commit disappear. Restore it.

PR: 261742
MFC after: 3 days

# 3a9a9c0c 28-Apr-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.3-0-g1f9140064dfb

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.3-0-g1f9140064dfb.

PR: 261742
MFC after: 2 weeks


# dbc822f3 29-Mar-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.0-2-g3f43d803382d

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-2-g3f43d803382d.

PR: 261742
MFC after: 2 weeks


# fb03ea46 17-Mar-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.0-rc4-2-gadd3ab7f4c8a

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-rc4-2-gadd3ab7f4c8a.

PR: 261742
MFC after: 2 weeks


# d781ede6 05-Mar-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.0-rc2-12-g09546e1b5103

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-rc2-12-g09546e1b5103.

PR: 261742
MFC after: 2 weeks


# d56accc7 18-Feb-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.0-rc1-74-g4dc3cb8e3255

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-rc1-74-g4dc3cb8e3255.

PR: 261742
MFC after: 2 weeks


# 1838bd0f 05-Feb-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14-init-18315-g190be5457c90

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14-init-18315-g190be5457c90.

PR: 261742
MFC after: 2 weeks


# 5e801ac6 20-Nov-2021 Dimitry Andric <dim@FreeBSD.org>

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


# fe6060f1 22-Aug-2021 Dimitry Andric <dim@FreeBSD.org>

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


# 23408297 18-Jun-2021 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project 12.0.1 rc2

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-12.0.1-rc2-0-ge7dac564cd0e, a.k.a. 12.0.1 rc2.

PR: 255570
MFC after: 6 weeks


# e8d8bef9 13-Jun-2021 Dimitry Andric <dim@FreeBSD.org>

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


# f9a66922 21-Jan-2021 Glen Barber <gjb@FreeBSD.org>

fix incorrect LLD_VERSION_STRING from previous commit

Reported by: Oliver Pinter
Sponsored by: Rubicon Communications, LLC ("Netgate")

# a53ce3fc 21-Jan-2021 Glen Barber <gjb@FreeBSD.org>

Bump CURRENT to 14.0

This one goes to 14.

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC ("Netgate")

# eaeb601b 03-Jan-2021 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
release/11.x llvmorg-11.0.1-rc2-0-g43ff75f2c3f (aka 11.0.1 rc2).

MFC after: 4 weeks
X-MFC-With: r364284


# 5f24ef21 06-Aug-2020 Dimitry Andric <dim@FreeBSD.org>

Update generated llvm-project related version headers, config.h files
and add a newly generated lldb Plugins.def file too.

# d65cd7a5 23-May-2020 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
llvmorg-10.0.1-rc1-0-gf79cd71e145 (aka 10.0.1 rc1).

MFC after: 3 weeks


# 0b37c159 25-Jan-2020 Dimitry Andric <dim@FreeBSD.org>

* Bump version numbers to 10.0.0
* Update UPDATING
* Update (Optional)ObsoleteFiles.inc
* Update VCS(Revision|Version) files
* Update generated config headers
* Update clang internal headers Makefile

# c14a5a88 22-Dec-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
9.0.1 final release c1a0a213378a458fbea1a5c77b315c7dce08fd05.

Release notes for llvm, clang, lld and libc++ 9.0.1 will become
available here:

https://releases.llvm.org/9.0.1/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.1/tools/clang/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.1/tools/lld/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.1/projects/libcxx/docs/ReleaseNotes.html

PR: 240629
MFC after: 1 month


# fb3a446a 06-Sep-2019 Dimitry Andric <dim@FreeBSD.org>

Add a VCSVersion.inc header with revision and repository defines,
similar to what upstream generates via CMake. Though for us it is
handier to have everything in one file.

# 6a82ac86 02-Sep-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb, and openmp
release_90 branch r370514, and update version numbers.


# 22f75ae7 02-Sep-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb, and openmp
release_90 branch r369369, and update version numbers.


# 86aa9539 23-Aug-2019 Dimitry Andric <dim@FreeBSD.org>

Regenerate config and version headers.

# 87c8ef55 20-Jul-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
8.0.1 final release r366581. The only functional change is a fix for a
mismerge of upstream r360816, which properly restores the r2 register
when unwinding on PowerPC64 (See https://reviews.freebsd.org/D20337).

Relnotes: yes
PR: 236062
MFC after: 3 days
X-MFC-With: r349004


# ec38f4f9 06-Jul-2019 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt, libc++,
libunwind and openmp to the upstream release_80 branch r364487
(effectively, 8.0.1 rc3). The 8.0.1 release will most likely
have no further changes.

MFC after: 1 week
X-MFC-With: r349004


# efc5c442 12-Jun-2019 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt, libc++,
libunwind and openmp to the upstream release_80 branch r363030
(effectively, 8.0.1 rc2). The 8.0.1 release should follow this within a
week or so.

MFC after: 2 weeks


# c3e6b9d3 20-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Pull in r352826 from upstream lld trunk (by Fangrui Song):

[ELF] Support --{,no-}allow-shlib-undefined

Summary:
In ld.bfd/gold, --no-allow-shlib-undefined is the default when
linking an executable. This patch implements a check to error on
undefined symbols in a shared object, if all of its DT_NEEDED entries
are seen.

Our approach resembles the one used in gold, achieves a good balance
to be useful but not too smart (ld.bfd traces all DSOs and emulates
the behavior of a dynamic linker to catch more cases).

The error is issued based on the symbol table, different from
undefined reference errors issued for relocations. It is most
effective when there are DSOs that were not linked with -z defs (e.g.
when static sanitizers runtime is used).

gold has a comment that some system libraries on GNU/Linux may have
spurious undefined references and thus system libraries should be
excluded (https://sourceware.org/bugzilla/show_bug.cgi?id=6811). The
story may have changed now but we make --allow-shlib-undefined the
default for now. Its interaction with -shared can be discussed in the
future.

Reviewers: ruiu, grimar, pcc, espindola

Reviewed By: ruiu

Subscribers: joerg, emaste, arichardson, llvm-commits

Differential Revision: https://reviews.llvm.org/D57385

Pull in r352943 from upstream lld trunk (by Fangrui Song):

[ELF] Default to --no-allow-shlib-undefined for executables

Summary:
This follows the ld.bfd/gold behavior.

The error check is useful as it captures a common type of ld.so
undefined symbol errors as link-time errors:

// a.cc => a.so (not linked with -z defs)
void f(); // f is undefined
void g() { f(); }

// b.cc => executable with a DT_NEEDED entry on a.so
void g();
int main() { g(); }

// ld.so errors when g() is executed (lazy binding) or when the program is started (-z now)
// symbol lookup error: ... undefined symbol: f

Reviewers: ruiu, grimar, pcc, espindola

Reviewed By: ruiu

Subscribers: llvm-commits, emaste, arichardson

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D57569

Together, these add support for --no-allow-shlib-undefined, and make it
the default for executables, so they will fail to link if any symbols
from needed shared libraries are undefined.

Reported by: jbeich
PR: 236062, 236141
MFC after: 1 month
X-MFC-With: r344779

# fb7e42b9 20-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
8.0.0 final release r356365. There were no functional changes since the
most recent merge, of 8.0.0 rc5.

Release notes for llvm, clang, lld and libc++ 8.0.0 are now available:

https://llvm.org/releases/8.0.0/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/tools/clang/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/tools/lld/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/projects/libcxx/docs/ReleaseNotes.html

PR: 236062
MFC after: 1 month
X-MFC-With: r344779


# 2352f970 14-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, and lldb
release_80 branch r356034 (effectively, 8.0.0 rc5), resolve conflicts,
and bump version numbers.

PR: 236062
MFC after: 1 month
X-MFC-With: r344779


# b3ed818e 08-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r355677 (effectively, 8.0.0 rc4), resolve conflicts, and bump version
numbers.

PR: 236062
MFC after: 1 month
X-MFC-With: r344779


# 3087b115 04-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r355313, resolve conflicts, and bump version numbers.


# da18572f 25-Feb-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r354799, resolve conflicts, and bump version numbers.


# 640dd76f 15-Feb-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r354130, resolve conflicts, and bump version numbers.


# c8630eab 05-Feb-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r353167, resolve conflicts, and bump version numbers.


# af44a011 22-Jan-2019 Dimitry Andric <dim@FreeBSD.org>

Now for the release_80 branch, update version numbers for llvm, clang
and lld, and regenerate config headers.

# 0bf31f1f 20-Jan-2019 Dimitry Andric <dim@FreeBSD.org>

Update version numbers, and regenerate config headers for llvm, clang,
lld and lldb. Update ObsoleteFiles.inc and OptionalObsoleteFiles.inc.

# 176fdeee 15-Dec-2018 Dimitry Andric <dim@FreeBSD.org>

Update clang, llvm, lld, lldb, compiler-rt and libc++ version number to
7.0.1 release r349250. There were no functional changes since the 7.0.1
rc3 import.

PR: 230240, 230355
Relnotes: yes
MFC after: 2 months
X-MFC-With: r341825


# 0b9890fc 09-Dec-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r348686 (effectively 7.0.1 rc3), resolve conflicts, and bump version
numbers.

PR: 230240, 230355


# 68948600 04-Nov-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r346007 (effectively 7.0.1 rc2), resolve conflicts, and bump version
numbers.

PR: 230240, 230355


# c6879c6c 23-Oct-2018 Dimitry Andric <dim@FreeBSD.org>

Merge ^/head r339015 through r339669.


# b0bffd12 20-Oct-2018 Ed Maste <emaste@FreeBSD.org>

Bump LLD_REVISION_STRING for 13-CURRENT

# b371a9f0 11-Oct-2018 Ed Maste <emaste@FreeBSD.org>

lld: set sh_link and sh_info for .rela.plt sections

ELF spec says that for SHT_REL and SHT_RELA sh_link should reference the
associated string table and sh_info should reference the "section to
which the relocation applies." ELF Tool Chain's elfcopy / strip use
this (in part) to control whether or not the relocation entry is copied
to the output.

LLVM PR 37538 https://bugs.llvm.org/show_bug.cgi?id=37538

Approved by: re (kib)
Obtained from: llvm r344226 (backported for 6.0)

# 38fb4010 17-Sep-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ 7.0.0 release
r342383, and bump version numbers.

PR: 230240, 230355


# c826f0db 11-Sep-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r341916, resolve conflicts, and bump version numbers.

PR: 230240, 230355


# 8ba00cf9 29-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r340910, resolve conflicts, and bump version numbers.

PR: 230240, 230355


# 7726714d 17-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r339999, resolve conflicts, and bump version numbers.

PR: 230240,230355


# 3beb5372 11-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r339355, resolve conflicts, and bump version numbers.


# 84ba35dc 04-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Bump clang and lld upstream revision numbers.

# 0fecf001 02-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Bump revisions to r338536, and also bump lld version again.

# 837f3385 31-Jul-2018 Ed Maste <emaste@FreeBSD.org>

bump lld version number after r336972 arm(v7) VFP tag support

Reported by: kevans
Sponsored by: The FreeBSD Foundation

# 6dfa117f 31-Jul-2018 Dimitry Andric <dim@FreeBSD.org>

Update llvm/clang version numbers in various files.

# fbfca78e 30-Jun-2018 Dimitry Andric <dim@FreeBSD.org>

Follow-up to r335799 (llvm/clang 6.0.1 update), by regenerating various
headers with new version information defines.

MFC after: 2 weeks
X-MFC-With: r335799

# 6ccc06f6 29-Jun-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.1 release (upstream r335540).

Relnotes: yes
MFC after: 2 weeks


# 19703503 09-May-2018 Ed Maste <emaste@FreeBSD.org>

lld: Omit PT_NOTE for SHT_NOTE without SHF_ALLOC

A non-alloc note section should not have a PT_NOTE program header.

Found while linking ghc (Haskell compiler) with lld on FreeBSD. Haskell
emits a .debug-ghc-link-info note section (as the name suggests, it
contains link info) as a SHT_NOTE section without SHF_ALLOC set.

For this case ld.bfd does not emit a PT_NOTE segment for
.debug-ghc-link-info. lld previously emitted a PT_NOTE with p_vaddr = 0
and FreeBSD's rtld segfaulted when trying to parse a note at address 0.

LLVM PR: https://llvm.org/pr37361
LLVM review: https://reviews.llvm.org/D46623

PR: 226872
Reviewed by: dim
Sponsored by: The FreeBSD Foundation

# 08730804 19-Apr-2018 Ed Maste <emaste@FreeBSD.org>

lld: use correct number of digits in __FreeBSD_version-style ID

__FreeBSD_version-style IDs should have 5 digits following the major.

# 12881601 17-Apr-2018 Ed Maste <emaste@FreeBSD.org>

lld: add a __FreeBSD_version-style identifier to version

This will faciliate a WITH_SYSTEM_LINKER option.

Reviewed by: dim
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D15110

# c5a4cd4f 04-Mar-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 release (upstream r326565).

Release notes for llvm, clang and lld will be available here soon:
<http://releases.llvm.org/6.0.0/docs/ReleaseNotes.html>
<http://releases.llvm.org/6.0.0/tools/clang/docs/ReleaseNotes.html>
<http://releases.llvm.org/6.0.0/tools/lld/docs/ReleaseNotes.html>

Relnotes: yes
MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 4f8786af 25-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r325932). This corresponds to 6.0.0 rc3.

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 954b921d 16-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r325330).

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 07577dfe 02-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r324090).

This introduces retpoline support, with the -mretpoline flag. The
upstream initial commit message (r323155 by Chandler Carruth) contains
quite a bit of explanation. Quoting:

Introduce the "retpoline" x86 mitigation technique for variant #2 of
the speculative execution vulnerabilities disclosed today,
specifically identified by CVE-2017-5715, "Branch Target Injection",
and is one of the two halves to Spectre.

Summary:
First, we need to explain the core of the vulnerability. Note that
this is a very incomplete description, please see the Project Zero
blog post for details:
https://googleprojectzero.blogspot.com/2018/01/reading-privileged-memory-with-side.html

The basis for branch target injection is to direct speculative
execution of the processor to some "gadget" of executable code by
poisoning the prediction of indirect branches with the address of
that gadget. The gadget in turn contains an operation that provides a
side channel for reading data. Most commonly, this will look like a
load of secret data followed by a branch on the loaded value and then
a load of some predictable cache line. The attacker then uses timing
of the processors cache to determine which direction the branch took
*in the speculative execution*, and in turn what one bit of the
loaded value was. Due to the nature of these timing side channels and
the branch predictor on Intel processors, this allows an attacker to
leak data only accessible to a privileged domain (like the kernel)
back into an unprivileged domain.

The goal is simple: avoid generating code which contains an indirect
branch that could have its prediction poisoned by an attacker. In
many cases, the compiler can simply use directed conditional branches
and a small search tree. LLVM already has support for lowering
switches in this way and the first step of this patch is to disable
jump-table lowering of switches and introduce a pass to rewrite
explicit indirectbr sequences into a switch over integers.

However, there is no fully general alternative to indirect calls. We
introduce a new construct we call a "retpoline" to implement indirect
calls in a non-speculatable way. It can be thought of loosely as a
trampoline for indirect calls which uses the RET instruction on x86.
Further, we arrange for a specific call->ret sequence which ensures
the processor predicts the return to go to a controlled, known
location. The retpoline then "smashes" the return address pushed onto
the stack by the call with the desired target of the original
indirect call. The result is a predicted return to the next
instruction after a call (which can be used to trap speculative
execution within an infinite loop) and an actual indirect branch to
an arbitrary address.

On 64-bit x86 ABIs, this is especially easily done in the compiler by
using a guaranteed scratch register to pass the target into this
device. For 32-bit ABIs there isn't a guaranteed scratch register
and so several different retpoline variants are introduced to use a
scratch register if one is available in the calling convention and to
otherwise use direct stack push/pop sequences to pass the target
address.

This "retpoline" mitigation is fully described in the following blog
post: https://support.google.com/faqs/answer/7625886

We also support a target feature that disables emission of the
retpoline thunk by the compiler to allow for custom thunks if users
want them. These are particularly useful in environments like
kernels that routinely do hot-patching on boot and want to hot-patch
their thunk to different code sequences. They can write this custom
thunk and use `-mretpoline-external-thunk` *in addition* to
`-mretpoline`. In this case, on x86-64 thu thunk names must be:
```
__llvm_external_retpoline_r11
```
or on 32-bit:
```
__llvm_external_retpoline_eax
__llvm_external_retpoline_ecx
__llvm_external_retpoline_edx
__llvm_external_retpoline_push
```
And the target of the retpoline is passed in the named register, or in
the case of the `push` suffix on the top of the stack via a `pushl`
instruction.

There is one other important source of indirect branches in x86 ELF
binaries: the PLT. These patches also include support for LLD to
generate PLT entries that perform a retpoline-style indirection.

The only other indirect branches remaining that we are aware of are
from precompiled runtimes (such as crt0.o and similar). The ones we
have found are not really attackable, and so we have not focused on
them here, but eventually these runtimes should also be replicated for
retpoline-ed configurations for completeness.

For kernels or other freestanding or fully static executables, the
compiler switch `-mretpoline` is sufficient to fully mitigate this
particular attack. For dynamic executables, you must compile *all*
libraries with `-mretpoline` and additionally link the dynamic
executable and all shared libraries with LLD and pass `-z
retpolineplt` (or use similar functionality from some other linker).
We strongly recommend also using `-z now` as non-lazy binding allows
the retpoline-mitigated PLT to be substantially smaller.

When manually apply similar transformations to `-mretpoline` to the
Linux kernel we observed very small performance hits to applications
running typic al workloads, and relatively minor hits (approximately
2%) even for extremely syscall-heavy applications. This is largely
due to the small number of indirect branches that occur in
performance sensitive paths of the kernel.

When using these patches on statically linked applications,
especially C++ applications, you should expect to see a much more
dramatic performance hit. For microbenchmarks that are switch,
indirect-, or virtual-call heavy we have seen overheads ranging from
10% to 50%.

However, real-world workloads exhibit substantially lower performance
impact. Notably, techniques such as PGO and ThinLTO dramatically
reduce the impact of hot indirect calls (by speculatively promoting
them to direct calls) and allow optimized search trees to be used to
lower switches. If you need to deploy these techniques in C++
applications, we *strongly* recommend that you ensure all hot call
targets are statically linked (avoiding PLT indirection) and use both
PGO and ThinLTO. Well tuned servers using all of these techniques saw
5% - 10% overhead from the use of retpoline.

We will add detailed documentation covering these components in
subsequent patches, but wanted to make the core functionality
available as soon as possible. Happy for more code review, but we'd
really like to get these patches landed and backported ASAP for
obvious reasons. We're planning to backport this to both 6.0 and 5.0
release streams and get a 5.0 release with just this cherry picked
ASAP for distros and vendors.

This patch is the work of a number of people over the past month:
Eric, Reid, Rui, and myself. I'm mailing it out as a single commit
due to the time sensitive nature of landing this and the need to
backport it. Huge thanks to everyone who helped out here, and
everyone at Intel who helped out in discussions about how to craft
this. Also, credit goes to Paul Turner (at Google, but not an LLVM
contributor) for much of the underlying retpoline design.

Reviewers: echristo, rnk, ruiu, craig.topper, DavidKreitzer

Subscribers: sanjoy, emaste, mcrosier, mgorny, mehdi_amini, hiraditya, llvm-commits

Differential Revision: https://reviews.llvm.org/D41723

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 842d113b 01-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r323948).

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 042b1c2e 24-Jan-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r323338).

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 30785c0e 06-Jan-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_60 r321788,
update build glue and version numbers.


# fe4fed2e 28-Dec-2017 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ trunk r321545,
update build glue and version numbers, add new intrinsics headers, and
update OptionalObsoleteFiles.inc.


# 2757ff7e 23-Dec-2017 Dimitry Andric <dim@FreeBSD.org>

Update clang, lld and llvm version numbers for r321414, and update build
glue.

# 02d2ad99 20-Dec-2017 Dimitry Andric <dim@FreeBSD.org>

Update generated config headers, and version numbers.

# 50d7464c 14-Jan-2023 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/15.x llvmorg-15.0.7-0-g8dfdcc7b7bf6

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15.0.7-0-g8dfdcc7b7bf6.

PR: 265425
MFC after: 2 weeks


# f3fd488f 04-Dec-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/15.x llvmorg-15.0.6-0-g088f33605d8a

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15.0.6-0-g088f33605d8a.

PR: 265425
MFC after: 2 weeks


# 6246ae0b 16-Oct-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/15.x llvmorg-15.0.2-10-gf3c5289e7846

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15.0.2-10-gf3c5289e7846.

PR: 265425
MFC after: 2 weeks


# a4a491e2 10-Sep-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/15.x llvmorg-15.0.0-9-g1c73596d3454

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15.0.0-9-g1c73596d3454.

PR: 265425
MFC after: 2 weeks


# 61cfbce3 13-Aug-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/15.x llvmorg-15.0.0-rc2-40-gfbd2950d8d0d

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15.0.0-rc2-40-gfbd2950d8d0d.

PR: 265425
MFC after: 2 weeks


# 972a253a 27-Jul-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-15-init-17826-g1f8ae9d7e7e4

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15-init-17826-g1f8ae9d7e7e4, the last commit before
the upstream release/16.x branch was created.

PR: 265425
MFC after: 2 weeks


# fcaf7f86 24-Jul-2022 Dimitry Andric <dim@FreeBSD.org>

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


# 753f127f 14-Jul-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project main llvmorg-15-init-16436-g18a6ab5b8d1f

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15-init-16436-g18a6ab5b8d1f.

PR: 265425
MFC after: 2 weeks


# 81ad6265 04-Jul-2022 Dimitry Andric <dim@FreeBSD.org>

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


# 56f451bb 12-Jun-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.5-0-gc12386ae247c

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.5-0-gc12386ae247c, aka 14.0.5 release.

PR: 261742
MFC after: 3 days


# 809922b0 05-Jun-2022 Dimitry Andric <dim@FreeBSD.org>

Update rest of llvm-project build glue for 14.0.4

I completely forgot about updating the generated llvm-project config
files, which also contain version numbers, etc. Sorry for the churn.

PR: 261742
Fixes: ab9d54731f43
MFC after: 3 days

# ab9d5473 04-Jun-2022 Dimitry Andric <dim@FreeBSD.org>

Bump versions llvm-project release/14.x llvmorg-14.0.4-0-g29f1039a7285

Somehow git rebase made this squashed commit disappear. Restore it.

PR: 261742
MFC after: 3 days

# 3a9a9c0c 28-Apr-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.3-0-g1f9140064dfb

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.3-0-g1f9140064dfb.

PR: 261742
MFC after: 2 weeks


# dbc822f3 29-Mar-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.0-2-g3f43d803382d

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-2-g3f43d803382d.

PR: 261742
MFC after: 2 weeks


# fb03ea46 17-Mar-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.0-rc4-2-gadd3ab7f4c8a

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-rc4-2-gadd3ab7f4c8a.

PR: 261742
MFC after: 2 weeks


# d781ede6 05-Mar-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.0-rc2-12-g09546e1b5103

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-rc2-12-g09546e1b5103.

PR: 261742
MFC after: 2 weeks


# d56accc7 18-Feb-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.0-rc1-74-g4dc3cb8e3255

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-rc1-74-g4dc3cb8e3255.

PR: 261742
MFC after: 2 weeks


# 1838bd0f 05-Feb-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14-init-18315-g190be5457c90

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14-init-18315-g190be5457c90.

PR: 261742
MFC after: 2 weeks


# 5e801ac6 20-Nov-2021 Dimitry Andric <dim@FreeBSD.org>

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


# fe6060f1 22-Aug-2021 Dimitry Andric <dim@FreeBSD.org>

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


# 23408297 18-Jun-2021 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project 12.0.1 rc2

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-12.0.1-rc2-0-ge7dac564cd0e, a.k.a. 12.0.1 rc2.

PR: 255570
MFC after: 6 weeks


# e8d8bef9 13-Jun-2021 Dimitry Andric <dim@FreeBSD.org>

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


# f9a66922 21-Jan-2021 Glen Barber <gjb@FreeBSD.org>

fix incorrect LLD_VERSION_STRING from previous commit

Reported by: Oliver Pinter
Sponsored by: Rubicon Communications, LLC ("Netgate")

# a53ce3fc 21-Jan-2021 Glen Barber <gjb@FreeBSD.org>

Bump CURRENT to 14.0

This one goes to 14.

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC ("Netgate")

# eaeb601b 03-Jan-2021 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
release/11.x llvmorg-11.0.1-rc2-0-g43ff75f2c3f (aka 11.0.1 rc2).

MFC after: 4 weeks
X-MFC-With: r364284


# 5f24ef21 06-Aug-2020 Dimitry Andric <dim@FreeBSD.org>

Update generated llvm-project related version headers, config.h files
and add a newly generated lldb Plugins.def file too.

# d65cd7a5 23-May-2020 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
llvmorg-10.0.1-rc1-0-gf79cd71e145 (aka 10.0.1 rc1).

MFC after: 3 weeks


# 0b37c159 25-Jan-2020 Dimitry Andric <dim@FreeBSD.org>

* Bump version numbers to 10.0.0
* Update UPDATING
* Update (Optional)ObsoleteFiles.inc
* Update VCS(Revision|Version) files
* Update generated config headers
* Update clang internal headers Makefile

# c14a5a88 22-Dec-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
9.0.1 final release c1a0a213378a458fbea1a5c77b315c7dce08fd05.

Release notes for llvm, clang, lld and libc++ 9.0.1 will become
available here:

https://releases.llvm.org/9.0.1/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.1/tools/clang/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.1/tools/lld/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.1/projects/libcxx/docs/ReleaseNotes.html

PR: 240629
MFC after: 1 month


# fb3a446a 06-Sep-2019 Dimitry Andric <dim@FreeBSD.org>

Add a VCSVersion.inc header with revision and repository defines,
similar to what upstream generates via CMake. Though for us it is
handier to have everything in one file.

# 6a82ac86 02-Sep-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb, and openmp
release_90 branch r370514, and update version numbers.


# 22f75ae7 02-Sep-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb, and openmp
release_90 branch r369369, and update version numbers.


# 86aa9539 23-Aug-2019 Dimitry Andric <dim@FreeBSD.org>

Regenerate config and version headers.

# 87c8ef55 20-Jul-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
8.0.1 final release r366581. The only functional change is a fix for a
mismerge of upstream r360816, which properly restores the r2 register
when unwinding on PowerPC64 (See https://reviews.freebsd.org/D20337).

Relnotes: yes
PR: 236062
MFC after: 3 days
X-MFC-With: r349004


# ec38f4f9 06-Jul-2019 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt, libc++,
libunwind and openmp to the upstream release_80 branch r364487
(effectively, 8.0.1 rc3). The 8.0.1 release will most likely
have no further changes.

MFC after: 1 week
X-MFC-With: r349004


# efc5c442 12-Jun-2019 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt, libc++,
libunwind and openmp to the upstream release_80 branch r363030
(effectively, 8.0.1 rc2). The 8.0.1 release should follow this within a
week or so.

MFC after: 2 weeks


# c3e6b9d3 20-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Pull in r352826 from upstream lld trunk (by Fangrui Song):

[ELF] Support --{,no-}allow-shlib-undefined

Summary:
In ld.bfd/gold, --no-allow-shlib-undefined is the default when
linking an executable. This patch implements a check to error on
undefined symbols in a shared object, if all of its DT_NEEDED entries
are seen.

Our approach resembles the one used in gold, achieves a good balance
to be useful but not too smart (ld.bfd traces all DSOs and emulates
the behavior of a dynamic linker to catch more cases).

The error is issued based on the symbol table, different from
undefined reference errors issued for relocations. It is most
effective when there are DSOs that were not linked with -z defs (e.g.
when static sanitizers runtime is used).

gold has a comment that some system libraries on GNU/Linux may have
spurious undefined references and thus system libraries should be
excluded (https://sourceware.org/bugzilla/show_bug.cgi?id=6811). The
story may have changed now but we make --allow-shlib-undefined the
default for now. Its interaction with -shared can be discussed in the
future.

Reviewers: ruiu, grimar, pcc, espindola

Reviewed By: ruiu

Subscribers: joerg, emaste, arichardson, llvm-commits

Differential Revision: https://reviews.llvm.org/D57385

Pull in r352943 from upstream lld trunk (by Fangrui Song):

[ELF] Default to --no-allow-shlib-undefined for executables

Summary:
This follows the ld.bfd/gold behavior.

The error check is useful as it captures a common type of ld.so
undefined symbol errors as link-time errors:

// a.cc => a.so (not linked with -z defs)
void f(); // f is undefined
void g() { f(); }

// b.cc => executable with a DT_NEEDED entry on a.so
void g();
int main() { g(); }

// ld.so errors when g() is executed (lazy binding) or when the program is started (-z now)
// symbol lookup error: ... undefined symbol: f

Reviewers: ruiu, grimar, pcc, espindola

Reviewed By: ruiu

Subscribers: llvm-commits, emaste, arichardson

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D57569

Together, these add support for --no-allow-shlib-undefined, and make it
the default for executables, so they will fail to link if any symbols
from needed shared libraries are undefined.

Reported by: jbeich
PR: 236062, 236141
MFC after: 1 month
X-MFC-With: r344779

# fb7e42b9 20-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
8.0.0 final release r356365. There were no functional changes since the
most recent merge, of 8.0.0 rc5.

Release notes for llvm, clang, lld and libc++ 8.0.0 are now available:

https://llvm.org/releases/8.0.0/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/tools/clang/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/tools/lld/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/projects/libcxx/docs/ReleaseNotes.html

PR: 236062
MFC after: 1 month
X-MFC-With: r344779


# 2352f970 14-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, and lldb
release_80 branch r356034 (effectively, 8.0.0 rc5), resolve conflicts,
and bump version numbers.

PR: 236062
MFC after: 1 month
X-MFC-With: r344779


# b3ed818e 08-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r355677 (effectively, 8.0.0 rc4), resolve conflicts, and bump version
numbers.

PR: 236062
MFC after: 1 month
X-MFC-With: r344779


# 3087b115 04-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r355313, resolve conflicts, and bump version numbers.


# da18572f 25-Feb-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r354799, resolve conflicts, and bump version numbers.


# 640dd76f 15-Feb-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r354130, resolve conflicts, and bump version numbers.


# c8630eab 05-Feb-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r353167, resolve conflicts, and bump version numbers.


# af44a011 22-Jan-2019 Dimitry Andric <dim@FreeBSD.org>

Now for the release_80 branch, update version numbers for llvm, clang
and lld, and regenerate config headers.

# 0bf31f1f 20-Jan-2019 Dimitry Andric <dim@FreeBSD.org>

Update version numbers, and regenerate config headers for llvm, clang,
lld and lldb. Update ObsoleteFiles.inc and OptionalObsoleteFiles.inc.

# 176fdeee 15-Dec-2018 Dimitry Andric <dim@FreeBSD.org>

Update clang, llvm, lld, lldb, compiler-rt and libc++ version number to
7.0.1 release r349250. There were no functional changes since the 7.0.1
rc3 import.

PR: 230240, 230355
Relnotes: yes
MFC after: 2 months
X-MFC-With: r341825


# 0b9890fc 09-Dec-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r348686 (effectively 7.0.1 rc3), resolve conflicts, and bump version
numbers.

PR: 230240, 230355


# 68948600 04-Nov-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r346007 (effectively 7.0.1 rc2), resolve conflicts, and bump version
numbers.

PR: 230240, 230355


# c6879c6c 23-Oct-2018 Dimitry Andric <dim@FreeBSD.org>

Merge ^/head r339015 through r339669.


# b0bffd12 20-Oct-2018 Ed Maste <emaste@FreeBSD.org>

Bump LLD_REVISION_STRING for 13-CURRENT

# b371a9f0 11-Oct-2018 Ed Maste <emaste@FreeBSD.org>

lld: set sh_link and sh_info for .rela.plt sections

ELF spec says that for SHT_REL and SHT_RELA sh_link should reference the
associated string table and sh_info should reference the "section to
which the relocation applies." ELF Tool Chain's elfcopy / strip use
this (in part) to control whether or not the relocation entry is copied
to the output.

LLVM PR 37538 https://bugs.llvm.org/show_bug.cgi?id=37538

Approved by: re (kib)
Obtained from: llvm r344226 (backported for 6.0)

# 38fb4010 17-Sep-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ 7.0.0 release
r342383, and bump version numbers.

PR: 230240, 230355


# c826f0db 11-Sep-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r341916, resolve conflicts, and bump version numbers.

PR: 230240, 230355


# 8ba00cf9 29-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r340910, resolve conflicts, and bump version numbers.

PR: 230240, 230355


# 7726714d 17-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r339999, resolve conflicts, and bump version numbers.

PR: 230240,230355


# 3beb5372 11-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r339355, resolve conflicts, and bump version numbers.


# 84ba35dc 04-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Bump clang and lld upstream revision numbers.

# 0fecf001 02-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Bump revisions to r338536, and also bump lld version again.

# 837f3385 31-Jul-2018 Ed Maste <emaste@FreeBSD.org>

bump lld version number after r336972 arm(v7) VFP tag support

Reported by: kevans
Sponsored by: The FreeBSD Foundation

# 6dfa117f 31-Jul-2018 Dimitry Andric <dim@FreeBSD.org>

Update llvm/clang version numbers in various files.

# fbfca78e 30-Jun-2018 Dimitry Andric <dim@FreeBSD.org>

Follow-up to r335799 (llvm/clang 6.0.1 update), by regenerating various
headers with new version information defines.

MFC after: 2 weeks
X-MFC-With: r335799

# 6ccc06f6 29-Jun-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.1 release (upstream r335540).

Relnotes: yes
MFC after: 2 weeks


# 19703503 09-May-2018 Ed Maste <emaste@FreeBSD.org>

lld: Omit PT_NOTE for SHT_NOTE without SHF_ALLOC

A non-alloc note section should not have a PT_NOTE program header.

Found while linking ghc (Haskell compiler) with lld on FreeBSD. Haskell
emits a .debug-ghc-link-info note section (as the name suggests, it
contains link info) as a SHT_NOTE section without SHF_ALLOC set.

For this case ld.bfd does not emit a PT_NOTE segment for
.debug-ghc-link-info. lld previously emitted a PT_NOTE with p_vaddr = 0
and FreeBSD's rtld segfaulted when trying to parse a note at address 0.

LLVM PR: https://llvm.org/pr37361
LLVM review: https://reviews.llvm.org/D46623

PR: 226872
Reviewed by: dim
Sponsored by: The FreeBSD Foundation

# 08730804 19-Apr-2018 Ed Maste <emaste@FreeBSD.org>

lld: use correct number of digits in __FreeBSD_version-style ID

__FreeBSD_version-style IDs should have 5 digits following the major.

# 12881601 17-Apr-2018 Ed Maste <emaste@FreeBSD.org>

lld: add a __FreeBSD_version-style identifier to version

This will faciliate a WITH_SYSTEM_LINKER option.

Reviewed by: dim
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D15110

# c5a4cd4f 04-Mar-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 release (upstream r326565).

Release notes for llvm, clang and lld will be available here soon:
<http://releases.llvm.org/6.0.0/docs/ReleaseNotes.html>
<http://releases.llvm.org/6.0.0/tools/clang/docs/ReleaseNotes.html>
<http://releases.llvm.org/6.0.0/tools/lld/docs/ReleaseNotes.html>

Relnotes: yes
MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 4f8786af 25-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r325932). This corresponds to 6.0.0 rc3.

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 954b921d 16-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r325330).

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 07577dfe 02-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r324090).

This introduces retpoline support, with the -mretpoline flag. The
upstream initial commit message (r323155 by Chandler Carruth) contains
quite a bit of explanation. Quoting:

Introduce the "retpoline" x86 mitigation technique for variant #2 of
the speculative execution vulnerabilities disclosed today,
specifically identified by CVE-2017-5715, "Branch Target Injection",
and is one of the two halves to Spectre.

Summary:
First, we need to explain the core of the vulnerability. Note that
this is a very incomplete description, please see the Project Zero
blog post for details:
https://googleprojectzero.blogspot.com/2018/01/reading-privileged-memory-with-side.html

The basis for branch target injection is to direct speculative
execution of the processor to some "gadget" of executable code by
poisoning the prediction of indirect branches with the address of
that gadget. The gadget in turn contains an operation that provides a
side channel for reading data. Most commonly, this will look like a
load of secret data followed by a branch on the loaded value and then
a load of some predictable cache line. The attacker then uses timing
of the processors cache to determine which direction the branch took
*in the speculative execution*, and in turn what one bit of the
loaded value was. Due to the nature of these timing side channels and
the branch predictor on Intel processors, this allows an attacker to
leak data only accessible to a privileged domain (like the kernel)
back into an unprivileged domain.

The goal is simple: avoid generating code which contains an indirect
branch that could have its prediction poisoned by an attacker. In
many cases, the compiler can simply use directed conditional branches
and a small search tree. LLVM already has support for lowering
switches in this way and the first step of this patch is to disable
jump-table lowering of switches and introduce a pass to rewrite
explicit indirectbr sequences into a switch over integers.

However, there is no fully general alternative to indirect calls. We
introduce a new construct we call a "retpoline" to implement indirect
calls in a non-speculatable way. It can be thought of loosely as a
trampoline for indirect calls which uses the RET instruction on x86.
Further, we arrange for a specific call->ret sequence which ensures
the processor predicts the return to go to a controlled, known
location. The retpoline then "smashes" the return address pushed onto
the stack by the call with the desired target of the original
indirect call. The result is a predicted return to the next
instruction after a call (which can be used to trap speculative
execution within an infinite loop) and an actual indirect branch to
an arbitrary address.

On 64-bit x86 ABIs, this is especially easily done in the compiler by
using a guaranteed scratch register to pass the target into this
device. For 32-bit ABIs there isn't a guaranteed scratch register
and so several different retpoline variants are introduced to use a
scratch register if one is available in the calling convention and to
otherwise use direct stack push/pop sequences to pass the target
address.

This "retpoline" mitigation is fully described in the following blog
post: https://support.google.com/faqs/answer/7625886

We also support a target feature that disables emission of the
retpoline thunk by the compiler to allow for custom thunks if users
want them. These are particularly useful in environments like
kernels that routinely do hot-patching on boot and want to hot-patch
their thunk to different code sequences. They can write this custom
thunk and use `-mretpoline-external-thunk` *in addition* to
`-mretpoline`. In this case, on x86-64 thu thunk names must be:
```
__llvm_external_retpoline_r11
```
or on 32-bit:
```
__llvm_external_retpoline_eax
__llvm_external_retpoline_ecx
__llvm_external_retpoline_edx
__llvm_external_retpoline_push
```
And the target of the retpoline is passed in the named register, or in
the case of the `push` suffix on the top of the stack via a `pushl`
instruction.

There is one other important source of indirect branches in x86 ELF
binaries: the PLT. These patches also include support for LLD to
generate PLT entries that perform a retpoline-style indirection.

The only other indirect branches remaining that we are aware of are
from precompiled runtimes (such as crt0.o and similar). The ones we
have found are not really attackable, and so we have not focused on
them here, but eventually these runtimes should also be replicated for
retpoline-ed configurations for completeness.

For kernels or other freestanding or fully static executables, the
compiler switch `-mretpoline` is sufficient to fully mitigate this
particular attack. For dynamic executables, you must compile *all*
libraries with `-mretpoline` and additionally link the dynamic
executable and all shared libraries with LLD and pass `-z
retpolineplt` (or use similar functionality from some other linker).
We strongly recommend also using `-z now` as non-lazy binding allows
the retpoline-mitigated PLT to be substantially smaller.

When manually apply similar transformations to `-mretpoline` to the
Linux kernel we observed very small performance hits to applications
running typic al workloads, and relatively minor hits (approximately
2%) even for extremely syscall-heavy applications. This is largely
due to the small number of indirect branches that occur in
performance sensitive paths of the kernel.

When using these patches on statically linked applications,
especially C++ applications, you should expect to see a much more
dramatic performance hit. For microbenchmarks that are switch,
indirect-, or virtual-call heavy we have seen overheads ranging from
10% to 50%.

However, real-world workloads exhibit substantially lower performance
impact. Notably, techniques such as PGO and ThinLTO dramatically
reduce the impact of hot indirect calls (by speculatively promoting
them to direct calls) and allow optimized search trees to be used to
lower switches. If you need to deploy these techniques in C++
applications, we *strongly* recommend that you ensure all hot call
targets are statically linked (avoiding PLT indirection) and use both
PGO and ThinLTO. Well tuned servers using all of these techniques saw
5% - 10% overhead from the use of retpoline.

We will add detailed documentation covering these components in
subsequent patches, but wanted to make the core functionality
available as soon as possible. Happy for more code review, but we'd
really like to get these patches landed and backported ASAP for
obvious reasons. We're planning to backport this to both 6.0 and 5.0
release streams and get a 5.0 release with just this cherry picked
ASAP for distros and vendors.

This patch is the work of a number of people over the past month:
Eric, Reid, Rui, and myself. I'm mailing it out as a single commit
due to the time sensitive nature of landing this and the need to
backport it. Huge thanks to everyone who helped out here, and
everyone at Intel who helped out in discussions about how to craft
this. Also, credit goes to Paul Turner (at Google, but not an LLVM
contributor) for much of the underlying retpoline design.

Reviewers: echristo, rnk, ruiu, craig.topper, DavidKreitzer

Subscribers: sanjoy, emaste, mcrosier, mgorny, mehdi_amini, hiraditya, llvm-commits

Differential Revision: https://reviews.llvm.org/D41723

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 842d113b 01-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r323948).

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 042b1c2e 24-Jan-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r323338).

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 30785c0e 06-Jan-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_60 r321788,
update build glue and version numbers.


# fe4fed2e 28-Dec-2017 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ trunk r321545,
update build glue and version numbers, add new intrinsics headers, and
update OptionalObsoleteFiles.inc.


# 2757ff7e 23-Dec-2017 Dimitry Andric <dim@FreeBSD.org>

Update clang, lld and llvm version numbers for r321414, and update build
glue.

# 02d2ad99 20-Dec-2017 Dimitry Andric <dim@FreeBSD.org>

Update generated config headers, and version numbers.

# 56f451bb 12-Jun-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.5-0-gc12386ae247c

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.5-0-gc12386ae247c, aka 14.0.5 release.

PR: 261742
MFC after: 3 days


# 809922b0 05-Jun-2022 Dimitry Andric <dim@FreeBSD.org>

Update rest of llvm-project build glue for 14.0.4

I completely forgot about updating the generated llvm-project config
files, which also contain version numbers, etc. Sorry for the churn.

PR: 261742
Fixes: ab9d54731f43
MFC after: 3 days

# ab9d5473 04-Jun-2022 Dimitry Andric <dim@FreeBSD.org>

Bump versions llvm-project release/14.x llvmorg-14.0.4-0-g29f1039a7285

Somehow git rebase made this squashed commit disappear. Restore it.

PR: 261742
MFC after: 3 days

# 3a9a9c0c 28-Apr-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.3-0-g1f9140064dfb

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.3-0-g1f9140064dfb.

PR: 261742
MFC after: 2 weeks


# dbc822f3 29-Mar-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.0-2-g3f43d803382d

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-2-g3f43d803382d.

PR: 261742
MFC after: 2 weeks


# fb03ea46 17-Mar-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.0-rc4-2-gadd3ab7f4c8a

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-rc4-2-gadd3ab7f4c8a.

PR: 261742
MFC after: 2 weeks


# d781ede6 05-Mar-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.0-rc2-12-g09546e1b5103

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-rc2-12-g09546e1b5103.

PR: 261742
MFC after: 2 weeks


# d56accc7 18-Feb-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.0-rc1-74-g4dc3cb8e3255

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-rc1-74-g4dc3cb8e3255.

PR: 261742
MFC after: 2 weeks


# 1838bd0f 05-Feb-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14-init-18315-g190be5457c90

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14-init-18315-g190be5457c90.

PR: 261742
MFC after: 2 weeks


# 5e801ac6 20-Nov-2021 Dimitry Andric <dim@FreeBSD.org>

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


# fe6060f1 22-Aug-2021 Dimitry Andric <dim@FreeBSD.org>

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


# 23408297 18-Jun-2021 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project 12.0.1 rc2

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-12.0.1-rc2-0-ge7dac564cd0e, a.k.a. 12.0.1 rc2.

PR: 255570
MFC after: 6 weeks


# e8d8bef9 13-Jun-2021 Dimitry Andric <dim@FreeBSD.org>

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


# f9a66922 21-Jan-2021 Glen Barber <gjb@FreeBSD.org>

fix incorrect LLD_VERSION_STRING from previous commit

Reported by: Oliver Pinter
Sponsored by: Rubicon Communications, LLC ("Netgate")

# a53ce3fc 21-Jan-2021 Glen Barber <gjb@FreeBSD.org>

Bump CURRENT to 14.0

This one goes to 14.

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC ("Netgate")

# eaeb601b 03-Jan-2021 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
release/11.x llvmorg-11.0.1-rc2-0-g43ff75f2c3f (aka 11.0.1 rc2).

MFC after: 4 weeks
X-MFC-With: r364284


# 5f24ef21 06-Aug-2020 Dimitry Andric <dim@FreeBSD.org>

Update generated llvm-project related version headers, config.h files
and add a newly generated lldb Plugins.def file too.

# d65cd7a5 23-May-2020 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
llvmorg-10.0.1-rc1-0-gf79cd71e145 (aka 10.0.1 rc1).

MFC after: 3 weeks


# 0b37c159 25-Jan-2020 Dimitry Andric <dim@FreeBSD.org>

* Bump version numbers to 10.0.0
* Update UPDATING
* Update (Optional)ObsoleteFiles.inc
* Update VCS(Revision|Version) files
* Update generated config headers
* Update clang internal headers Makefile

# c14a5a88 22-Dec-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
9.0.1 final release c1a0a213378a458fbea1a5c77b315c7dce08fd05.

Release notes for llvm, clang, lld and libc++ 9.0.1 will become
available here:

https://releases.llvm.org/9.0.1/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.1/tools/clang/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.1/tools/lld/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.1/projects/libcxx/docs/ReleaseNotes.html

PR: 240629
MFC after: 1 month


# fb3a446a 06-Sep-2019 Dimitry Andric <dim@FreeBSD.org>

Add a VCSVersion.inc header with revision and repository defines,
similar to what upstream generates via CMake. Though for us it is
handier to have everything in one file.

# 6a82ac86 02-Sep-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb, and openmp
release_90 branch r370514, and update version numbers.


# 22f75ae7 02-Sep-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb, and openmp
release_90 branch r369369, and update version numbers.


# 86aa9539 23-Aug-2019 Dimitry Andric <dim@FreeBSD.org>

Regenerate config and version headers.

# 87c8ef55 20-Jul-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
8.0.1 final release r366581. The only functional change is a fix for a
mismerge of upstream r360816, which properly restores the r2 register
when unwinding on PowerPC64 (See https://reviews.freebsd.org/D20337).

Relnotes: yes
PR: 236062
MFC after: 3 days
X-MFC-With: r349004


# ec38f4f9 06-Jul-2019 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt, libc++,
libunwind and openmp to the upstream release_80 branch r364487
(effectively, 8.0.1 rc3). The 8.0.1 release will most likely
have no further changes.

MFC after: 1 week
X-MFC-With: r349004


# efc5c442 12-Jun-2019 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt, libc++,
libunwind and openmp to the upstream release_80 branch r363030
(effectively, 8.0.1 rc2). The 8.0.1 release should follow this within a
week or so.

MFC after: 2 weeks


# c3e6b9d3 20-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Pull in r352826 from upstream lld trunk (by Fangrui Song):

[ELF] Support --{,no-}allow-shlib-undefined

Summary:
In ld.bfd/gold, --no-allow-shlib-undefined is the default when
linking an executable. This patch implements a check to error on
undefined symbols in a shared object, if all of its DT_NEEDED entries
are seen.

Our approach resembles the one used in gold, achieves a good balance
to be useful but not too smart (ld.bfd traces all DSOs and emulates
the behavior of a dynamic linker to catch more cases).

The error is issued based on the symbol table, different from
undefined reference errors issued for relocations. It is most
effective when there are DSOs that were not linked with -z defs (e.g.
when static sanitizers runtime is used).

gold has a comment that some system libraries on GNU/Linux may have
spurious undefined references and thus system libraries should be
excluded (https://sourceware.org/bugzilla/show_bug.cgi?id=6811). The
story may have changed now but we make --allow-shlib-undefined the
default for now. Its interaction with -shared can be discussed in the
future.

Reviewers: ruiu, grimar, pcc, espindola

Reviewed By: ruiu

Subscribers: joerg, emaste, arichardson, llvm-commits

Differential Revision: https://reviews.llvm.org/D57385

Pull in r352943 from upstream lld trunk (by Fangrui Song):

[ELF] Default to --no-allow-shlib-undefined for executables

Summary:
This follows the ld.bfd/gold behavior.

The error check is useful as it captures a common type of ld.so
undefined symbol errors as link-time errors:

// a.cc => a.so (not linked with -z defs)
void f(); // f is undefined
void g() { f(); }

// b.cc => executable with a DT_NEEDED entry on a.so
void g();
int main() { g(); }

// ld.so errors when g() is executed (lazy binding) or when the program is started (-z now)
// symbol lookup error: ... undefined symbol: f

Reviewers: ruiu, grimar, pcc, espindola

Reviewed By: ruiu

Subscribers: llvm-commits, emaste, arichardson

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D57569

Together, these add support for --no-allow-shlib-undefined, and make it
the default for executables, so they will fail to link if any symbols
from needed shared libraries are undefined.

Reported by: jbeich
PR: 236062, 236141
MFC after: 1 month
X-MFC-With: r344779

# fb7e42b9 20-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
8.0.0 final release r356365. There were no functional changes since the
most recent merge, of 8.0.0 rc5.

Release notes for llvm, clang, lld and libc++ 8.0.0 are now available:

https://llvm.org/releases/8.0.0/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/tools/clang/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/tools/lld/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/projects/libcxx/docs/ReleaseNotes.html

PR: 236062
MFC after: 1 month
X-MFC-With: r344779


# 2352f970 14-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, and lldb
release_80 branch r356034 (effectively, 8.0.0 rc5), resolve conflicts,
and bump version numbers.

PR: 236062
MFC after: 1 month
X-MFC-With: r344779


# b3ed818e 08-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r355677 (effectively, 8.0.0 rc4), resolve conflicts, and bump version
numbers.

PR: 236062
MFC after: 1 month
X-MFC-With: r344779


# 3087b115 04-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r355313, resolve conflicts, and bump version numbers.


# da18572f 25-Feb-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r354799, resolve conflicts, and bump version numbers.


# 640dd76f 15-Feb-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r354130, resolve conflicts, and bump version numbers.


# c8630eab 05-Feb-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r353167, resolve conflicts, and bump version numbers.


# af44a011 22-Jan-2019 Dimitry Andric <dim@FreeBSD.org>

Now for the release_80 branch, update version numbers for llvm, clang
and lld, and regenerate config headers.

# 0bf31f1f 20-Jan-2019 Dimitry Andric <dim@FreeBSD.org>

Update version numbers, and regenerate config headers for llvm, clang,
lld and lldb. Update ObsoleteFiles.inc and OptionalObsoleteFiles.inc.

# 176fdeee 15-Dec-2018 Dimitry Andric <dim@FreeBSD.org>

Update clang, llvm, lld, lldb, compiler-rt and libc++ version number to
7.0.1 release r349250. There were no functional changes since the 7.0.1
rc3 import.

PR: 230240, 230355
Relnotes: yes
MFC after: 2 months
X-MFC-With: r341825


# 0b9890fc 09-Dec-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r348686 (effectively 7.0.1 rc3), resolve conflicts, and bump version
numbers.

PR: 230240, 230355


# 68948600 04-Nov-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r346007 (effectively 7.0.1 rc2), resolve conflicts, and bump version
numbers.

PR: 230240, 230355


# c6879c6c 23-Oct-2018 Dimitry Andric <dim@FreeBSD.org>

Merge ^/head r339015 through r339669.


# b0bffd12 20-Oct-2018 Ed Maste <emaste@FreeBSD.org>

Bump LLD_REVISION_STRING for 13-CURRENT

# b371a9f0 11-Oct-2018 Ed Maste <emaste@FreeBSD.org>

lld: set sh_link and sh_info for .rela.plt sections

ELF spec says that for SHT_REL and SHT_RELA sh_link should reference the
associated string table and sh_info should reference the "section to
which the relocation applies." ELF Tool Chain's elfcopy / strip use
this (in part) to control whether or not the relocation entry is copied
to the output.

LLVM PR 37538 https://bugs.llvm.org/show_bug.cgi?id=37538

Approved by: re (kib)
Obtained from: llvm r344226 (backported for 6.0)

# 38fb4010 17-Sep-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ 7.0.0 release
r342383, and bump version numbers.

PR: 230240, 230355


# c826f0db 11-Sep-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r341916, resolve conflicts, and bump version numbers.

PR: 230240, 230355


# 8ba00cf9 29-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r340910, resolve conflicts, and bump version numbers.

PR: 230240, 230355


# 7726714d 17-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r339999, resolve conflicts, and bump version numbers.

PR: 230240,230355


# 3beb5372 11-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r339355, resolve conflicts, and bump version numbers.


# 84ba35dc 04-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Bump clang and lld upstream revision numbers.

# 0fecf001 02-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Bump revisions to r338536, and also bump lld version again.

# 837f3385 31-Jul-2018 Ed Maste <emaste@FreeBSD.org>

bump lld version number after r336972 arm(v7) VFP tag support

Reported by: kevans
Sponsored by: The FreeBSD Foundation

# 6dfa117f 31-Jul-2018 Dimitry Andric <dim@FreeBSD.org>

Update llvm/clang version numbers in various files.

# fbfca78e 30-Jun-2018 Dimitry Andric <dim@FreeBSD.org>

Follow-up to r335799 (llvm/clang 6.0.1 update), by regenerating various
headers with new version information defines.

MFC after: 2 weeks
X-MFC-With: r335799

# 6ccc06f6 29-Jun-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.1 release (upstream r335540).

Relnotes: yes
MFC after: 2 weeks


# 19703503 09-May-2018 Ed Maste <emaste@FreeBSD.org>

lld: Omit PT_NOTE for SHT_NOTE without SHF_ALLOC

A non-alloc note section should not have a PT_NOTE program header.

Found while linking ghc (Haskell compiler) with lld on FreeBSD. Haskell
emits a .debug-ghc-link-info note section (as the name suggests, it
contains link info) as a SHT_NOTE section without SHF_ALLOC set.

For this case ld.bfd does not emit a PT_NOTE segment for
.debug-ghc-link-info. lld previously emitted a PT_NOTE with p_vaddr = 0
and FreeBSD's rtld segfaulted when trying to parse a note at address 0.

LLVM PR: https://llvm.org/pr37361
LLVM review: https://reviews.llvm.org/D46623

PR: 226872
Reviewed by: dim
Sponsored by: The FreeBSD Foundation

# 08730804 19-Apr-2018 Ed Maste <emaste@FreeBSD.org>

lld: use correct number of digits in __FreeBSD_version-style ID

__FreeBSD_version-style IDs should have 5 digits following the major.

# 12881601 17-Apr-2018 Ed Maste <emaste@FreeBSD.org>

lld: add a __FreeBSD_version-style identifier to version

This will faciliate a WITH_SYSTEM_LINKER option.

Reviewed by: dim
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D15110

# c5a4cd4f 04-Mar-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 release (upstream r326565).

Release notes for llvm, clang and lld will be available here soon:
<http://releases.llvm.org/6.0.0/docs/ReleaseNotes.html>
<http://releases.llvm.org/6.0.0/tools/clang/docs/ReleaseNotes.html>
<http://releases.llvm.org/6.0.0/tools/lld/docs/ReleaseNotes.html>

Relnotes: yes
MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 4f8786af 25-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r325932). This corresponds to 6.0.0 rc3.

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 954b921d 16-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r325330).

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 07577dfe 02-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r324090).

This introduces retpoline support, with the -mretpoline flag. The
upstream initial commit message (r323155 by Chandler Carruth) contains
quite a bit of explanation. Quoting:

Introduce the "retpoline" x86 mitigation technique for variant #2 of
the speculative execution vulnerabilities disclosed today,
specifically identified by CVE-2017-5715, "Branch Target Injection",
and is one of the two halves to Spectre.

Summary:
First, we need to explain the core of the vulnerability. Note that
this is a very incomplete description, please see the Project Zero
blog post for details:
https://googleprojectzero.blogspot.com/2018/01/reading-privileged-memory-with-side.html

The basis for branch target injection is to direct speculative
execution of the processor to some "gadget" of executable code by
poisoning the prediction of indirect branches with the address of
that gadget. The gadget in turn contains an operation that provides a
side channel for reading data. Most commonly, this will look like a
load of secret data followed by a branch on the loaded value and then
a load of some predictable cache line. The attacker then uses timing
of the processors cache to determine which direction the branch took
*in the speculative execution*, and in turn what one bit of the
loaded value was. Due to the nature of these timing side channels and
the branch predictor on Intel processors, this allows an attacker to
leak data only accessible to a privileged domain (like the kernel)
back into an unprivileged domain.

The goal is simple: avoid generating code which contains an indirect
branch that could have its prediction poisoned by an attacker. In
many cases, the compiler can simply use directed conditional branches
and a small search tree. LLVM already has support for lowering
switches in this way and the first step of this patch is to disable
jump-table lowering of switches and introduce a pass to rewrite
explicit indirectbr sequences into a switch over integers.

However, there is no fully general alternative to indirect calls. We
introduce a new construct we call a "retpoline" to implement indirect
calls in a non-speculatable way. It can be thought of loosely as a
trampoline for indirect calls which uses the RET instruction on x86.
Further, we arrange for a specific call->ret sequence which ensures
the processor predicts the return to go to a controlled, known
location. The retpoline then "smashes" the return address pushed onto
the stack by the call with the desired target of the original
indirect call. The result is a predicted return to the next
instruction after a call (which can be used to trap speculative
execution within an infinite loop) and an actual indirect branch to
an arbitrary address.

On 64-bit x86 ABIs, this is especially easily done in the compiler by
using a guaranteed scratch register to pass the target into this
device. For 32-bit ABIs there isn't a guaranteed scratch register
and so several different retpoline variants are introduced to use a
scratch register if one is available in the calling convention and to
otherwise use direct stack push/pop sequences to pass the target
address.

This "retpoline" mitigation is fully described in the following blog
post: https://support.google.com/faqs/answer/7625886

We also support a target feature that disables emission of the
retpoline thunk by the compiler to allow for custom thunks if users
want them. These are particularly useful in environments like
kernels that routinely do hot-patching on boot and want to hot-patch
their thunk to different code sequences. They can write this custom
thunk and use `-mretpoline-external-thunk` *in addition* to
`-mretpoline`. In this case, on x86-64 thu thunk names must be:
```
__llvm_external_retpoline_r11
```
or on 32-bit:
```
__llvm_external_retpoline_eax
__llvm_external_retpoline_ecx
__llvm_external_retpoline_edx
__llvm_external_retpoline_push
```
And the target of the retpoline is passed in the named register, or in
the case of the `push` suffix on the top of the stack via a `pushl`
instruction.

There is one other important source of indirect branches in x86 ELF
binaries: the PLT. These patches also include support for LLD to
generate PLT entries that perform a retpoline-style indirection.

The only other indirect branches remaining that we are aware of are
from precompiled runtimes (such as crt0.o and similar). The ones we
have found are not really attackable, and so we have not focused on
them here, but eventually these runtimes should also be replicated for
retpoline-ed configurations for completeness.

For kernels or other freestanding or fully static executables, the
compiler switch `-mretpoline` is sufficient to fully mitigate this
particular attack. For dynamic executables, you must compile *all*
libraries with `-mretpoline` and additionally link the dynamic
executable and all shared libraries with LLD and pass `-z
retpolineplt` (or use similar functionality from some other linker).
We strongly recommend also using `-z now` as non-lazy binding allows
the retpoline-mitigated PLT to be substantially smaller.

When manually apply similar transformations to `-mretpoline` to the
Linux kernel we observed very small performance hits to applications
running typic al workloads, and relatively minor hits (approximately
2%) even for extremely syscall-heavy applications. This is largely
due to the small number of indirect branches that occur in
performance sensitive paths of the kernel.

When using these patches on statically linked applications,
especially C++ applications, you should expect to see a much more
dramatic performance hit. For microbenchmarks that are switch,
indirect-, or virtual-call heavy we have seen overheads ranging from
10% to 50%.

However, real-world workloads exhibit substantially lower performance
impact. Notably, techniques such as PGO and ThinLTO dramatically
reduce the impact of hot indirect calls (by speculatively promoting
them to direct calls) and allow optimized search trees to be used to
lower switches. If you need to deploy these techniques in C++
applications, we *strongly* recommend that you ensure all hot call
targets are statically linked (avoiding PLT indirection) and use both
PGO and ThinLTO. Well tuned servers using all of these techniques saw
5% - 10% overhead from the use of retpoline.

We will add detailed documentation covering these components in
subsequent patches, but wanted to make the core functionality
available as soon as possible. Happy for more code review, but we'd
really like to get these patches landed and backported ASAP for
obvious reasons. We're planning to backport this to both 6.0 and 5.0
release streams and get a 5.0 release with just this cherry picked
ASAP for distros and vendors.

This patch is the work of a number of people over the past month:
Eric, Reid, Rui, and myself. I'm mailing it out as a single commit
due to the time sensitive nature of landing this and the need to
backport it. Huge thanks to everyone who helped out here, and
everyone at Intel who helped out in discussions about how to craft
this. Also, credit goes to Paul Turner (at Google, but not an LLVM
contributor) for much of the underlying retpoline design.

Reviewers: echristo, rnk, ruiu, craig.topper, DavidKreitzer

Subscribers: sanjoy, emaste, mcrosier, mgorny, mehdi_amini, hiraditya, llvm-commits

Differential Revision: https://reviews.llvm.org/D41723

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 842d113b 01-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r323948).

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 042b1c2e 24-Jan-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r323338).

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 30785c0e 06-Jan-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_60 r321788,
update build glue and version numbers.


# fe4fed2e 28-Dec-2017 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ trunk r321545,
update build glue and version numbers, add new intrinsics headers, and
update OptionalObsoleteFiles.inc.


# 2757ff7e 23-Dec-2017 Dimitry Andric <dim@FreeBSD.org>

Update clang, lld and llvm version numbers for r321414, and update build
glue.

# 02d2ad99 20-Dec-2017 Dimitry Andric <dim@FreeBSD.org>

Update generated config headers, and version numbers.

# 809922b0 05-Jun-2022 Dimitry Andric <dim@FreeBSD.org>

Update rest of llvm-project build glue for 14.0.4

I completely forgot about updating the generated llvm-project config
files, which also contain version numbers, etc. Sorry for the churn.

PR: 261742
Fixes: ab9d54731f43
MFC after: 3 days


# ab9d5473 04-Jun-2022 Dimitry Andric <dim@FreeBSD.org>

Bump versions llvm-project release/14.x llvmorg-14.0.4-0-g29f1039a7285

Somehow git rebase made this squashed commit disappear. Restore it.

PR: 261742
MFC after: 3 days


# 3a9a9c0c 28-Apr-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.3-0-g1f9140064dfb

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.3-0-g1f9140064dfb.

PR: 261742
MFC after: 2 weeks


# dbc822f3 29-Mar-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.0-2-g3f43d803382d

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-2-g3f43d803382d.

PR: 261742
MFC after: 2 weeks


# fb03ea46 17-Mar-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.0-rc4-2-gadd3ab7f4c8a

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-rc4-2-gadd3ab7f4c8a.

PR: 261742
MFC after: 2 weeks


# d781ede6 05-Mar-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.0-rc2-12-g09546e1b5103

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-rc2-12-g09546e1b5103.

PR: 261742
MFC after: 2 weeks


# d56accc7 18-Feb-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14.0.0-rc1-74-g4dc3cb8e3255

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14.0.0-rc1-74-g4dc3cb8e3255.

PR: 261742
MFC after: 2 weeks


# 1838bd0f 05-Feb-2022 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project release/14.x llvmorg-14-init-18315-g190be5457c90

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-14-init-18315-g190be5457c90.

PR: 261742
MFC after: 2 weeks


# 5e801ac6 20-Nov-2021 Dimitry Andric <dim@FreeBSD.org>

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


# fe6060f1 22-Aug-2021 Dimitry Andric <dim@FreeBSD.org>

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


# 23408297 18-Jun-2021 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project 12.0.1 rc2

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-12.0.1-rc2-0-ge7dac564cd0e, a.k.a. 12.0.1 rc2.

PR: 255570
MFC after: 6 weeks


# e8d8bef9 13-Jun-2021 Dimitry Andric <dim@FreeBSD.org>

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


# f9a66922 21-Jan-2021 Glen Barber <gjb@FreeBSD.org>

fix incorrect LLD_VERSION_STRING from previous commit

Reported by: Oliver Pinter
Sponsored by: Rubicon Communications, LLC ("Netgate")

# a53ce3fc 21-Jan-2021 Glen Barber <gjb@FreeBSD.org>

Bump CURRENT to 14.0

This one goes to 14.

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC ("Netgate")

# eaeb601b 03-Jan-2021 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
release/11.x llvmorg-11.0.1-rc2-0-g43ff75f2c3f (aka 11.0.1 rc2).

MFC after: 4 weeks
X-MFC-With: r364284


# 5f24ef21 06-Aug-2020 Dimitry Andric <dim@FreeBSD.org>

Update generated llvm-project related version headers, config.h files
and add a newly generated lldb Plugins.def file too.

# d65cd7a5 23-May-2020 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
llvmorg-10.0.1-rc1-0-gf79cd71e145 (aka 10.0.1 rc1).

MFC after: 3 weeks


# 0b37c159 25-Jan-2020 Dimitry Andric <dim@FreeBSD.org>

* Bump version numbers to 10.0.0
* Update UPDATING
* Update (Optional)ObsoleteFiles.inc
* Update VCS(Revision|Version) files
* Update generated config headers
* Update clang internal headers Makefile

# c14a5a88 22-Dec-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
9.0.1 final release c1a0a213378a458fbea1a5c77b315c7dce08fd05.

Release notes for llvm, clang, lld and libc++ 9.0.1 will become
available here:

https://releases.llvm.org/9.0.1/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.1/tools/clang/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.1/tools/lld/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.1/projects/libcxx/docs/ReleaseNotes.html

PR: 240629
MFC after: 1 month


# fb3a446a 06-Sep-2019 Dimitry Andric <dim@FreeBSD.org>

Add a VCSVersion.inc header with revision and repository defines,
similar to what upstream generates via CMake. Though for us it is
handier to have everything in one file.

# 6a82ac86 02-Sep-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb, and openmp
release_90 branch r370514, and update version numbers.


# 22f75ae7 02-Sep-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb, and openmp
release_90 branch r369369, and update version numbers.


# 86aa9539 23-Aug-2019 Dimitry Andric <dim@FreeBSD.org>

Regenerate config and version headers.

# 87c8ef55 20-Jul-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
8.0.1 final release r366581. The only functional change is a fix for a
mismerge of upstream r360816, which properly restores the r2 register
when unwinding on PowerPC64 (See https://reviews.freebsd.org/D20337).

Relnotes: yes
PR: 236062
MFC after: 3 days
X-MFC-With: r349004


# ec38f4f9 06-Jul-2019 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt, libc++,
libunwind and openmp to the upstream release_80 branch r364487
(effectively, 8.0.1 rc3). The 8.0.1 release will most likely
have no further changes.

MFC after: 1 week
X-MFC-With: r349004


# efc5c442 12-Jun-2019 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt, libc++,
libunwind and openmp to the upstream release_80 branch r363030
(effectively, 8.0.1 rc2). The 8.0.1 release should follow this within a
week or so.

MFC after: 2 weeks


# c3e6b9d3 20-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Pull in r352826 from upstream lld trunk (by Fangrui Song):

[ELF] Support --{,no-}allow-shlib-undefined

Summary:
In ld.bfd/gold, --no-allow-shlib-undefined is the default when
linking an executable. This patch implements a check to error on
undefined symbols in a shared object, if all of its DT_NEEDED entries
are seen.

Our approach resembles the one used in gold, achieves a good balance
to be useful but not too smart (ld.bfd traces all DSOs and emulates
the behavior of a dynamic linker to catch more cases).

The error is issued based on the symbol table, different from
undefined reference errors issued for relocations. It is most
effective when there are DSOs that were not linked with -z defs (e.g.
when static sanitizers runtime is used).

gold has a comment that some system libraries on GNU/Linux may have
spurious undefined references and thus system libraries should be
excluded (https://sourceware.org/bugzilla/show_bug.cgi?id=6811). The
story may have changed now but we make --allow-shlib-undefined the
default for now. Its interaction with -shared can be discussed in the
future.

Reviewers: ruiu, grimar, pcc, espindola

Reviewed By: ruiu

Subscribers: joerg, emaste, arichardson, llvm-commits

Differential Revision: https://reviews.llvm.org/D57385

Pull in r352943 from upstream lld trunk (by Fangrui Song):

[ELF] Default to --no-allow-shlib-undefined for executables

Summary:
This follows the ld.bfd/gold behavior.

The error check is useful as it captures a common type of ld.so
undefined symbol errors as link-time errors:

// a.cc => a.so (not linked with -z defs)
void f(); // f is undefined
void g() { f(); }

// b.cc => executable with a DT_NEEDED entry on a.so
void g();
int main() { g(); }

// ld.so errors when g() is executed (lazy binding) or when the program is started (-z now)
// symbol lookup error: ... undefined symbol: f

Reviewers: ruiu, grimar, pcc, espindola

Reviewed By: ruiu

Subscribers: llvm-commits, emaste, arichardson

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D57569

Together, these add support for --no-allow-shlib-undefined, and make it
the default for executables, so they will fail to link if any symbols
from needed shared libraries are undefined.

Reported by: jbeich
PR: 236062, 236141
MFC after: 1 month
X-MFC-With: r344779

# fb7e42b9 20-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
8.0.0 final release r356365. There were no functional changes since the
most recent merge, of 8.0.0 rc5.

Release notes for llvm, clang, lld and libc++ 8.0.0 are now available:

https://llvm.org/releases/8.0.0/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/tools/clang/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/tools/lld/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/projects/libcxx/docs/ReleaseNotes.html

PR: 236062
MFC after: 1 month
X-MFC-With: r344779


# 2352f970 14-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, and lldb
release_80 branch r356034 (effectively, 8.0.0 rc5), resolve conflicts,
and bump version numbers.

PR: 236062
MFC after: 1 month
X-MFC-With: r344779


# b3ed818e 08-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r355677 (effectively, 8.0.0 rc4), resolve conflicts, and bump version
numbers.

PR: 236062
MFC after: 1 month
X-MFC-With: r344779


# 3087b115 04-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r355313, resolve conflicts, and bump version numbers.


# da18572f 25-Feb-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r354799, resolve conflicts, and bump version numbers.


# 640dd76f 15-Feb-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r354130, resolve conflicts, and bump version numbers.


# c8630eab 05-Feb-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r353167, resolve conflicts, and bump version numbers.


# af44a011 22-Jan-2019 Dimitry Andric <dim@FreeBSD.org>

Now for the release_80 branch, update version numbers for llvm, clang
and lld, and regenerate config headers.

# 0bf31f1f 20-Jan-2019 Dimitry Andric <dim@FreeBSD.org>

Update version numbers, and regenerate config headers for llvm, clang,
lld and lldb. Update ObsoleteFiles.inc and OptionalObsoleteFiles.inc.

# 176fdeee 15-Dec-2018 Dimitry Andric <dim@FreeBSD.org>

Update clang, llvm, lld, lldb, compiler-rt and libc++ version number to
7.0.1 release r349250. There were no functional changes since the 7.0.1
rc3 import.

PR: 230240, 230355
Relnotes: yes
MFC after: 2 months
X-MFC-With: r341825


# 0b9890fc 09-Dec-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r348686 (effectively 7.0.1 rc3), resolve conflicts, and bump version
numbers.

PR: 230240, 230355


# 68948600 04-Nov-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r346007 (effectively 7.0.1 rc2), resolve conflicts, and bump version
numbers.

PR: 230240, 230355


# c6879c6c 23-Oct-2018 Dimitry Andric <dim@FreeBSD.org>

Merge ^/head r339015 through r339669.


# b0bffd12 20-Oct-2018 Ed Maste <emaste@FreeBSD.org>

Bump LLD_REVISION_STRING for 13-CURRENT

# b371a9f0 11-Oct-2018 Ed Maste <emaste@FreeBSD.org>

lld: set sh_link and sh_info for .rela.plt sections

ELF spec says that for SHT_REL and SHT_RELA sh_link should reference the
associated string table and sh_info should reference the "section to
which the relocation applies." ELF Tool Chain's elfcopy / strip use
this (in part) to control whether or not the relocation entry is copied
to the output.

LLVM PR 37538 https://bugs.llvm.org/show_bug.cgi?id=37538

Approved by: re (kib)
Obtained from: llvm r344226 (backported for 6.0)

# 38fb4010 17-Sep-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ 7.0.0 release
r342383, and bump version numbers.

PR: 230240, 230355


# c826f0db 11-Sep-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r341916, resolve conflicts, and bump version numbers.

PR: 230240, 230355


# 8ba00cf9 29-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r340910, resolve conflicts, and bump version numbers.

PR: 230240, 230355


# 7726714d 17-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r339999, resolve conflicts, and bump version numbers.

PR: 230240,230355


# 3beb5372 11-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r339355, resolve conflicts, and bump version numbers.


# 84ba35dc 04-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Bump clang and lld upstream revision numbers.

# 0fecf001 02-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Bump revisions to r338536, and also bump lld version again.

# 837f3385 31-Jul-2018 Ed Maste <emaste@FreeBSD.org>

bump lld version number after r336972 arm(v7) VFP tag support

Reported by: kevans
Sponsored by: The FreeBSD Foundation

# 6dfa117f 31-Jul-2018 Dimitry Andric <dim@FreeBSD.org>

Update llvm/clang version numbers in various files.

# fbfca78e 30-Jun-2018 Dimitry Andric <dim@FreeBSD.org>

Follow-up to r335799 (llvm/clang 6.0.1 update), by regenerating various
headers with new version information defines.

MFC after: 2 weeks
X-MFC-With: r335799

# 6ccc06f6 29-Jun-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.1 release (upstream r335540).

Relnotes: yes
MFC after: 2 weeks


# 19703503 09-May-2018 Ed Maste <emaste@FreeBSD.org>

lld: Omit PT_NOTE for SHT_NOTE without SHF_ALLOC

A non-alloc note section should not have a PT_NOTE program header.

Found while linking ghc (Haskell compiler) with lld on FreeBSD. Haskell
emits a .debug-ghc-link-info note section (as the name suggests, it
contains link info) as a SHT_NOTE section without SHF_ALLOC set.

For this case ld.bfd does not emit a PT_NOTE segment for
.debug-ghc-link-info. lld previously emitted a PT_NOTE with p_vaddr = 0
and FreeBSD's rtld segfaulted when trying to parse a note at address 0.

LLVM PR: https://llvm.org/pr37361
LLVM review: https://reviews.llvm.org/D46623

PR: 226872
Reviewed by: dim
Sponsored by: The FreeBSD Foundation

# 08730804 19-Apr-2018 Ed Maste <emaste@FreeBSD.org>

lld: use correct number of digits in __FreeBSD_version-style ID

__FreeBSD_version-style IDs should have 5 digits following the major.

# 12881601 17-Apr-2018 Ed Maste <emaste@FreeBSD.org>

lld: add a __FreeBSD_version-style identifier to version

This will faciliate a WITH_SYSTEM_LINKER option.

Reviewed by: dim
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D15110

# c5a4cd4f 04-Mar-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 release (upstream r326565).

Release notes for llvm, clang and lld will be available here soon:
<http://releases.llvm.org/6.0.0/docs/ReleaseNotes.html>
<http://releases.llvm.org/6.0.0/tools/clang/docs/ReleaseNotes.html>
<http://releases.llvm.org/6.0.0/tools/lld/docs/ReleaseNotes.html>

Relnotes: yes
MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 4f8786af 25-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r325932). This corresponds to 6.0.0 rc3.

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 954b921d 16-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r325330).

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 07577dfe 02-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r324090).

This introduces retpoline support, with the -mretpoline flag. The
upstream initial commit message (r323155 by Chandler Carruth) contains
quite a bit of explanation. Quoting:

Introduce the "retpoline" x86 mitigation technique for variant #2 of
the speculative execution vulnerabilities disclosed today,
specifically identified by CVE-2017-5715, "Branch Target Injection",
and is one of the two halves to Spectre.

Summary:
First, we need to explain the core of the vulnerability. Note that
this is a very incomplete description, please see the Project Zero
blog post for details:
https://googleprojectzero.blogspot.com/2018/01/reading-privileged-memory-with-side.html

The basis for branch target injection is to direct speculative
execution of the processor to some "gadget" of executable code by
poisoning the prediction of indirect branches with the address of
that gadget. The gadget in turn contains an operation that provides a
side channel for reading data. Most commonly, this will look like a
load of secret data followed by a branch on the loaded value and then
a load of some predictable cache line. The attacker then uses timing
of the processors cache to determine which direction the branch took
*in the speculative execution*, and in turn what one bit of the
loaded value was. Due to the nature of these timing side channels and
the branch predictor on Intel processors, this allows an attacker to
leak data only accessible to a privileged domain (like the kernel)
back into an unprivileged domain.

The goal is simple: avoid generating code which contains an indirect
branch that could have its prediction poisoned by an attacker. In
many cases, the compiler can simply use directed conditional branches
and a small search tree. LLVM already has support for lowering
switches in this way and the first step of this patch is to disable
jump-table lowering of switches and introduce a pass to rewrite
explicit indirectbr sequences into a switch over integers.

However, there is no fully general alternative to indirect calls. We
introduce a new construct we call a "retpoline" to implement indirect
calls in a non-speculatable way. It can be thought of loosely as a
trampoline for indirect calls which uses the RET instruction on x86.
Further, we arrange for a specific call->ret sequence which ensures
the processor predicts the return to go to a controlled, known
location. The retpoline then "smashes" the return address pushed onto
the stack by the call with the desired target of the original
indirect call. The result is a predicted return to the next
instruction after a call (which can be used to trap speculative
execution within an infinite loop) and an actual indirect branch to
an arbitrary address.

On 64-bit x86 ABIs, this is especially easily done in the compiler by
using a guaranteed scratch register to pass the target into this
device. For 32-bit ABIs there isn't a guaranteed scratch register
and so several different retpoline variants are introduced to use a
scratch register if one is available in the calling convention and to
otherwise use direct stack push/pop sequences to pass the target
address.

This "retpoline" mitigation is fully described in the following blog
post: https://support.google.com/faqs/answer/7625886

We also support a target feature that disables emission of the
retpoline thunk by the compiler to allow for custom thunks if users
want them. These are particularly useful in environments like
kernels that routinely do hot-patching on boot and want to hot-patch
their thunk to different code sequences. They can write this custom
thunk and use `-mretpoline-external-thunk` *in addition* to
`-mretpoline`. In this case, on x86-64 thu thunk names must be:
```
__llvm_external_retpoline_r11
```
or on 32-bit:
```
__llvm_external_retpoline_eax
__llvm_external_retpoline_ecx
__llvm_external_retpoline_edx
__llvm_external_retpoline_push
```
And the target of the retpoline is passed in the named register, or in
the case of the `push` suffix on the top of the stack via a `pushl`
instruction.

There is one other important source of indirect branches in x86 ELF
binaries: the PLT. These patches also include support for LLD to
generate PLT entries that perform a retpoline-style indirection.

The only other indirect branches remaining that we are aware of are
from precompiled runtimes (such as crt0.o and similar). The ones we
have found are not really attackable, and so we have not focused on
them here, but eventually these runtimes should also be replicated for
retpoline-ed configurations for completeness.

For kernels or other freestanding or fully static executables, the
compiler switch `-mretpoline` is sufficient to fully mitigate this
particular attack. For dynamic executables, you must compile *all*
libraries with `-mretpoline` and additionally link the dynamic
executable and all shared libraries with LLD and pass `-z
retpolineplt` (or use similar functionality from some other linker).
We strongly recommend also using `-z now` as non-lazy binding allows
the retpoline-mitigated PLT to be substantially smaller.

When manually apply similar transformations to `-mretpoline` to the
Linux kernel we observed very small performance hits to applications
running typic al workloads, and relatively minor hits (approximately
2%) even for extremely syscall-heavy applications. This is largely
due to the small number of indirect branches that occur in
performance sensitive paths of the kernel.

When using these patches on statically linked applications,
especially C++ applications, you should expect to see a much more
dramatic performance hit. For microbenchmarks that are switch,
indirect-, or virtual-call heavy we have seen overheads ranging from
10% to 50%.

However, real-world workloads exhibit substantially lower performance
impact. Notably, techniques such as PGO and ThinLTO dramatically
reduce the impact of hot indirect calls (by speculatively promoting
them to direct calls) and allow optimized search trees to be used to
lower switches. If you need to deploy these techniques in C++
applications, we *strongly* recommend that you ensure all hot call
targets are statically linked (avoiding PLT indirection) and use both
PGO and ThinLTO. Well tuned servers using all of these techniques saw
5% - 10% overhead from the use of retpoline.

We will add detailed documentation covering these components in
subsequent patches, but wanted to make the core functionality
available as soon as possible. Happy for more code review, but we'd
really like to get these patches landed and backported ASAP for
obvious reasons. We're planning to backport this to both 6.0 and 5.0
release streams and get a 5.0 release with just this cherry picked
ASAP for distros and vendors.

This patch is the work of a number of people over the past month:
Eric, Reid, Rui, and myself. I'm mailing it out as a single commit
due to the time sensitive nature of landing this and the need to
backport it. Huge thanks to everyone who helped out here, and
everyone at Intel who helped out in discussions about how to craft
this. Also, credit goes to Paul Turner (at Google, but not an LLVM
contributor) for much of the underlying retpoline design.

Reviewers: echristo, rnk, ruiu, craig.topper, DavidKreitzer

Subscribers: sanjoy, emaste, mcrosier, mgorny, mehdi_amini, hiraditya, llvm-commits

Differential Revision: https://reviews.llvm.org/D41723

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 842d113b 01-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r323948).

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 042b1c2e 24-Jan-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r323338).

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 30785c0e 06-Jan-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_60 r321788,
update build glue and version numbers.


# fe4fed2e 28-Dec-2017 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ trunk r321545,
update build glue and version numbers, add new intrinsics headers, and
update OptionalObsoleteFiles.inc.


# 2757ff7e 23-Dec-2017 Dimitry Andric <dim@FreeBSD.org>

Update clang, lld and llvm version numbers for r321414, and update build
glue.

# 02d2ad99 20-Dec-2017 Dimitry Andric <dim@FreeBSD.org>

Update generated config headers, and version numbers.

# fe6060f1 22-Aug-2021 Dimitry Andric <dim@FreeBSD.org>

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


# 23408297 18-Jun-2021 Dimitry Andric <dim@FreeBSD.org>

Merge llvm-project 12.0.1 rc2

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-12.0.1-rc2-0-ge7dac564cd0e, a.k.a. 12.0.1 rc2.

PR: 255570
MFC after: 6 weeks


# e8d8bef9 13-Jun-2021 Dimitry Andric <dim@FreeBSD.org>

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


# f9a66922 21-Jan-2021 Glen Barber <gjb@FreeBSD.org>

fix incorrect LLD_VERSION_STRING from previous commit

Reported by: Oliver Pinter
Sponsored by: Rubicon Communications, LLC ("Netgate")

# a53ce3fc 21-Jan-2021 Glen Barber <gjb@FreeBSD.org>

Bump CURRENT to 14.0

This one goes to 14.

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC ("Netgate")

# eaeb601b 03-Jan-2021 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
release/11.x llvmorg-11.0.1-rc2-0-g43ff75f2c3f (aka 11.0.1 rc2).

MFC after: 4 weeks
X-MFC-With: r364284


# 5f24ef21 06-Aug-2020 Dimitry Andric <dim@FreeBSD.org>

Update generated llvm-project related version headers, config.h files
and add a newly generated lldb Plugins.def file too.

# d65cd7a5 23-May-2020 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
llvmorg-10.0.1-rc1-0-gf79cd71e145 (aka 10.0.1 rc1).

MFC after: 3 weeks


# 0b37c159 25-Jan-2020 Dimitry Andric <dim@FreeBSD.org>

* Bump version numbers to 10.0.0
* Update UPDATING
* Update (Optional)ObsoleteFiles.inc
* Update VCS(Revision|Version) files
* Update generated config headers
* Update clang internal headers Makefile

# c14a5a88 22-Dec-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
9.0.1 final release c1a0a213378a458fbea1a5c77b315c7dce08fd05.

Release notes for llvm, clang, lld and libc++ 9.0.1 will become
available here:

https://releases.llvm.org/9.0.1/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.1/tools/clang/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.1/tools/lld/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.1/projects/libcxx/docs/ReleaseNotes.html

PR: 240629
MFC after: 1 month


# fb3a446a 06-Sep-2019 Dimitry Andric <dim@FreeBSD.org>

Add a VCSVersion.inc header with revision and repository defines,
similar to what upstream generates via CMake. Though for us it is
handier to have everything in one file.

# 6a82ac86 02-Sep-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb, and openmp
release_90 branch r370514, and update version numbers.


# 22f75ae7 02-Sep-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb, and openmp
release_90 branch r369369, and update version numbers.


# 86aa9539 23-Aug-2019 Dimitry Andric <dim@FreeBSD.org>

Regenerate config and version headers.

# 87c8ef55 20-Jul-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
8.0.1 final release r366581. The only functional change is a fix for a
mismerge of upstream r360816, which properly restores the r2 register
when unwinding on PowerPC64 (See https://reviews.freebsd.org/D20337).

Relnotes: yes
PR: 236062
MFC after: 3 days
X-MFC-With: r349004


# ec38f4f9 06-Jul-2019 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt, libc++,
libunwind and openmp to the upstream release_80 branch r364487
(effectively, 8.0.1 rc3). The 8.0.1 release will most likely
have no further changes.

MFC after: 1 week
X-MFC-With: r349004


# efc5c442 12-Jun-2019 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt, libc++,
libunwind and openmp to the upstream release_80 branch r363030
(effectively, 8.0.1 rc2). The 8.0.1 release should follow this within a
week or so.

MFC after: 2 weeks


# c3e6b9d3 20-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Pull in r352826 from upstream lld trunk (by Fangrui Song):

[ELF] Support --{,no-}allow-shlib-undefined

Summary:
In ld.bfd/gold, --no-allow-shlib-undefined is the default when
linking an executable. This patch implements a check to error on
undefined symbols in a shared object, if all of its DT_NEEDED entries
are seen.

Our approach resembles the one used in gold, achieves a good balance
to be useful but not too smart (ld.bfd traces all DSOs and emulates
the behavior of a dynamic linker to catch more cases).

The error is issued based on the symbol table, different from
undefined reference errors issued for relocations. It is most
effective when there are DSOs that were not linked with -z defs (e.g.
when static sanitizers runtime is used).

gold has a comment that some system libraries on GNU/Linux may have
spurious undefined references and thus system libraries should be
excluded (https://sourceware.org/bugzilla/show_bug.cgi?id=6811). The
story may have changed now but we make --allow-shlib-undefined the
default for now. Its interaction with -shared can be discussed in the
future.

Reviewers: ruiu, grimar, pcc, espindola

Reviewed By: ruiu

Subscribers: joerg, emaste, arichardson, llvm-commits

Differential Revision: https://reviews.llvm.org/D57385

Pull in r352943 from upstream lld trunk (by Fangrui Song):

[ELF] Default to --no-allow-shlib-undefined for executables

Summary:
This follows the ld.bfd/gold behavior.

The error check is useful as it captures a common type of ld.so
undefined symbol errors as link-time errors:

// a.cc => a.so (not linked with -z defs)
void f(); // f is undefined
void g() { f(); }

// b.cc => executable with a DT_NEEDED entry on a.so
void g();
int main() { g(); }

// ld.so errors when g() is executed (lazy binding) or when the program is started (-z now)
// symbol lookup error: ... undefined symbol: f

Reviewers: ruiu, grimar, pcc, espindola

Reviewed By: ruiu

Subscribers: llvm-commits, emaste, arichardson

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D57569

Together, these add support for --no-allow-shlib-undefined, and make it
the default for executables, so they will fail to link if any symbols
from needed shared libraries are undefined.

Reported by: jbeich
PR: 236062, 236141
MFC after: 1 month
X-MFC-With: r344779

# fb7e42b9 20-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
8.0.0 final release r356365. There were no functional changes since the
most recent merge, of 8.0.0 rc5.

Release notes for llvm, clang, lld and libc++ 8.0.0 are now available:

https://llvm.org/releases/8.0.0/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/tools/clang/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/tools/lld/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/projects/libcxx/docs/ReleaseNotes.html

PR: 236062
MFC after: 1 month
X-MFC-With: r344779


# 2352f970 14-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, and lldb
release_80 branch r356034 (effectively, 8.0.0 rc5), resolve conflicts,
and bump version numbers.

PR: 236062
MFC after: 1 month
X-MFC-With: r344779


# b3ed818e 08-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r355677 (effectively, 8.0.0 rc4), resolve conflicts, and bump version
numbers.

PR: 236062
MFC after: 1 month
X-MFC-With: r344779


# 3087b115 04-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r355313, resolve conflicts, and bump version numbers.


# da18572f 25-Feb-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r354799, resolve conflicts, and bump version numbers.


# 640dd76f 15-Feb-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r354130, resolve conflicts, and bump version numbers.


# c8630eab 05-Feb-2019 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r353167, resolve conflicts, and bump version numbers.


# af44a011 22-Jan-2019 Dimitry Andric <dim@FreeBSD.org>

Now for the release_80 branch, update version numbers for llvm, clang
and lld, and regenerate config headers.

# 0bf31f1f 20-Jan-2019 Dimitry Andric <dim@FreeBSD.org>

Update version numbers, and regenerate config headers for llvm, clang,
lld and lldb. Update ObsoleteFiles.inc and OptionalObsoleteFiles.inc.

# 176fdeee 15-Dec-2018 Dimitry Andric <dim@FreeBSD.org>

Update clang, llvm, lld, lldb, compiler-rt and libc++ version number to
7.0.1 release r349250. There were no functional changes since the 7.0.1
rc3 import.

PR: 230240, 230355
Relnotes: yes
MFC after: 2 months
X-MFC-With: r341825


# 0b9890fc 09-Dec-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r348686 (effectively 7.0.1 rc3), resolve conflicts, and bump version
numbers.

PR: 230240, 230355


# 68948600 04-Nov-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r346007 (effectively 7.0.1 rc2), resolve conflicts, and bump version
numbers.

PR: 230240, 230355


# c6879c6c 23-Oct-2018 Dimitry Andric <dim@FreeBSD.org>

Merge ^/head r339015 through r339669.


# b0bffd12 20-Oct-2018 Ed Maste <emaste@FreeBSD.org>

Bump LLD_REVISION_STRING for 13-CURRENT

# b371a9f0 11-Oct-2018 Ed Maste <emaste@FreeBSD.org>

lld: set sh_link and sh_info for .rela.plt sections

ELF spec says that for SHT_REL and SHT_RELA sh_link should reference the
associated string table and sh_info should reference the "section to
which the relocation applies." ELF Tool Chain's elfcopy / strip use
this (in part) to control whether or not the relocation entry is copied
to the output.

LLVM PR 37538 https://bugs.llvm.org/show_bug.cgi?id=37538

Approved by: re (kib)
Obtained from: llvm r344226 (backported for 6.0)

# 38fb4010 17-Sep-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ 7.0.0 release
r342383, and bump version numbers.

PR: 230240, 230355


# c826f0db 11-Sep-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r341916, resolve conflicts, and bump version numbers.

PR: 230240, 230355


# 8ba00cf9 29-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r340910, resolve conflicts, and bump version numbers.

PR: 230240, 230355


# 7726714d 17-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r339999, resolve conflicts, and bump version numbers.

PR: 230240,230355


# 3beb5372 11-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_70 branch
r339355, resolve conflicts, and bump version numbers.


# 84ba35dc 04-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Bump clang and lld upstream revision numbers.

# 0fecf001 02-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Bump revisions to r338536, and also bump lld version again.

# 837f3385 31-Jul-2018 Ed Maste <emaste@FreeBSD.org>

bump lld version number after r336972 arm(v7) VFP tag support

Reported by: kevans
Sponsored by: The FreeBSD Foundation

# 6dfa117f 31-Jul-2018 Dimitry Andric <dim@FreeBSD.org>

Update llvm/clang version numbers in various files.

# fbfca78e 30-Jun-2018 Dimitry Andric <dim@FreeBSD.org>

Follow-up to r335799 (llvm/clang 6.0.1 update), by regenerating various
headers with new version information defines.

MFC after: 2 weeks
X-MFC-With: r335799

# 6ccc06f6 29-Jun-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.1 release (upstream r335540).

Relnotes: yes
MFC after: 2 weeks


# 19703503 09-May-2018 Ed Maste <emaste@FreeBSD.org>

lld: Omit PT_NOTE for SHT_NOTE without SHF_ALLOC

A non-alloc note section should not have a PT_NOTE program header.

Found while linking ghc (Haskell compiler) with lld on FreeBSD. Haskell
emits a .debug-ghc-link-info note section (as the name suggests, it
contains link info) as a SHT_NOTE section without SHF_ALLOC set.

For this case ld.bfd does not emit a PT_NOTE segment for
.debug-ghc-link-info. lld previously emitted a PT_NOTE with p_vaddr = 0
and FreeBSD's rtld segfaulted when trying to parse a note at address 0.

LLVM PR: https://llvm.org/pr37361
LLVM review: https://reviews.llvm.org/D46623

PR: 226872
Reviewed by: dim
Sponsored by: The FreeBSD Foundation

# 08730804 19-Apr-2018 Ed Maste <emaste@FreeBSD.org>

lld: use correct number of digits in __FreeBSD_version-style ID

__FreeBSD_version-style IDs should have 5 digits following the major.

# 12881601 17-Apr-2018 Ed Maste <emaste@FreeBSD.org>

lld: add a __FreeBSD_version-style identifier to version

This will faciliate a WITH_SYSTEM_LINKER option.

Reviewed by: dim
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D15110

# c5a4cd4f 04-Mar-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 release (upstream r326565).

Release notes for llvm, clang and lld will be available here soon:
<http://releases.llvm.org/6.0.0/docs/ReleaseNotes.html>
<http://releases.llvm.org/6.0.0/tools/clang/docs/ReleaseNotes.html>
<http://releases.llvm.org/6.0.0/tools/lld/docs/ReleaseNotes.html>

Relnotes: yes
MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 4f8786af 25-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r325932). This corresponds to 6.0.0 rc3.

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 954b921d 16-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r325330).

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 07577dfe 02-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r324090).

This introduces retpoline support, with the -mretpoline flag. The
upstream initial commit message (r323155 by Chandler Carruth) contains
quite a bit of explanation. Quoting:

Introduce the "retpoline" x86 mitigation technique for variant #2 of
the speculative execution vulnerabilities disclosed today,
specifically identified by CVE-2017-5715, "Branch Target Injection",
and is one of the two halves to Spectre.

Summary:
First, we need to explain the core of the vulnerability. Note that
this is a very incomplete description, please see the Project Zero
blog post for details:
https://googleprojectzero.blogspot.com/2018/01/reading-privileged-memory-with-side.html

The basis for branch target injection is to direct speculative
execution of the processor to some "gadget" of executable code by
poisoning the prediction of indirect branches with the address of
that gadget. The gadget in turn contains an operation that provides a
side channel for reading data. Most commonly, this will look like a
load of secret data followed by a branch on the loaded value and then
a load of some predictable cache line. The attacker then uses timing
of the processors cache to determine which direction the branch took
*in the speculative execution*, and in turn what one bit of the
loaded value was. Due to the nature of these timing side channels and
the branch predictor on Intel processors, this allows an attacker to
leak data only accessible to a privileged domain (like the kernel)
back into an unprivileged domain.

The goal is simple: avoid generating code which contains an indirect
branch that could have its prediction poisoned by an attacker. In
many cases, the compiler can simply use directed conditional branches
and a small search tree. LLVM already has support for lowering
switches in this way and the first step of this patch is to disable
jump-table lowering of switches and introduce a pass to rewrite
explicit indirectbr sequences into a switch over integers.

However, there is no fully general alternative to indirect calls. We
introduce a new construct we call a "retpoline" to implement indirect
calls in a non-speculatable way. It can be thought of loosely as a
trampoline for indirect calls which uses the RET instruction on x86.
Further, we arrange for a specific call->ret sequence which ensures
the processor predicts the return to go to a controlled, known
location. The retpoline then "smashes" the return address pushed onto
the stack by the call with the desired target of the original
indirect call. The result is a predicted return to the next
instruction after a call (which can be used to trap speculative
execution within an infinite loop) and an actual indirect branch to
an arbitrary address.

On 64-bit x86 ABIs, this is especially easily done in the compiler by
using a guaranteed scratch register to pass the target into this
device. For 32-bit ABIs there isn't a guaranteed scratch register
and so several different retpoline variants are introduced to use a
scratch register if one is available in the calling convention and to
otherwise use direct stack push/pop sequences to pass the target
address.

This "retpoline" mitigation is fully described in the following blog
post: https://support.google.com/faqs/answer/7625886

We also support a target feature that disables emission of the
retpoline thunk by the compiler to allow for custom thunks if users
want them. These are particularly useful in environments like
kernels that routinely do hot-patching on boot and want to hot-patch
their thunk to different code sequences. They can write this custom
thunk and use `-mretpoline-external-thunk` *in addition* to
`-mretpoline`. In this case, on x86-64 thu thunk names must be:
```
__llvm_external_retpoline_r11
```
or on 32-bit:
```
__llvm_external_retpoline_eax
__llvm_external_retpoline_ecx
__llvm_external_retpoline_edx
__llvm_external_retpoline_push
```
And the target of the retpoline is passed in the named register, or in
the case of the `push` suffix on the top of the stack via a `pushl`
instruction.

There is one other important source of indirect branches in x86 ELF
binaries: the PLT. These patches also include support for LLD to
generate PLT entries that perform a retpoline-style indirection.

The only other indirect branches remaining that we are aware of are
from precompiled runtimes (such as crt0.o and similar). The ones we
have found are not really attackable, and so we have not focused on
them here, but eventually these runtimes should also be replicated for
retpoline-ed configurations for completeness.

For kernels or other freestanding or fully static executables, the
compiler switch `-mretpoline` is sufficient to fully mitigate this
particular attack. For dynamic executables, you must compile *all*
libraries with `-mretpoline` and additionally link the dynamic
executable and all shared libraries with LLD and pass `-z
retpolineplt` (or use similar functionality from some other linker).
We strongly recommend also using `-z now` as non-lazy binding allows
the retpoline-mitigated PLT to be substantially smaller.

When manually apply similar transformations to `-mretpoline` to the
Linux kernel we observed very small performance hits to applications
running typic al workloads, and relatively minor hits (approximately
2%) even for extremely syscall-heavy applications. This is largely
due to the small number of indirect branches that occur in
performance sensitive paths of the kernel.

When using these patches on statically linked applications,
especially C++ applications, you should expect to see a much more
dramatic performance hit. For microbenchmarks that are switch,
indirect-, or virtual-call heavy we have seen overheads ranging from
10% to 50%.

However, real-world workloads exhibit substantially lower performance
impact. Notably, techniques such as PGO and ThinLTO dramatically
reduce the impact of hot indirect calls (by speculatively promoting
them to direct calls) and allow optimized search trees to be used to
lower switches. If you need to deploy these techniques in C++
applications, we *strongly* recommend that you ensure all hot call
targets are statically linked (avoiding PLT indirection) and use both
PGO and ThinLTO. Well tuned servers using all of these techniques saw
5% - 10% overhead from the use of retpoline.

We will add detailed documentation covering these components in
subsequent patches, but wanted to make the core functionality
available as soon as possible. Happy for more code review, but we'd
really like to get these patches landed and backported ASAP for
obvious reasons. We're planning to backport this to both 6.0 and 5.0
release streams and get a 5.0 release with just this cherry picked
ASAP for distros and vendors.

This patch is the work of a number of people over the past month:
Eric, Reid, Rui, and myself. I'm mailing it out as a single commit
due to the time sensitive nature of landing this and the need to
backport it. Huge thanks to everyone who helped out here, and
everyone at Intel who helped out in discussions about how to craft
this. Also, credit goes to Paul Turner (at Google, but not an LLVM
contributor) for much of the underlying retpoline design.

Reviewers: echristo, rnk, ruiu, craig.topper, DavidKreitzer

Subscribers: sanjoy, emaste, mcrosier, mgorny, mehdi_amini, hiraditya, llvm-commits

Differential Revision: https://reviews.llvm.org/D41723

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 842d113b 01-Feb-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r323948).

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 042b1c2e 24-Jan-2018 Dimitry Andric <dim@FreeBSD.org>

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
6.0.0 (branches/release_60 r323338).

MFC after: 3 months
X-MFC-With: r327952
PR: 224669


# 30785c0e 06-Jan-2018 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_60 r321788,
update build glue and version numbers.


# fe4fed2e 28-Dec-2017 Dimitry Andric <dim@FreeBSD.org>

Merge llvm, clang, lld, lldb, compiler-rt and libc++ trunk r321545,
update build glue and version numbers, add new intrinsics headers, and
update OptionalObsoleteFiles.inc.


# 2757ff7e 23-Dec-2017 Dimitry Andric <dim@FreeBSD.org>

Update clang, lld and llvm version numbers for r321414, and update build
glue.

# 02d2ad99 20-Dec-2017 Dimitry Andric <dim@FreeBSD.org>

Update generated config headers, and version numbers.

# f9a66922 21-Jan-2021 Glen Barber <gjb@FreeBSD.org>

fix incorrect LLD_VERSION_STRING from previous commit

Reported by: Oliver Pinter
Sponsored by: Rubicon Communications, LLC ("Netgate")


# a53ce3fc 21-Jan-2021 Glen Barber <gjb@FreeBSD.org>

Bump CURRENT to 14.0

This one goes to 14.

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC ("Netgate")


# 5f24ef21 06-Aug-2020 Dimitry Andric <dim@FreeBSD.org>

Update generated llvm-project related version headers, config.h files
and add a newly generated lldb Plugins.def file too.


# 0b37c159 25-Jan-2020 Dimitry Andric <dim@FreeBSD.org>

* Bump version numbers to 10.0.0
* Update UPDATING
* Update (Optional)ObsoleteFiles.inc
* Update VCS(Revision|Version) files
* Update generated config headers
* Update clang internal headers Makefile


# fb3a446a 06-Sep-2019 Dimitry Andric <dim@FreeBSD.org>

Add a VCSVersion.inc header with revision and repository defines,
similar to what upstream generates via CMake. Though for us it is
handier to have everything in one file.


# 86aa9539 23-Aug-2019 Dimitry Andric <dim@FreeBSD.org>

Regenerate config and version headers.


# c3e6b9d3 20-Mar-2019 Dimitry Andric <dim@FreeBSD.org>

Pull in r352826 from upstream lld trunk (by Fangrui Song):

[ELF] Support --{,no-}allow-shlib-undefined

Summary:
In ld.bfd/gold, --no-allow-shlib-undefined is the default when
linking an executable. This patch implements a check to error on
undefined symbols in a shared object, if all of its DT_NEEDED entries
are seen.

Our approach resembles the one used in gold, achieves a good balance
to be useful but not too smart (ld.bfd traces all DSOs and emulates
the behavior of a dynamic linker to catch more cases).

The error is issued based on the symbol table, different from
undefined reference errors issued for relocations. It is most
effective when there are DSOs that were not linked with -z defs (e.g.
when static sanitizers runtime is used).

gold has a comment that some system libraries on GNU/Linux may have
spurious undefined references and thus system libraries should be
excluded (https://sourceware.org/bugzilla/show_bug.cgi?id=6811). The
story may have changed now but we make --allow-shlib-undefined the
default for now. Its interaction with -shared can be discussed in the
future.

Reviewers: ruiu, grimar, pcc, espindola

Reviewed By: ruiu

Subscribers: joerg, emaste, arichardson, llvm-commits

Differential Revision: https://reviews.llvm.org/D57385

Pull in r352943 from upstream lld trunk (by Fangrui Song):

[ELF] Default to --no-allow-shlib-undefined for executables

Summary:
This follows the ld.bfd/gold behavior.

The error check is useful as it captures a common type of ld.so
undefined symbol errors as link-time errors:

// a.cc => a.so (not linked with -z defs)
void f(); // f is undefined
void g() { f(); }

// b.cc => executable with a DT_NEEDED entry on a.so
void g();
int main() { g(); }

// ld.so errors when g() is executed (lazy binding) or when the program is started (-z now)
// symbol lookup error: ... undefined symbol: f

Reviewers: ruiu, grimar, pcc, espindola

Reviewed By: ruiu

Subscribers: llvm-commits, emaste, arichardson

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D57569

Together, these add support for --no-allow-shlib-undefined, and make it
the default for executables, so they will fail to link if any symbols
from needed shared libraries are undefined.

Reported by: jbeich
PR: 236062, 236141
MFC after: 1 month
X-MFC-With: r344779


# af44a011 22-Jan-2019 Dimitry Andric <dim@FreeBSD.org>

Now for the release_80 branch, update version numbers for llvm, clang
and lld, and regenerate config headers.


# 0bf31f1f 20-Jan-2019 Dimitry Andric <dim@FreeBSD.org>

Update version numbers, and regenerate config headers for llvm, clang,
lld and lldb. Update ObsoleteFiles.inc and OptionalObsoleteFiles.inc.


# b0bffd12 20-Oct-2018 Ed Maste <emaste@FreeBSD.org>

Bump LLD_REVISION_STRING for 13-CURRENT


# b371a9f0 11-Oct-2018 Ed Maste <emaste@FreeBSD.org>

lld: set sh_link and sh_info for .rela.plt sections

ELF spec says that for SHT_REL and SHT_RELA sh_link should reference the
associated string table and sh_info should reference the "section to
which the relocation applies." ELF Tool Chain's elfcopy / strip use
this (in part) to control whether or not the relocation entry is copied
to the output.

LLVM PR 37538 https://bugs.llvm.org/show_bug.cgi?id=37538

Approved by: re (kib)
Obtained from: llvm r344226 (backported for 6.0)


# 84ba35dc 04-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Bump clang and lld upstream revision numbers.


# 0fecf001 02-Aug-2018 Dimitry Andric <dim@FreeBSD.org>

Bump revisions to r338536, and also bump lld version again.


# 837f3385 31-Jul-2018 Ed Maste <emaste@FreeBSD.org>

bump lld version number after r336972 arm(v7) VFP tag support

Reported by: kevans
Sponsored by: The FreeBSD Foundation


# 6dfa117f 31-Jul-2018 Dimitry Andric <dim@FreeBSD.org>

Update llvm/clang version numbers in various files.


# fbfca78e 30-Jun-2018 Dimitry Andric <dim@FreeBSD.org>

Follow-up to r335799 (llvm/clang 6.0.1 update), by regenerating various
headers with new version information defines.

MFC after: 2 weeks
X-MFC-With: r335799


# 19703503 09-May-2018 Ed Maste <emaste@FreeBSD.org>

lld: Omit PT_NOTE for SHT_NOTE without SHF_ALLOC

A non-alloc note section should not have a PT_NOTE program header.

Found while linking ghc (Haskell compiler) with lld on FreeBSD. Haskell
emits a .debug-ghc-link-info note section (as the name suggests, it
contains link info) as a SHT_NOTE section without SHF_ALLOC set.

For this case ld.bfd does not emit a PT_NOTE segment for
.debug-ghc-link-info. lld previously emitted a PT_NOTE with p_vaddr = 0
and FreeBSD's rtld segfaulted when trying to parse a note at address 0.

LLVM PR: https://llvm.org/pr37361
LLVM review: https://reviews.llvm.org/D46623

PR: 226872
Reviewed by: dim
Sponsored by: The FreeBSD Foundation


# 08730804 19-Apr-2018 Ed Maste <emaste@FreeBSD.org>

lld: use correct number of digits in __FreeBSD_version-style ID

__FreeBSD_version-style IDs should have 5 digits following the major.


# 12881601 17-Apr-2018 Ed Maste <emaste@FreeBSD.org>

lld: add a __FreeBSD_version-style identifier to version

This will faciliate a WITH_SYSTEM_LINKER option.

Reviewed by: dim
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D15110


# 2757ff7e 23-Dec-2017 Dimitry Andric <dim@FreeBSD.org>

Update clang, lld and llvm version numbers for r321414, and update build
glue.


# 02d2ad99 20-Dec-2017 Dimitry Andric <dim@FreeBSD.org>

Update generated config headers, and version numbers.