@@ -402,6 +402,11 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
402402 CmdArgs.push_back (Arch == llvm::Triple::aarch64_be ? " -EB" : " -EL" );
403403 }
404404
405+ if (Triple.isRISCV () &&
406+ Triple.getVendor () == llvm::Triple::MipsTechnologies) {
407+ CmdArgs.push_back (" -EL" );
408+ }
409+
405410 // Most Android ARM64 targets should enable the linker fix for erratum
406411 // 843419. Only non-Cortex-A53 devices are allowed to skip this flag.
407412 if (Arch == llvm::Triple::aarch64 && (isAndroid || isOHOSFamily)) {
@@ -765,7 +770,8 @@ void tools::gnutools::Assembler::ConstructJob(Compilation &C,
765770 }
766771 case llvm::Triple::riscv32:
767772 case llvm::Triple::riscv64: {
768- StringRef ABIName = riscv::getRISCVABI (Args, getToolChain ().getTriple ());
773+ const llvm::Triple &Triple = getToolChain ().getTriple ();
774+ StringRef ABIName = riscv::getRISCVABI (Args, Triple);
769775 CmdArgs.push_back (" -mabi" );
770776 CmdArgs.push_back (ABIName.data ());
771777 std::string MArchName =
@@ -774,6 +780,10 @@ void tools::gnutools::Assembler::ConstructJob(Compilation &C,
774780 CmdArgs.push_back (Args.MakeArgString (MArchName));
775781 if (!Args.hasFlag (options::OPT_mrelax, options::OPT_mno_relax, true ))
776782 Args.addOptOutFlag (CmdArgs, options::OPT_mrelax, options::OPT_mno_relax);
783+
784+ if (Triple.getVendor () == llvm::Triple::MipsTechnologies)
785+ CmdArgs.push_back (" -EL" );
786+
777787 break ;
778788 }
779789 case llvm::Triple::sparc:
@@ -1824,9 +1834,19 @@ static void findRISCVBareMetalMultilibs(const Driver &D,
18241834 .flag (Twine (" -march=" , Element.march ).str ())
18251835 .flag (Twine (" -mabi=" , Element.mabi ).str ()));
18261836 }
1837+ SmallVector<MultilibBuilder, 2 > Endian;
1838+ bool IsMIPS = TargetTriple.getVendor () == llvm::Triple::MipsTechnologies;
1839+ if (IsMIPS) {
1840+ Endian.push_back (
1841+ MultilibBuilder (" /riscv" ).flag (" -EL" ).flag (" -EB" , /* Disallow=*/ true ));
1842+ Endian.push_back (
1843+ MultilibBuilder (" /riscveb" ).flag (" -EB" ).flag (" -EL" , /* Disallow=*/ true ));
1844+ }
18271845 MultilibSet RISCVMultilibs =
18281846 MultilibSetBuilder ()
18291847 .Either (Ms)
1848+ .Either (Endian)
1849+ .Either (ArrayRef<MultilibBuilder>(Ms))
18301850 .makeMultilibSet ()
18311851 .FilterOut (NonExistent)
18321852 .setFilePathsCallback ([](const Multilib &M) {
@@ -1850,6 +1870,8 @@ static void findRISCVBareMetalMultilibs(const Driver &D,
18501870 }
18511871 }
18521872
1873+ addMultilibFlag (IsMIPS, " -EL" , Flags);
1874+
18531875 if (selectRISCVMultilib (D, RISCVMultilibs, MArch, Flags,
18541876 Result.SelectedMultilibs ))
18551877 Result.Multilibs = RISCVMultilibs;
@@ -1874,15 +1896,26 @@ static void findRISCVMultilibs(const Driver &D,
18741896 MultilibBuilder (" lib64/lp64f" ).flag (" -m64" ).flag (" -mabi=lp64f" );
18751897 MultilibBuilder Lp64d =
18761898 MultilibBuilder (" lib64/lp64d" ).flag (" -m64" ).flag (" -mabi=lp64d" );
1899+
1900+ SmallVector<MultilibBuilder, 2 > Endian;
1901+ if (TargetTriple.getVendor () == llvm::Triple::MipsTechnologies) {
1902+ Endian.push_back (
1903+ MultilibBuilder (" /riscv" ).flag (" -EL" ).flag (" -EB" , /* Disallow=*/ true ));
1904+ Endian.push_back (
1905+ MultilibBuilder (" /riscveb" ).flag (" -EB" ).flag (" -EL" , /* Disallow=*/ true ));
1906+ }
1907+
18771908 MultilibSet RISCVMultilibs =
18781909 MultilibSetBuilder ()
1910+ .Either (Endian)
18791911 .Either ({Ilp32, Ilp32f, Ilp32d, Lp64, Lp64f, Lp64d})
18801912 .makeMultilibSet ()
18811913 .FilterOut (NonExistent);
18821914
18831915 Multilib::flags_list Flags;
18841916 bool IsRV64 = TargetTriple.getArch () == llvm::Triple::riscv64;
18851917 StringRef ABIName = tools::riscv::getRISCVABI (Args, TargetTriple);
1918+ bool IsMIPS = TargetTriple.getVendor () == llvm::Triple::MipsTechnologies;
18861919
18871920 addMultilibFlag (!IsRV64, " -m32" , Flags);
18881921 addMultilibFlag (IsRV64, " -m64" , Flags);
@@ -1892,6 +1925,7 @@ static void findRISCVMultilibs(const Driver &D,
18921925 addMultilibFlag (ABIName == " lp64" , " -mabi=lp64" , Flags);
18931926 addMultilibFlag (ABIName == " lp64f" , " -mabi=lp64f" , Flags);
18941927 addMultilibFlag (ABIName == " lp64d" , " -mabi=lp64d" , Flags);
1928+ addMultilibFlag (IsMIPS, " -EL" , Flags);
18951929
18961930 if (RISCVMultilibs.select (D, Flags, Result.SelectedMultilibs ))
18971931 Result.Multilibs = RISCVMultilibs;
@@ -2516,8 +2550,8 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
25162550 static const char *const RISCV32Triples[] = {" riscv32-unknown-linux-gnu" ,
25172551 " riscv32-unknown-elf" };
25182552 static const char *const RISCV64LibDirs[] = {" /lib64" , " /lib" };
2519- static const char *const RISCV64Triples[] = {" riscv64-unknown-linux-gnu " ,
2520- " riscv64-unknown-elf" };
2553+ static const char *const RISCV64Triples[] = {
2554+ " riscv64-unknown-linux-gnu " , " riscv64-unknown-elf " , " riscv64-mti -elf" };
25212555
25222556 static const char *const SPARCv8LibDirs[] = {" /lib32" , " /lib" };
25232557 static const char *const SPARCv8Triples[] = {" sparc-linux-gnu" ,
0 commit comments