git: c80674ff65c5 - stable/13 - Merge llvm-project release/18.x llvmorg-18.1.0-rc2-53-gc7b0a6ecd442
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 20 Apr 2024 10:34:39 UTC
The branch stable/13 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=c80674ff65c5ff9f2a844e4ed6fe7e5f935f6e4c commit c80674ff65c5ff9f2a844e4ed6fe7e5f935f6e4c Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2024-02-20 18:57:23 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2024-04-19 21:24:47 +0000 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 (cherry picked from commit 74626c16ff489c0d64cf2843dfd522e7c544f3ce) --- .../clang/include/clang/Basic/arm_sme.td | 28 +- .../clang/include/clang/Driver/Options.td | 12 + .../clang/lib/Basic/Targets/AArch64.cpp | 9 +- .../clang/lib/Driver/ToolChains/Arch/Sparc.cpp | 81 +++ .../clang/lib/Format/UnwrappedLineParser.cpp | 2 +- contrib/llvm-project/clang/lib/Sema/SemaExpr.cpp | 2 +- .../clang/tools/clang-format/ClangFormat.cpp | 49 +- .../compiler-rt/lib/dfsan/dfsan_custom.cpp | 203 ++----- .../compiler-rt/lib/dfsan/done_abilist.txt | 6 + .../lib/dfsan/libc_ubuntu1404_abilist.txt | 5 + .../lib/profile/InstrProfilingPlatformAIX.c | 4 +- contrib/llvm-project/libcxx/include/print | 14 +- .../llvm-project/libcxx/modules/CMakeLists.txt.in | 88 +++ .../llvm-project/libcxx/modules/std/ostream.inc | 4 +- contrib/llvm-project/libcxx/src/print.cpp | 25 +- contrib/llvm-project/lld/COFF/Driver.cpp | 10 +- contrib/llvm-project/lld/ELF/Arch/LoongArch.cpp | 156 +++++- contrib/llvm-project/lld/ELF/Arch/RISCV.cpp | 29 +- contrib/llvm-project/lld/ELF/Arch/SystemZ.cpp | 607 +++++++++++++++++++++ contrib/llvm-project/lld/ELF/Driver.cpp | 3 +- contrib/llvm-project/lld/ELF/InputFiles.cpp | 2 + contrib/llvm-project/lld/ELF/InputSection.cpp | 14 +- contrib/llvm-project/lld/ELF/InputSection.h | 24 +- contrib/llvm-project/lld/ELF/Relocations.cpp | 27 +- contrib/llvm-project/lld/ELF/Relocations.h | 3 + contrib/llvm-project/lld/ELF/ScriptParser.cpp | 1 + contrib/llvm-project/lld/ELF/SyntheticSections.cpp | 3 + contrib/llvm-project/lld/ELF/Target.cpp | 2 + contrib/llvm-project/lld/ELF/Target.h | 4 + contrib/llvm-project/lld/ELF/Writer.cpp | 4 +- contrib/llvm-project/lld/docs/ReleaseNotes.rst | 53 +- .../llvm/include/llvm/BinaryFormat/ELF.h | 1 + .../llvm/lib/Analysis/ValueTracking.cpp | 7 +- .../lib/CodeGen/GlobalISel/LegalizerHelper.cpp | 2 + .../llvm/lib/CodeGen/RegisterCoalescer.cpp | 27 +- .../llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 2 +- .../lib/Target/AArch64/AArch64ISelLowering.cpp | 11 +- .../lib/Target/AArch64/AArch64RegisterInfo.cpp | 4 + .../Target/AArch64/GISel/AArch64LegalizerInfo.cpp | 5 +- .../lib/Target/Mips/AsmParser/MipsAsmParser.cpp | 7 +- .../llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 98 ++-- .../llvm/lib/Target/RISCV/RISCVInstrInfo.cpp | 3 +- .../llvm-project/llvm/lib/Target/Sparc/Sparc.td | 14 + .../llvm/lib/Target/Sparc/SparcISelLowering.cpp | 43 ++ .../llvm/lib/Target/Sparc/SparcRegisterInfo.cpp | 14 +- .../llvm/lib/Target/Sparc/SparcRegisterInfo.h | 1 + .../llvm/lib/Target/Sparc/SparcRegisterInfo.td | 4 + .../llvm/lib/Target/Sparc/SparcSubtarget.cpp | 1 + .../llvm/lib/Target/Sparc/SparcSubtarget.h | 10 + .../llvm/lib/Target/X86/X86ISelLowering.cpp | 10 +- .../llvm/lib/Transforms/IPO/LowerTypeTests.cpp | 28 +- .../lib/Transforms/Vectorize/SLPVectorizer.cpp | 14 +- contrib/llvm-project/openmp/runtime/src/kmp.h | 7 +- .../openmp/runtime/src/kmp_csupport.cpp | 5 +- .../openmp/runtime/src/kmp_gsupport.cpp | 2 +- .../llvm-project/openmp/runtime/src/kmp_lock.cpp | 6 +- contrib/llvm-project/openmp/runtime/src/kmp_lock.h | 17 +- .../openmp/runtime/src/kmp_settings.cpp | 5 + lib/clang/include/VCSVersion.inc | 6 +- lib/clang/include/lld/Common/Version.inc | 2 +- lib/clang/include/llvm/Support/VCSRevision.h | 2 +- usr.bin/clang/lld/Makefile | 1 + 62 files changed, 1481 insertions(+), 352 deletions(-) diff --git a/contrib/llvm-project/clang/include/clang/Basic/arm_sme.td b/contrib/llvm-project/clang/include/clang/Basic/arm_sme.td index 695e1bddf9ff..2da0e8d2aba9 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/arm_sme.td +++ b/contrib/llvm-project/clang/include/clang/Basic/arm_sme.td @@ -44,6 +44,7 @@ defm SVLD1_ZA32 : ZALoad<"za32", "i", "aarch64_sme_ld1w", [ImmCheck<0, ImmCheck0 defm SVLD1_ZA64 : ZALoad<"za64", "l", "aarch64_sme_ld1d", [ImmCheck<0, ImmCheck0_7>]>; defm SVLD1_ZA128 : ZALoad<"za128", "q", "aarch64_sme_ld1q", [ImmCheck<0, ImmCheck0_15>]>; +let TargetGuard = "sme" in { def SVLDR_VNUM_ZA : MInst<"svldr_vnum_za", "vmQl", "", [IsOverloadNone, IsStreamingCompatible, IsInOutZA], MemEltTyDefault, "aarch64_sme_ldr">; @@ -51,6 +52,7 @@ def SVLDR_VNUM_ZA : MInst<"svldr_vnum_za", "vmQl", "", def SVLDR_ZA : MInst<"svldr_za", "vmQ", "", [IsOverloadNone, IsStreamingCompatible, IsInOutZA], MemEltTyDefault, "aarch64_sme_ldr", []>; +} //////////////////////////////////////////////////////////////////////////////// // Stores @@ -81,6 +83,7 @@ defm SVST1_ZA32 : ZAStore<"za32", "i", "aarch64_sme_st1w", [ImmCheck<0, ImmCheck defm SVST1_ZA64 : ZAStore<"za64", "l", "aarch64_sme_st1d", [ImmCheck<0, ImmCheck0_7>]>; defm SVST1_ZA128 : ZAStore<"za128", "q", "aarch64_sme_st1q", [ImmCheck<0, ImmCheck0_15>]>; +let TargetGuard = "sme" in { def SVSTR_VNUM_ZA : MInst<"svstr_vnum_za", "vm%l", "", [IsOverloadNone, IsStreamingCompatible, IsInZA], MemEltTyDefault, "aarch64_sme_str">; @@ -88,6 +91,7 @@ def SVSTR_VNUM_ZA : MInst<"svstr_vnum_za", "vm%l", "", def SVSTR_ZA : MInst<"svstr_za", "vm%", "", [IsOverloadNone, IsStreamingCompatible, IsInZA], MemEltTyDefault, "aarch64_sme_str", []>; +} //////////////////////////////////////////////////////////////////////////////// // Read horizontal/vertical ZA slices @@ -277,22 +281,22 @@ multiclass ZAAddSub<string n_suffix> { def NAME # _ZA32_VG1x2_I32 : Inst<"sv" # n_suffix # "_za32[_{d}]_vg1x2", "vm2", "iUif", MergeNone, "aarch64_sme_" # n_suffix # "_za32_vg1x2", [IsStreaming, IsInOutZA], []>; def NAME # _ZA32_VG1X4_I32 : Inst<"sv" # n_suffix # "_za32[_{d}]_vg1x4", "vm4", "iUif", MergeNone, "aarch64_sme_" # n_suffix # "_za32_vg1x4", [IsStreaming, IsInOutZA], []>; + } - let TargetGuard = "sme-i16i64" in { - def NAME # _WRITE_SINGLE_ZA64_VG1X2_I64 : Inst<"sv" # n_suffix # "_write[_single]_za64[_{d}]_vg1x2", "vm2d", "lUl", MergeNone, "aarch64_sme_" # n_suffix # "_write_single_za_vg1x2", [IsStreaming, IsInOutZA], []>; - def NAME # _WRITE_SINGLE_ZA64_VG1X4_I64 : Inst<"sv" # n_suffix # "_write[_single]_za64[_{d}]_vg1x4", "vm4d", "lUl", MergeNone, "aarch64_sme_" # n_suffix # "_write_single_za_vg1x4", [IsStreaming, IsInOutZA], []>; + let TargetGuard = "sme2,sme-i16i64" in { + def NAME # _WRITE_SINGLE_ZA64_VG1X2_I64 : Inst<"sv" # n_suffix # "_write[_single]_za64[_{d}]_vg1x2", "vm2d", "lUl", MergeNone, "aarch64_sme_" # n_suffix # "_write_single_za_vg1x2", [IsStreaming, IsInOutZA], []>; + def NAME # _WRITE_SINGLE_ZA64_VG1X4_I64 : Inst<"sv" # n_suffix # "_write[_single]_za64[_{d}]_vg1x4", "vm4d", "lUl", MergeNone, "aarch64_sme_" # n_suffix # "_write_single_za_vg1x4", [IsStreaming, IsInOutZA], []>; - def NAME # _WRITE_ZA64_VG1x2_I64 : Inst<"sv" # n_suffix # "_write_za64[_{d}]_vg1x2", "vm22", "lUl", MergeNone, "aarch64_sme_" # n_suffix # "_write_za_vg1x2", [IsStreaming, IsInOutZA], []>; - def NAME # _WRITE_ZA64_VG1x4_I64 : Inst<"sv" # n_suffix # "_write_za64[_{d}]_vg1x4", "vm44", "lUl", MergeNone, "aarch64_sme_" # n_suffix # "_write_za_vg1x4", [IsStreaming, IsInOutZA], []>; + def NAME # _WRITE_ZA64_VG1x2_I64 : Inst<"sv" # n_suffix # "_write_za64[_{d}]_vg1x2", "vm22", "lUl", MergeNone, "aarch64_sme_" # n_suffix # "_write_za_vg1x2", [IsStreaming, IsInOutZA], []>; + def NAME # _WRITE_ZA64_VG1x4_I64 : Inst<"sv" # n_suffix # "_write_za64[_{d}]_vg1x4", "vm44", "lUl", MergeNone, "aarch64_sme_" # n_suffix # "_write_za_vg1x4", [IsStreaming, IsInOutZA], []>; - def NAME # _ZA64_VG1X2_I64 : Inst<"sv" # n_suffix # "_za64[_{d}]_vg1x2", "vm2", "lUl", MergeNone, "aarch64_sme_" # n_suffix # "_za64_vg1x2", [IsStreaming, IsInOutZA], []>; - def NAME # _ZA64_VG1X4_I64 : Inst<"sv" # n_suffix # "_za64[_{d}]_vg1x4", "vm4", "lUl", MergeNone, "aarch64_sme_" # n_suffix # "_za64_vg1x4", [IsStreaming, IsInOutZA], []>; - } + def NAME # _ZA64_VG1X2_I64 : Inst<"sv" # n_suffix # "_za64[_{d}]_vg1x2", "vm2", "lUl", MergeNone, "aarch64_sme_" # n_suffix # "_za64_vg1x2", [IsStreaming, IsInOutZA], []>; + def NAME # _ZA64_VG1X4_I64 : Inst<"sv" # n_suffix # "_za64[_{d}]_vg1x4", "vm4", "lUl", MergeNone, "aarch64_sme_" # n_suffix # "_za64_vg1x4", [IsStreaming, IsInOutZA], []>; + } - let TargetGuard = "sme-f64f64" in { - def NAME # _ZA64_VG1X2_F64 : Inst<"sv" # n_suffix # "_za64[_{d}]_vg1x2", "vm2", "d", MergeNone, "aarch64_sme_" # n_suffix # "_za64_vg1x2", [IsStreaming, IsInOutZA], []>; - def NAME # _ZA64_VG1X4_F64 : Inst<"sv" # n_suffix # "_za64[_{d}]_vg1x4", "vm4", "d", MergeNone, "aarch64_sme_" # n_suffix # "_za64_vg1x4", [IsStreaming, IsInOutZA], []>; - } + let TargetGuard = "sme2,sme-f64f64" in { + def NAME # _ZA64_VG1X2_F64 : Inst<"sv" # n_suffix # "_za64[_{d}]_vg1x2", "vm2", "d", MergeNone, "aarch64_sme_" # n_suffix # "_za64_vg1x2", [IsStreaming, IsInOutZA], []>; + def NAME # _ZA64_VG1X4_F64 : Inst<"sv" # n_suffix # "_za64[_{d}]_vg1x4", "vm4", "d", MergeNone, "aarch64_sme_" # n_suffix # "_za64_vg1x4", [IsStreaming, IsInOutZA], []>; } } diff --git a/contrib/llvm-project/clang/include/clang/Driver/Options.td b/contrib/llvm-project/clang/include/clang/Driver/Options.td index e8d03fc26902..175bedbfb4d0 100644 --- a/contrib/llvm-project/clang/include/clang/Driver/Options.td +++ b/contrib/llvm-project/clang/include/clang/Driver/Options.td @@ -5815,6 +5815,18 @@ def mvis3 : Flag<["-"], "mvis3">, Group<m_sparc_Features_Group>; def mno_vis3 : Flag<["-"], "mno-vis3">, Group<m_sparc_Features_Group>; def mhard_quad_float : Flag<["-"], "mhard-quad-float">, Group<m_sparc_Features_Group>; def msoft_quad_float : Flag<["-"], "msoft-quad-float">, Group<m_sparc_Features_Group>; +foreach i = 1 ... 7 in + def ffixed_g#i : Flag<["-"], "ffixed-g"#i>, Group<m_sparc_Features_Group>, + HelpText<"Reserve the G"#i#" register (SPARC only)">; +foreach i = 0 ... 5 in + def ffixed_o#i : Flag<["-"], "ffixed-o"#i>, Group<m_sparc_Features_Group>, + HelpText<"Reserve the O"#i#" register (SPARC only)">; +foreach i = 0 ... 7 in + def ffixed_l#i : Flag<["-"], "ffixed-l"#i>, Group<m_sparc_Features_Group>, + HelpText<"Reserve the L"#i#" register (SPARC only)">; +foreach i = 0 ... 5 in + def ffixed_i#i : Flag<["-"], "ffixed-i"#i>, Group<m_sparc_Features_Group>, + HelpText<"Reserve the I"#i#" register (SPARC only)">; } // let Flags = [TargetSpecific] // M68k features flags diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/AArch64.cpp b/contrib/llvm-project/clang/lib/Basic/Targets/AArch64.cpp index 336b7a5e3d72..3036f461c1de 100644 --- a/contrib/llvm-project/clang/lib/Basic/Targets/AArch64.cpp +++ b/contrib/llvm-project/clang/lib/Basic/Targets/AArch64.cpp @@ -1187,6 +1187,8 @@ TargetInfo::BuiltinVaListKind AArch64TargetInfo::getBuiltinVaListKind() const { } const char *const AArch64TargetInfo::GCCRegNames[] = { + // clang-format off + // 32-bit Integer registers "w0", "w1", "w2", "w3", "w4", "w5", "w6", "w7", "w8", "w9", "w10", "w11", "w12", "w13", "w14", "w15", "w16", "w17", "w18", "w19", "w20", "w21", "w22", @@ -1223,7 +1225,12 @@ const char *const AArch64TargetInfo::GCCRegNames[] = { // SVE predicate-as-counter registers "pn0", "pn1", "pn2", "pn3", "pn4", "pn5", "pn6", "pn7", "pn8", - "pn9", "pn10", "pn11", "pn12", "pn13", "pn14", "pn15" + "pn9", "pn10", "pn11", "pn12", "pn13", "pn14", "pn15", + + // SME registers + "za", "zt0", + + // clang-format on }; ArrayRef<const char *> AArch64TargetInfo::getGCCRegNames() const { diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/Sparc.cpp b/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/Sparc.cpp index 22e583021515..ae1a4ba78826 100644 --- a/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/Sparc.cpp +++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/Sparc.cpp @@ -178,4 +178,85 @@ void sparc::getSparcTargetFeatures(const Driver &D, const ArgList &Args, else Features.push_back("-hard-quad-float"); } + + if (Args.hasArg(options::OPT_ffixed_g1)) + Features.push_back("+reserve-g1"); + + if (Args.hasArg(options::OPT_ffixed_g2)) + Features.push_back("+reserve-g2"); + + if (Args.hasArg(options::OPT_ffixed_g3)) + Features.push_back("+reserve-g3"); + + if (Args.hasArg(options::OPT_ffixed_g4)) + Features.push_back("+reserve-g4"); + + if (Args.hasArg(options::OPT_ffixed_g5)) + Features.push_back("+reserve-g5"); + + if (Args.hasArg(options::OPT_ffixed_g6)) + Features.push_back("+reserve-g6"); + + if (Args.hasArg(options::OPT_ffixed_g7)) + Features.push_back("+reserve-g7"); + + if (Args.hasArg(options::OPT_ffixed_o0)) + Features.push_back("+reserve-o0"); + + if (Args.hasArg(options::OPT_ffixed_o1)) + Features.push_back("+reserve-o1"); + + if (Args.hasArg(options::OPT_ffixed_o2)) + Features.push_back("+reserve-o2"); + + if (Args.hasArg(options::OPT_ffixed_o3)) + Features.push_back("+reserve-o3"); + + if (Args.hasArg(options::OPT_ffixed_o4)) + Features.push_back("+reserve-o4"); + + if (Args.hasArg(options::OPT_ffixed_o5)) + Features.push_back("+reserve-o5"); + + if (Args.hasArg(options::OPT_ffixed_l0)) + Features.push_back("+reserve-l0"); + + if (Args.hasArg(options::OPT_ffixed_l1)) + Features.push_back("+reserve-l1"); + + if (Args.hasArg(options::OPT_ffixed_l2)) + Features.push_back("+reserve-l2"); + + if (Args.hasArg(options::OPT_ffixed_l3)) + Features.push_back("+reserve-l3"); + + if (Args.hasArg(options::OPT_ffixed_l4)) + Features.push_back("+reserve-l4"); + + if (Args.hasArg(options::OPT_ffixed_l5)) + Features.push_back("+reserve-l5"); + + if (Args.hasArg(options::OPT_ffixed_l6)) + Features.push_back("+reserve-l6"); + + if (Args.hasArg(options::OPT_ffixed_l7)) + Features.push_back("+reserve-l7"); + + if (Args.hasArg(options::OPT_ffixed_i0)) + Features.push_back("+reserve-i0"); + + if (Args.hasArg(options::OPT_ffixed_i1)) + Features.push_back("+reserve-i1"); + + if (Args.hasArg(options::OPT_ffixed_i2)) + Features.push_back("+reserve-i2"); + + if (Args.hasArg(options::OPT_ffixed_i3)) + Features.push_back("+reserve-i3"); + + if (Args.hasArg(options::OPT_ffixed_i4)) + Features.push_back("+reserve-i4"); + + if (Args.hasArg(options::OPT_ffixed_i5)) + Features.push_back("+reserve-i5"); } diff --git a/contrib/llvm-project/clang/lib/Format/UnwrappedLineParser.cpp b/contrib/llvm-project/clang/lib/Format/UnwrappedLineParser.cpp index b904e0e56d9e..573919798870 100644 --- a/contrib/llvm-project/clang/lib/Format/UnwrappedLineParser.cpp +++ b/contrib/llvm-project/clang/lib/Format/UnwrappedLineParser.cpp @@ -2515,7 +2515,7 @@ bool UnwrappedLineParser::parseParens(TokenType AmpAmpTokenType) { parseChildBlock(); break; case tok::r_paren: - if (!MightBeStmtExpr && + if (!MightBeStmtExpr && !Line->InMacroBody && Style.RemoveParentheses > FormatStyle::RPS_Leave) { const auto *Prev = LeftParen->Previous; const auto *Next = Tokens->peekNextToken(); diff --git a/contrib/llvm-project/clang/lib/Sema/SemaExpr.cpp b/contrib/llvm-project/clang/lib/Sema/SemaExpr.cpp index 4efcb3590355..0d9c087ed0cd 100644 --- a/contrib/llvm-project/clang/lib/Sema/SemaExpr.cpp +++ b/contrib/llvm-project/clang/lib/Sema/SemaExpr.cpp @@ -14062,7 +14062,7 @@ inline QualType Sema::CheckLogicalOperands(ExprResult &LHS, ExprResult &RHS, Expr::EvalResult EVResult; if (RHS.get()->EvaluateAsInt(EVResult, Context)) { llvm::APSInt Result = EVResult.Val.getInt(); - if ((getLangOpts().Bool && !RHS.get()->getType()->isBooleanType() && + if ((getLangOpts().CPlusPlus && !RHS.get()->getType()->isBooleanType() && !RHS.get()->getExprLoc().isMacroID()) || (Result != 0 && Result != 1)) { Diag(Loc, diag::warn_logical_instead_of_bitwise) diff --git a/contrib/llvm-project/clang/tools/clang-format/ClangFormat.cpp b/contrib/llvm-project/clang/tools/clang-format/ClangFormat.cpp index 5ee6092bb9bb..e122cea50f72 100644 --- a/contrib/llvm-project/clang/tools/clang-format/ClangFormat.cpp +++ b/contrib/llvm-project/clang/tools/clang-format/ClangFormat.cpp @@ -399,7 +399,8 @@ class ClangFormatDiagConsumer : public DiagnosticConsumer { }; // Returns true on error. -static bool format(StringRef FileName, bool IsSTDIN) { +static bool format(StringRef FileName) { + const bool IsSTDIN = FileName == "-"; if (!OutputXML && Inplace && IsSTDIN) { errs() << "error: cannot use -i when reading from stdin.\n"; return false; @@ -545,24 +546,25 @@ static void PrintVersion(raw_ostream &OS) { } // Dump the configuration. -static int dumpConfig(bool IsSTDIN) { +static int dumpConfig() { std::unique_ptr<llvm::MemoryBuffer> Code; - - // `FileNames` must have at least "-" in it even if no file was specified. - assert(!FileNames.empty()); - - // Read in the code in case the filename alone isn't enough to detect the - // language. - ErrorOr<std::unique_ptr<MemoryBuffer>> CodeOrErr = - MemoryBuffer::getFileOrSTDIN(FileNames[0]); - if (std::error_code EC = CodeOrErr.getError()) { - llvm::errs() << EC.message() << "\n"; - return 1; + // We can't read the code to detect the language if there's no file name. + if (!FileNames.empty()) { + // Read in the code in case the filename alone isn't enough to detect the + // language. + ErrorOr<std::unique_ptr<MemoryBuffer>> CodeOrErr = + MemoryBuffer::getFileOrSTDIN(FileNames[0]); + if (std::error_code EC = CodeOrErr.getError()) { + llvm::errs() << EC.message() << "\n"; + return 1; + } + Code = std::move(CodeOrErr.get()); } - Code = std::move(CodeOrErr.get()); - llvm::Expected<clang::format::FormatStyle> FormatStyle = - clang::format::getStyle(Style, IsSTDIN ? AssumeFileName : FileNames[0], + clang::format::getStyle(Style, + FileNames.empty() || FileNames[0] == "-" + ? AssumeFileName + : FileNames[0], FallbackStyle, Code ? Code->getBuffer() : ""); if (!FormatStyle) { llvm::errs() << llvm::toString(FormatStyle.takeError()) << "\n"; @@ -682,11 +684,8 @@ int main(int argc, const char **argv) { return 0; } - if (FileNames.empty()) - FileNames.push_back("-"); - if (DumpConfig) - return dumpConfig(FileNames[0] == "-"); + return dumpConfig(); if (!Files.empty()) { std::ifstream ExternalFileOfFiles{std::string(Files)}; @@ -699,7 +698,10 @@ int main(int argc, const char **argv) { errs() << "Clang-formating " << LineNo << " files\n"; } - if (FileNames.size() != 1 && + if (FileNames.empty()) + return clang::format::format("-"); + + if (FileNames.size() > 1 && (!Offsets.empty() || !Lengths.empty() || !LineRanges.empty())) { errs() << "error: -offset, -length and -lines can only be used for " "single file.\n"; @@ -709,14 +711,13 @@ int main(int argc, const char **argv) { unsigned FileNo = 1; bool Error = false; for (const auto &FileName : FileNames) { - const bool IsSTDIN = FileName == "-"; - if (!IsSTDIN && isIgnored(FileName)) + if (isIgnored(FileName)) continue; if (Verbose) { errs() << "Formatting [" << FileNo++ << "/" << FileNames.size() << "] " << FileName << "\n"; } - Error |= clang::format::format(FileName, IsSTDIN); + Error |= clang::format::format(FileName); } return Error ? 1 : 0; } diff --git a/contrib/llvm-project/compiler-rt/lib/dfsan/dfsan_custom.cpp b/contrib/llvm-project/compiler-rt/lib/dfsan/dfsan_custom.cpp index 85b796bd6349..3af26e9f64c9 100644 --- a/contrib/llvm-project/compiler-rt/lib/dfsan/dfsan_custom.cpp +++ b/contrib/llvm-project/compiler-rt/lib/dfsan/dfsan_custom.cpp @@ -55,6 +55,10 @@ using namespace __dfsan; #define DECLARE_WEAK_INTERCEPTOR_HOOK(f, ...) \ SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void f(__VA_ARGS__); +#define WRAPPER_ALIAS(fun, real) \ + SANITIZER_INTERFACE_ATTRIBUTE void __dfsw_##fun() ALIAS(__dfsw_##real); \ + SANITIZER_INTERFACE_ATTRIBUTE void __dfso_##fun() ALIAS(__dfso_##real); + // Async-safe, non-reentrant spin lock. class SignalSpinLocker { public: @@ -1197,16 +1201,20 @@ char *__dfso_strcpy(char *dest, const char *src, dfsan_label dst_label, *ret_origin = dst_origin; return ret; } +} -static long int dfsan_strtol(const char *nptr, char **endptr, int base, - char **tmp_endptr) { +template <typename Fn> +static ALWAYS_INLINE auto dfsan_strtol_impl( + Fn real, const char *nptr, char **endptr, int base, + char **tmp_endptr) -> decltype(real(nullptr, nullptr, 0)) { assert(tmp_endptr); - long int ret = strtol(nptr, tmp_endptr, base); + auto ret = real(nptr, tmp_endptr, base); if (endptr) *endptr = *tmp_endptr; return ret; } +extern "C" { static void dfsan_strtolong_label(const char *nptr, const char *tmp_endptr, dfsan_label base_label, dfsan_label *ret_label) { @@ -1236,30 +1244,6 @@ static void dfsan_strtolong_origin(const char *nptr, const char *tmp_endptr, } } -SANITIZER_INTERFACE_ATTRIBUTE -long int __dfsw_strtol(const char *nptr, char **endptr, int base, - dfsan_label nptr_label, dfsan_label endptr_label, - dfsan_label base_label, dfsan_label *ret_label) { - char *tmp_endptr; - long int ret = dfsan_strtol(nptr, endptr, base, &tmp_endptr); - dfsan_strtolong_label(nptr, tmp_endptr, base_label, ret_label); - return ret; -} - -SANITIZER_INTERFACE_ATTRIBUTE -long int __dfso_strtol(const char *nptr, char **endptr, int base, - dfsan_label nptr_label, dfsan_label endptr_label, - dfsan_label base_label, dfsan_label *ret_label, - dfsan_origin nptr_origin, dfsan_origin endptr_origin, - dfsan_origin base_origin, dfsan_origin *ret_origin) { - char *tmp_endptr; - long int ret = dfsan_strtol(nptr, endptr, base, &tmp_endptr); - dfsan_strtolong_label(nptr, tmp_endptr, base_label, ret_label); - dfsan_strtolong_origin(nptr, tmp_endptr, base_label, ret_label, base_origin, - ret_origin); - return ret; -} - static double dfsan_strtod(const char *nptr, char **endptr, char **tmp_endptr) { assert(tmp_endptr); double ret = strtod(nptr, tmp_endptr); @@ -1307,108 +1291,40 @@ double __dfso_strtod(const char *nptr, char **endptr, dfsan_label nptr_label, return ret; } -static long long int dfsan_strtoll(const char *nptr, char **endptr, int base, - char **tmp_endptr) { - assert(tmp_endptr); - long long int ret = strtoll(nptr, tmp_endptr, base); - if (endptr) - *endptr = *tmp_endptr; - return ret; -} - -SANITIZER_INTERFACE_ATTRIBUTE -long long int __dfsw_strtoll(const char *nptr, char **endptr, int base, - dfsan_label nptr_label, dfsan_label endptr_label, - dfsan_label base_label, dfsan_label *ret_label) { - char *tmp_endptr; - long long int ret = dfsan_strtoll(nptr, endptr, base, &tmp_endptr); - dfsan_strtolong_label(nptr, tmp_endptr, base_label, ret_label); - return ret; -} - -SANITIZER_INTERFACE_ATTRIBUTE -long long int __dfso_strtoll(const char *nptr, char **endptr, int base, - dfsan_label nptr_label, dfsan_label endptr_label, - dfsan_label base_label, dfsan_label *ret_label, - dfsan_origin nptr_origin, - dfsan_origin endptr_origin, - dfsan_origin base_origin, - dfsan_origin *ret_origin) { - char *tmp_endptr; - long long int ret = dfsan_strtoll(nptr, endptr, base, &tmp_endptr); - dfsan_strtolong_label(nptr, tmp_endptr, base_label, ret_label); - dfsan_strtolong_origin(nptr, tmp_endptr, base_label, ret_label, base_origin, - ret_origin); - return ret; -} - -static unsigned long int dfsan_strtoul(const char *nptr, char **endptr, - int base, char **tmp_endptr) { - assert(tmp_endptr); - unsigned long int ret = strtoul(nptr, tmp_endptr, base); - if (endptr) - *endptr = *tmp_endptr; - return ret; -} - -SANITIZER_INTERFACE_ATTRIBUTE -unsigned long int __dfsw_strtoul(const char *nptr, char **endptr, int base, - dfsan_label nptr_label, dfsan_label endptr_label, - dfsan_label base_label, dfsan_label *ret_label) { - char *tmp_endptr; - unsigned long int ret = dfsan_strtoul(nptr, endptr, base, &tmp_endptr); - dfsan_strtolong_label(nptr, tmp_endptr, base_label, ret_label); - return ret; -} - -SANITIZER_INTERFACE_ATTRIBUTE -unsigned long int __dfso_strtoul( - const char *nptr, char **endptr, int base, dfsan_label nptr_label, - dfsan_label endptr_label, dfsan_label base_label, dfsan_label *ret_label, - dfsan_origin nptr_origin, dfsan_origin endptr_origin, - dfsan_origin base_origin, dfsan_origin *ret_origin) { - char *tmp_endptr; - unsigned long int ret = dfsan_strtoul(nptr, endptr, base, &tmp_endptr); - dfsan_strtolong_label(nptr, tmp_endptr, base_label, ret_label); - dfsan_strtolong_origin(nptr, tmp_endptr, base_label, ret_label, base_origin, - ret_origin); - return ret; -} - -static long long unsigned int dfsan_strtoull(const char *nptr, char **endptr, - int base, char **tmp_endptr) { - assert(tmp_endptr); - long long unsigned int ret = strtoull(nptr, tmp_endptr, base); - if (endptr) - *endptr = *tmp_endptr; - return ret; -} - -SANITIZER_INTERFACE_ATTRIBUTE -long long unsigned int __dfsw_strtoull(const char *nptr, char **endptr, - int base, dfsan_label nptr_label, - dfsan_label endptr_label, - dfsan_label base_label, - dfsan_label *ret_label) { - char *tmp_endptr; - long long unsigned int ret = dfsan_strtoull(nptr, endptr, base, &tmp_endptr); - dfsan_strtolong_label(nptr, tmp_endptr, base_label, ret_label); - return ret; -} - -SANITIZER_INTERFACE_ATTRIBUTE -long long unsigned int __dfso_strtoull( - const char *nptr, char **endptr, int base, dfsan_label nptr_label, - dfsan_label endptr_label, dfsan_label base_label, dfsan_label *ret_label, - dfsan_origin nptr_origin, dfsan_origin endptr_origin, - dfsan_origin base_origin, dfsan_origin *ret_origin) { - char *tmp_endptr; - long long unsigned int ret = dfsan_strtoull(nptr, endptr, base, &tmp_endptr); - dfsan_strtolong_label(nptr, tmp_endptr, base_label, ret_label); - dfsan_strtolong_origin(nptr, tmp_endptr, base_label, ret_label, base_origin, - ret_origin); - return ret; -} +WRAPPER_ALIAS(__isoc23_strtod, strtod) + +#define WRAPPER_STRTO(ret_type, fun) \ + SANITIZER_INTERFACE_ATTRIBUTE ret_type __dfsw_##fun( \ + const char *nptr, char **endptr, int base, dfsan_label nptr_label, \ + dfsan_label endptr_label, dfsan_label base_label, \ + dfsan_label *ret_label) { \ + char *tmp_endptr; \ + auto ret = dfsan_strtol_impl(fun, nptr, endptr, base, &tmp_endptr); \ + dfsan_strtolong_label(nptr, tmp_endptr, base_label, ret_label); \ + return ret; \ + } \ + SANITIZER_INTERFACE_ATTRIBUTE ret_type __dfso_##fun( \ + const char *nptr, char **endptr, int base, dfsan_label nptr_label, \ + dfsan_label endptr_label, dfsan_label base_label, \ + dfsan_label *ret_label, dfsan_origin nptr_origin, \ + dfsan_origin endptr_origin, dfsan_origin base_origin, \ + dfsan_origin *ret_origin) { \ + char *tmp_endptr; \ + auto ret = dfsan_strtol_impl(fun, nptr, endptr, base, &tmp_endptr); \ + dfsan_strtolong_label(nptr, tmp_endptr, base_label, ret_label); \ + dfsan_strtolong_origin(nptr, tmp_endptr, base_label, ret_label, \ + base_origin, ret_origin); \ + return ret; \ + } + +WRAPPER_STRTO(long, strtol) +WRAPPER_STRTO(long long, strtoll) +WRAPPER_STRTO(unsigned long, strtoul) +WRAPPER_STRTO(unsigned long long, strtoull) +WRAPPER_ALIAS(__isoc23_strtol, strtol) +WRAPPER_ALIAS(__isoc23_strtoll, strtoll) +WRAPPER_ALIAS(__isoc23_strtoul, strtoul) +WRAPPER_ALIAS(__isoc23_strtoull, strtoull) SANITIZER_INTERFACE_ATTRIBUTE time_t __dfsw_time(time_t *t, dfsan_label t_label, dfsan_label *ret_label) { @@ -2231,7 +2147,7 @@ SANITIZER_INTERFACE_ATTRIBUTE int __dfso_write( *ret_label = 0; return write(fd, buf, count); } -} // namespace __dfsan +} // namespace __dfsan // Type used to extract a dfsan_label with va_arg() typedef int dfsan_label_va; @@ -2866,31 +2782,8 @@ int __dfso_sscanf(char *str, const char *format, dfsan_label str_label, return ret; } -SANITIZER_INTERFACE_ATTRIBUTE -int __dfsw___isoc99_sscanf(char *str, const char *format, dfsan_label str_label, - dfsan_label format_label, dfsan_label *va_labels, - dfsan_label *ret_label, ...) { - va_list ap; - va_start(ap, ret_label); - int ret = scan_buffer(str, ~0ul, format, va_labels, ret_label, nullptr, - nullptr, ap); - va_end(ap); - return ret; -} - -SANITIZER_INTERFACE_ATTRIBUTE -int __dfso___isoc99_sscanf(char *str, const char *format, dfsan_label str_label, - dfsan_label format_label, dfsan_label *va_labels, - dfsan_label *ret_label, dfsan_origin str_origin, - dfsan_origin format_origin, dfsan_origin *va_origins, - dfsan_origin *ret_origin, ...) { - va_list ap; - va_start(ap, ret_origin); - int ret = scan_buffer(str, ~0ul, format, va_labels, ret_label, &str_origin, - ret_origin, ap); - va_end(ap); - return ret; -} +WRAPPER_ALIAS(__isoc99_sscanf, sscanf) +WRAPPER_ALIAS(__isoc23_sscanf, sscanf) static void BeforeFork() { StackDepotLockBeforeFork(); diff --git a/contrib/llvm-project/compiler-rt/lib/dfsan/done_abilist.txt b/contrib/llvm-project/compiler-rt/lib/dfsan/done_abilist.txt index c582584d77e4..86a42ee1b4dc 100644 --- a/contrib/llvm-project/compiler-rt/lib/dfsan/done_abilist.txt +++ b/contrib/llvm-project/compiler-rt/lib/dfsan/done_abilist.txt @@ -270,6 +270,11 @@ fun:strtoul=custom fun:strtoull=custom fun:strcat=custom fun:strncat=custom +fun:__isoc23_strtod=custom +fun:__isoc23_strtol=custom +fun:__isoc23_strtoll=custom +fun:__isoc23_strtoul=custom +fun:__isoc23_strtoull=custom # Functions that produce an output that is computed from the input, but is not # necessarily data dependent. @@ -311,6 +316,7 @@ fun:snprintf=custom # scanf-like fun:sscanf=custom fun:__isoc99_sscanf=custom +fun:__isoc23_sscanf=custom # TODO: custom fun:asprintf=discard diff --git a/contrib/llvm-project/compiler-rt/lib/dfsan/libc_ubuntu1404_abilist.txt b/contrib/llvm-project/compiler-rt/lib/dfsan/libc_ubuntu1404_abilist.txt index 433092e2b27b..9ffa56a23818 100644 --- a/contrib/llvm-project/compiler-rt/lib/dfsan/libc_ubuntu1404_abilist.txt +++ b/contrib/llvm-project/compiler-rt/lib/dfsan/libc_ubuntu1404_abilist.txt @@ -1,3 +1,8 @@ +fun:__isoc23_sscanf=uninstrumented +fun:__isoc23_strtol=uninstrumented +fun:__isoc23_strtoll=uninstrumented +fun:__isoc23_strtoul=uninstrumented +fun:__isoc23_strtoull=uninstrumented fun:_Exit=uninstrumented fun:_IO_adjust_column=uninstrumented fun:_IO_adjust_wcolumn=uninstrumented diff --git a/contrib/llvm-project/compiler-rt/lib/profile/InstrProfilingPlatformAIX.c b/contrib/llvm-project/compiler-rt/lib/profile/InstrProfilingPlatformAIX.c index 9f46a98d78ac..002bec164d7e 100644 --- a/contrib/llvm-project/compiler-rt/lib/profile/InstrProfilingPlatformAIX.c +++ b/contrib/llvm-project/compiler-rt/lib/profile/InstrProfilingPlatformAIX.c @@ -195,6 +195,8 @@ static const int dummy_name[0] COMPILER_RT_SECTION( COMPILER_RT_SEG INSTR_PROF_NAME_SECT_NAME); static int dummy_vnds[0] COMPILER_RT_SECTION( COMPILER_RT_SEG INSTR_PROF_VNODES_SECT_NAME); +static int dummy_orderfile[0] COMPILER_RT_SECTION( + COMPILER_RT_SEG INSTR_PROF_ORDERFILE_SECT_NAME); // To avoid GC'ing of the dummy variables by the linker, reference them in an // array and reference the array in the runtime registration code @@ -206,7 +208,7 @@ static int dummy_vnds[0] COMPILER_RT_SECTION( COMPILER_RT_VISIBILITY void *__llvm_profile_keep[] = {(void *)&dummy_cnts, (void *)&dummy_bits, (void *)&dummy_data, (void *)&dummy_name, - (void *)&dummy_vnds}; + (void *)&dummy_vnds, (void *)&dummy_orderfile}; #ifdef __GNUC__ #pragma GCC diagnostic pop #endif diff --git a/contrib/llvm-project/libcxx/include/print b/contrib/llvm-project/libcxx/include/print index 7f2b5bac3dcf..543a540ee4f2 100644 --- a/contrib/llvm-project/libcxx/include/print +++ b/contrib/llvm-project/libcxx/include/print @@ -32,6 +32,7 @@ namespace std { */ #include <__assert> // all public C++ headers provide the assertion handler +#include <__availability> #include <__concepts/same_as.h> #include <__config> #include <__system_error/system_error.h> @@ -43,10 +44,6 @@ namespace std { #include <string_view> #include <version> -#if __has_include(<unistd.h>) -# include <unistd.h> -#endif - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif @@ -68,7 +65,8 @@ _LIBCPP_EXPORTED_FROM_ABI bool __is_windows_terminal(FILE* __stream); // Note the function is only implemented on the Windows platform. _LIBCPP_EXPORTED_FROM_ABI void __write_to_windows_console(FILE* __stream, wstring_view __view); # endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS - +#elif __has_include(<unistd.h>) +_LIBCPP_EXPORTED_FROM_ABI bool __is_posix_terminal(FILE* __stream); #endif // _LIBCPP_WIN32API #if _LIBCPP_STD_VER >= 23 @@ -195,15 +193,17 @@ inline constexpr bool __use_unicode_execution_charset = _MSVC_EXECUTION_CHARACTE inline constexpr bool __use_unicode_execution_charset = true; # endif -_LIBCPP_HIDE_FROM_ABI inline bool __is_terminal(FILE* __stream) { +_LIBCPP_HIDE_FROM_ABI inline bool __is_terminal([[maybe_unused]] FILE* __stream) { // The macro _LIBCPP_TESTING_PRINT_IS_TERMINAL is used to change // the behavior in the test. This is not part of the public API. # ifdef _LIBCPP_TESTING_PRINT_IS_TERMINAL return _LIBCPP_TESTING_PRINT_IS_TERMINAL(__stream); +# elif _LIBCPP_AVAILABILITY_HAS_PRINT == 0 + return false; # elif defined(_LIBCPP_WIN32API) return std::__is_windows_terminal(__stream); # elif __has_include(<unistd.h>) - return isatty(fileno(__stream)); + return std::__is_posix_terminal(__stream); # else # error "Provide a way to determine whether a FILE* is a terminal" # endif diff --git a/contrib/llvm-project/libcxx/modules/CMakeLists.txt.in b/contrib/llvm-project/libcxx/modules/CMakeLists.txt.in new file mode 100644 index 000000000000..e332d70cc163 --- /dev/null +++ b/contrib/llvm-project/libcxx/modules/CMakeLists.txt.in @@ -0,0 +1,88 @@ +cmake_minimum_required(VERSION 3.26) + +project(libc++-modules LANGUAGES CXX) + +# Enable CMake's module support +if(CMAKE_VERSION VERSION_LESS "3.28.0") + if(CMAKE_VERSION VERSION_LESS "3.27.0") + set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "2182bf5c-ef0d-489a-91da-49dbc3090d2a") + else() + set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "aa1f7df0-828a-4fcd-9afc-2dc80491aca7") + endif() + set(CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP 1) +else() + cmake_policy(VERSION 3.28) +endif() + +# Default to C++ extensions being off. Libc++'s modules support have trouble +# with extensions right now. +set(CMAKE_CXX_EXTENSIONS OFF) + +# Propagates the CMake options to the modules. +# +# This uses the std module hard-coded since the std.compat module does not +# depend on these flags. +macro(compile_define_if_not condition def) + if (NOT ${condition}) + target_compile_definitions(std PRIVATE ${def}) + endif() +endmacro() +macro(compile_define_if condition def) + if (${condition}) + target_compile_definitions(std PRIVATE ${def}) + endif() +endmacro() + +### STD + +add_library(std) +target_sources(std + PUBLIC FILE_SET cxx_modules TYPE CXX_MODULES FILES + std.cppm +) + +target_include_directories(std SYSTEM PRIVATE @LIBCXX_CONFIGURED_INCLUDE_DIRS@) + +if (NOT @LIBCXX_ENABLE_EXCEPTIONS@) + target_compile_options(std PUBLIC -fno-exceptions) +endif() + +target_compile_options(std + PUBLIC + -nostdinc++ + -Wno-reserved-module-identifier + -Wno-reserved-user-defined-literal + @LIBCXX_COMPILE_FLAGS@ +) +set_target_properties(std + PROPERTIES + OUTPUT_NAME "c++std" +) + +### STD.COMPAT + +add_library(std.compat) +target_sources(std.compat + PUBLIC FILE_SET cxx_modules TYPE CXX_MODULES FILES + std.compat.cppm +) + +target_include_directories(std.compat SYSTEM PRIVATE @LIBCXX_CONFIGURED_INCLUDE_DIRS@) + +if (NOT @LIBCXX_ENABLE_EXCEPTIONS@) + target_compile_options(std.compat PUBLIC -fno-exceptions) +endif() + +target_compile_options(std.compat + PUBLIC + -nostdinc++ + -Wno-reserved-module-identifier + -Wno-reserved-user-defined-literal + -fmodule-file=std=${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/std.dir/std.pcm + @LIBCXX_COMPILE_FLAGS@ +) +set_target_properties(std.compat + PROPERTIES + OUTPUT_NAME "c++std.compat" +) +add_dependencies(std.compat std) diff --git a/contrib/llvm-project/libcxx/modules/std/ostream.inc b/contrib/llvm-project/libcxx/modules/std/ostream.inc index 8fcbfb4bdc18..0e0e2d54fe6b 100644 --- a/contrib/llvm-project/libcxx/modules/std/ostream.inc +++ b/contrib/llvm-project/libcxx/modules/std/ostream.inc @@ -33,8 +33,10 @@ export namespace std { using std::println; using std::vprint_nonunicode; +# ifndef _LIBCPP_HAS_NO_UNICODE using std::vprint_unicode; -# endif // _LIBCPP_STD_VER >= 23 +# endif // _LIBCPP_HAS_NO_UNICODE +# endif // _LIBCPP_STD_VER >= 23 #endif // _LIBCPP_HAS_NO_LOCALIZATION } // namespace std diff --git a/contrib/llvm-project/libcxx/src/print.cpp b/contrib/llvm-project/libcxx/src/print.cpp index 3692187a5954..8fa59fdd097b 100644 --- a/contrib/llvm-project/libcxx/src/print.cpp +++ b/contrib/llvm-project/libcxx/src/print.cpp @@ -8,22 +8,26 @@ #include <__config> -#if defined(_LIBCPP_WIN32API) +#include <cstdlib> +#include <print> + +#include <__system_error/system_error.h> -# include <cstdlib> -# include <print> +#include "filesystem/error.h" +#if defined(_LIBCPP_WIN32API) # define WIN32_LEAN_AND_MEAN # define NOMINMAX # include <io.h> # include <windows.h> - -# include <__system_error/system_error.h> - -# include "filesystem/error.h" +#elif __has_include(<unistd.h>) +# include <unistd.h> +#endif _LIBCPP_BEGIN_NAMESPACE_STD +#if defined(_LIBCPP_WIN32API) + _LIBCPP_EXPORTED_FROM_ABI bool __is_windows_terminal(FILE* __stream) { // Note the Standard does this in one call, but it's unclear whether // an invalid handle is allowed when calling GetConsoleMode. @@ -52,6 +56,9 @@ __write_to_windows_console([[maybe_unused]] FILE* __stream, [[maybe_unused]] wst } # endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS -_LIBCPP_END_NAMESPACE_STD +#elif __has_include(<unistd.h>) // !_LIBCPP_WIN32API -#endif // !_LIBCPP_WIN32API +_LIBCPP_EXPORTED_FROM_ABI bool __is_posix_terminal(FILE* __stream) { return isatty(fileno(__stream)); } +#endif + +_LIBCPP_END_NAMESPACE_STD diff --git a/contrib/llvm-project/lld/COFF/Driver.cpp b/contrib/llvm-project/lld/COFF/Driver.cpp index e0afb6b18805..22ee2f133be9 100644 --- a/contrib/llvm-project/lld/COFF/Driver.cpp +++ b/contrib/llvm-project/lld/COFF/Driver.cpp @@ -1825,7 +1825,15 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) { } } else { config->repro = false; - config->timestamp = time(nullptr); + if (std::optional<std::string> epoch = + Process::GetEnv("SOURCE_DATE_EPOCH")) { + StringRef value(*epoch); + if (value.getAsInteger(0, config->timestamp)) + fatal(Twine("invalid SOURCE_DATE_EPOCH timestamp: ") + value + + ". Expected 32-bit integer"); + } else { + config->timestamp = time(nullptr); + } } // Handle /alternatename diff --git a/contrib/llvm-project/lld/ELF/Arch/LoongArch.cpp b/contrib/llvm-project/lld/ELF/Arch/LoongArch.cpp index ab2ec5b447d0..05fd38fb753f 100644 --- a/contrib/llvm-project/lld/ELF/Arch/LoongArch.cpp +++ b/contrib/llvm-project/lld/ELF/Arch/LoongArch.cpp @@ -36,6 +36,8 @@ public: bool usesOnlyLowPageBits(RelType type) const override; void relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const override; + bool relaxOnce(int pass) const override; + void finalizeRelax(int passes) const override; }; } // end anonymous namespace @@ -465,8 +467,9 @@ RelExpr LoongArch::getRelExpr(const RelType type, const Symbol &s, case R_LARCH_TLS_GD_HI20: return R_TLSGD_GOT; case R_LARCH_RELAX: - // LoongArch linker relaxation is not implemented yet. - return R_NONE; *** 2151 LINES SKIPPED ***