git: 1d6829066557 - stable/12 - Reapply r362235 (by kp):

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Wed, 22 Dec 2021 10:05:47 UTC
The branch stable/12 has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=1d6829066557a673a8fe85ad2f91c024d3a014f4

commit 1d6829066557a673a8fe85ad2f91c024d3a014f4
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2020-08-06 19:24:17 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2021-12-22 09:58:23 +0000

    Reapply r362235 (by kp):
    
    llvm: Default to -mno-relax on RISC-V
    
    Compiling on a RISC-V system fails with 'relocation R_RISCV_ALIGN
    requires unimplemented linker relaxation; recompile with -mno-relax'.
    
    Our default linker (ld.lld) doesn't support relaxation, so default to
    no-relax so we don't generate object files the linker can't handle.
    
    Reviewed by:    mhorne
    Sponsored by:   Axiado
    Differential Revision:  https://reviews.freebsd.org/D25210
    
    (cherry picked from commit 82343267e32c24c6c577bc9cdae394d84c623507)
---
 contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/RISCV.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/RISCV.cpp b/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index be3f0a07b576..b1ddd3d83909 100644
--- a/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -536,8 +536,9 @@ void riscv::getRISCVTargetFeatures(const Driver &D, const llvm::Triple &Triple,
   if (Args.hasArg(options::OPT_ffixed_x31))
     Features.push_back("+reserve-x31");
 
-  // -mrelax is default, unless -mno-relax is specified.
-  if (Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax, true))
+  // FreeBSD local, because ld.lld doesn't support relaxations
+  // -mno-relax is default, unless -mrelax is specified.
+  if (Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax, false))
     Features.push_back("+relax");
   else
     Features.push_back("-relax");