https://github.com/hpoussin updated https://github.com/llvm/llvm-project/pull/121041
From 946baa36101b99bfd512a0b7dbca757a93f68891 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= <hpous...@reactos.org> Date: Fri, 10 Nov 2023 23:06:52 +0100 Subject: [PATCH] [Clang][MIPS] Create correct linker arguments for Windows toolchains --- clang/lib/CodeGen/CodeGenModule.cpp | 2 ++ clang/lib/CodeGen/TargetInfo.h | 3 +++ clang/lib/CodeGen/Targets/Mips.cpp | 22 ++++++++++++++++++++++ clang/test/CodeGen/pragma-comment.c | 1 + 4 files changed, 28 insertions(+) diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index c49f7631488285..2ec12eb8b7b04e 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -119,6 +119,8 @@ createTargetCodeGenInfo(CodeGenModule &CGM) { case llvm::Triple::mipsel: if (Triple.getOS() == llvm::Triple::NaCl) return createPNaClTargetCodeGenInfo(CGM); + else if (Triple.getOS() == llvm::Triple::Win32) + return createWindowsMIPSTargetCodeGenInfo(CGM, /*IsOS32=*/true); return createMIPSTargetCodeGenInfo(CGM, /*IsOS32=*/true); case llvm::Triple::mips64: diff --git a/clang/lib/CodeGen/TargetInfo.h b/clang/lib/CodeGen/TargetInfo.h index ab3142bdea684e..4a66683a3b91fd 100644 --- a/clang/lib/CodeGen/TargetInfo.h +++ b/clang/lib/CodeGen/TargetInfo.h @@ -522,6 +522,9 @@ createM68kTargetCodeGenInfo(CodeGenModule &CGM); std::unique_ptr<TargetCodeGenInfo> createMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32); +std::unique_ptr<TargetCodeGenInfo> +createWindowsMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32); + std::unique_ptr<TargetCodeGenInfo> createMSP430TargetCodeGenInfo(CodeGenModule &CGM); diff --git a/clang/lib/CodeGen/Targets/Mips.cpp b/clang/lib/CodeGen/Targets/Mips.cpp index 06d9b6d4a57615..771a85c84b3571 100644 --- a/clang/lib/CodeGen/Targets/Mips.cpp +++ b/clang/lib/CodeGen/Targets/Mips.cpp @@ -105,6 +105,23 @@ class MIPSTargetCodeGenInfo : public TargetCodeGenInfo { return SizeOfUnwindException; } }; + +class WindowsMIPSTargetCodeGenInfo : public MIPSTargetCodeGenInfo { +public: + WindowsMIPSTargetCodeGenInfo(CodeGenTypes &CGT, bool IsO32) + : MIPSTargetCodeGenInfo(CGT, IsO32) {} + + void getDependentLibraryOption(llvm::StringRef Lib, + llvm::SmallString<24> &Opt) const override { + Opt = "/DEFAULTLIB:"; + Opt += qualifyWindowsLibrary(Lib); + } + + void getDetectMismatchOption(llvm::StringRef Name, llvm::StringRef Value, + llvm::SmallString<32> &Opt) const override { + Opt = "/FAILIFMISMATCH:\"" + Name.str() + "=" + Value.str() + "\""; + } +}; } void MipsABIInfo::CoerceToIntArgs( @@ -436,3 +453,8 @@ std::unique_ptr<TargetCodeGenInfo> CodeGen::createMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32) { return std::make_unique<MIPSTargetCodeGenInfo>(CGM.getTypes(), IsOS32); } + +std::unique_ptr<TargetCodeGenInfo> +CodeGen::createWindowsMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32) { + return std::make_unique<WindowsMIPSTargetCodeGenInfo>(CGM.getTypes(), IsOS32); +} diff --git a/clang/test/CodeGen/pragma-comment.c b/clang/test/CodeGen/pragma-comment.c index a4746f5c47bf6b..a966840f7c26fc 100644 --- a/clang/test/CodeGen/pragma-comment.c +++ b/clang/test/CodeGen/pragma-comment.c @@ -6,6 +6,7 @@ // RUN: %clang_cc1 %s -triple x86_64-scei-ps4 -fms-extensions -emit-llvm -o - | FileCheck -check-prefix ELF %s --implicit-check-not llvm.linker.options // RUN: %clang_cc1 %s -triple x86_64-sie-ps5 -fms-extensions -emit-llvm -o - | FileCheck -check-prefix ELF %s --implicit-check-not llvm.linker.options // RUN: %clang_cc1 %s -triple aarch64-windows-msvc -fms-extensions -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple mipsel-windows-msvc -fms-extensions -emit-llvm -o - | FileCheck %s #pragma comment(lib, "msvcrt.lib") #pragma comment(lib, "kernel32") _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits