Index: ELF/Arch/MipsArchTree.cpp =================================================================== --- ELF/Arch/MipsArchTree.cpp +++ ELF/Arch/MipsArchTree.cpp @@ -34,7 +34,7 @@ }; struct FileFlags { - StringRef Filename; + InputFile *File; uint32_t Flags; }; } // namespace @@ -73,17 +73,17 @@ uint32_t ABI2 = F.Flags & (EF_MIPS_ABI | EF_MIPS_ABI2); if (ABI != ABI2) error("target ABI '" + getAbiName(ABI) + "' is incompatible with '" + - getAbiName(ABI2) + "': " + F.Filename); + getAbiName(ABI2) + "': " + toString(F.File)); bool Nan2 = F.Flags & EF_MIPS_NAN2008; if (Nan != Nan2) error("target -mnan=" + getNanName(Nan) + " is incompatible with -mnan=" + - getNanName(Nan2) + ": " + F.Filename); + getNanName(Nan2) + ": " + toString(F.File)); bool Fp2 = F.Flags & EF_MIPS_FP64; if (Fp != Fp2) error("target -mfp" + getFpName(Fp) + " is incompatible with -mfp" + - getFpName(Fp2) + ": " + F.Filename); + getFpName(Fp2) + ": " + toString(F.File)); } } @@ -102,9 +102,11 @@ for (const FileFlags &F : Files.slice(1)) { bool IsPic2 = F.Flags & (EF_MIPS_PIC | EF_MIPS_CPIC); if (IsPic && !IsPic2) - warn("linking abicalls code with non-abicalls file: " + F.Filename); + warn("linking abicalls code " + toString(Files[0].File) + + " with non-abicalls file: " + toString(F.File)); if (!IsPic && IsPic2) - warn("linking non-abicalls code with abicalls file: " + F.Filename); + warn("linking non-abicalls code " + toString(Files[0].File) + + " with abicalls file: " + toString(F.File)); } // Compute the result PIC/non-PIC flag. @@ -221,10 +223,6 @@ } static StringRef getArchName(uint32_t Flags) { - StringRef S = getMachName(Flags); - if (!S.empty()) - return S; - switch (Flags & EF_MIPS_ARCH) { case EF_MIPS_ARCH_1: return "mips1"; @@ -253,6 +251,14 @@ } } +static std::string getFullArchName(uint32_t Flags) { + StringRef Arch = getArchName(Flags); + StringRef Mach = getMachName(Flags); + if (Mach.empty()) + return Arch.str(); + return (Arch + " (" + Mach + ")").str(); +} + // There are (arguably too) many MIPS ISAs out there. Their relationships // can be represented as a forest. If all input files have ISAs which // reachable by repeated proceeding from the single child to the parent, @@ -272,8 +278,9 @@ if (isArchMatched(New, Ret)) continue; if (!isArchMatched(Ret, New)) { - error("target ISA '" + getArchName(Ret) + "' is incompatible with '" + - getArchName(New) + "': " + F.Filename); + error("incompatible target ISA:\n>>> " + toString(Files[0].File) + ": " + + getFullArchName(Ret) + "\n>>> " + toString(F.File) + ": " + + getFullArchName(New)); return 0; } Ret = New; @@ -284,8 +291,7 @@ template uint32_t elf::calcMipsEFlags() { std::vector V; for (InputFile *F : ObjectFiles) - V.push_back( - {F->getName(), cast>(F)->getObj().getHeader()->e_flags}); + V.push_back({F, cast>(F)->getObj().getHeader()->e_flags}); if (V.empty()) return 0; checkFlags(V); Index: test/ELF/mips-elf-flags-err.s =================================================================== --- test/ELF/mips-elf-flags-err.s +++ test/ELF/mips-elf-flags-err.s @@ -71,8 +71,14 @@ # R1R2-NEXT: EF_MIPS_CPIC # R1R2-NEXT: ] -# R3R32: target ISA 'mips3' is incompatible with 'mips32': {{.*}}mips-elf-flags-err.s.tmp2.o -# R6OCTEON: target ISA 'mips64r6' is incompatible with 'octeon': {{.*}}mips-elf-flags-err.s.tmp2.o +# R3R32: error: incompatible target ISA: +# R3R32-NEXT: >>> {{.+}}/mips-elf-flags-err.s.tmp1.o: mips3 +# R3R32-NEXT: >>> {{.+}}/mips-elf-flags-err.s.tmp2.o: mips32 + +# R6OCTEON: error: incompatible target ISA: +# R6OCTEON-NEXT: >>> {{.+}}/mips-elf-flags-err.s.tmp1.o: mips64r6 +# R6OCTEON-NEXT: >>> {{.+}}/mips-elf-flags-err.s.tmp2.o: mips64r2 (octeon) + # FPABI: target floating point ABI '-mdouble-float' is incompatible with '-mgp32 -mfp64': {{.*}}mips-elf-flags-err.s.tmp2.o # OCTEON: Flags [