Skip to content
Snippets Groups Projects
Commit 280252c6 authored by Alexander Richardson's avatar Alexander Richardson
Browse files

[ELF][mips] Print the full file path for files with incompatible ISA

Summary:
I also changed the message to print both the ISA and the the architecture
name for incompatible files. Previously it would be quite hard to find the
actual path of the incompatible object files in projects that have many
object files with the same name in different directories.

Reviewers: atanasyan, ruiu

Reviewed By: atanasyan

Subscribers: emaste, sdardis, llvm-commits

Differential Revision: https://reviews.llvm.org/D40958

llvm-svn: 320056
parent 2983b469
No related branches found
No related tags found
No related merge requests found
...@@ -34,7 +34,7 @@ struct ArchTreeEdge { ...@@ -34,7 +34,7 @@ struct ArchTreeEdge {
}; };
struct FileFlags { struct FileFlags {
StringRef Filename; InputFile *File;
uint32_t Flags; uint32_t Flags;
}; };
} // namespace } // namespace
...@@ -73,17 +73,17 @@ static void checkFlags(ArrayRef<FileFlags> Files) { ...@@ -73,17 +73,17 @@ static void checkFlags(ArrayRef<FileFlags> Files) {
uint32_t ABI2 = F.Flags & (EF_MIPS_ABI | EF_MIPS_ABI2); uint32_t ABI2 = F.Flags & (EF_MIPS_ABI | EF_MIPS_ABI2);
if (ABI != ABI2) if (ABI != ABI2)
error("target ABI '" + getAbiName(ABI) + "' is incompatible with '" + error("target ABI '" + getAbiName(ABI) + "' is incompatible with '" +
getAbiName(ABI2) + "': " + F.Filename); getAbiName(ABI2) + "': " + toString(F.File));
bool Nan2 = F.Flags & EF_MIPS_NAN2008; bool Nan2 = F.Flags & EF_MIPS_NAN2008;
if (Nan != Nan2) if (Nan != Nan2)
error("target -mnan=" + getNanName(Nan) + " is incompatible with -mnan=" + 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; bool Fp2 = F.Flags & EF_MIPS_FP64;
if (Fp != Fp2) if (Fp != Fp2)
error("target -mfp" + getFpName(Fp) + " is incompatible with -mfp" + error("target -mfp" + getFpName(Fp) + " is incompatible with -mfp" +
getFpName(Fp2) + ": " + F.Filename); getFpName(Fp2) + ": " + toString(F.File));
} }
} }
...@@ -102,9 +102,11 @@ static uint32_t getPicFlags(ArrayRef<FileFlags> Files) { ...@@ -102,9 +102,11 @@ static uint32_t getPicFlags(ArrayRef<FileFlags> Files) {
for (const FileFlags &F : Files.slice(1)) { for (const FileFlags &F : Files.slice(1)) {
bool IsPic2 = F.Flags & (EF_MIPS_PIC | EF_MIPS_CPIC); bool IsPic2 = F.Flags & (EF_MIPS_PIC | EF_MIPS_CPIC);
if (IsPic && !IsPic2) 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) 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. // Compute the result PIC/non-PIC flag.
...@@ -221,10 +223,6 @@ static StringRef getMachName(uint32_t Flags) { ...@@ -221,10 +223,6 @@ static StringRef getMachName(uint32_t Flags) {
} }
static StringRef getArchName(uint32_t Flags) { static StringRef getArchName(uint32_t Flags) {
StringRef S = getMachName(Flags);
if (!S.empty())
return S;
switch (Flags & EF_MIPS_ARCH) { switch (Flags & EF_MIPS_ARCH) {
case EF_MIPS_ARCH_1: case EF_MIPS_ARCH_1:
return "mips1"; return "mips1";
...@@ -253,6 +251,14 @@ static StringRef getArchName(uint32_t Flags) { ...@@ -253,6 +251,14 @@ static StringRef getArchName(uint32_t Flags) {
} }
} }
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 // There are (arguably too) many MIPS ISAs out there. Their relationships
// can be represented as a forest. If all input files have ISAs which // can be represented as a forest. If all input files have ISAs which
// reachable by repeated proceeding from the single child to the parent, // reachable by repeated proceeding from the single child to the parent,
...@@ -272,8 +278,9 @@ static uint32_t getArchFlags(ArrayRef<FileFlags> Files) { ...@@ -272,8 +278,9 @@ static uint32_t getArchFlags(ArrayRef<FileFlags> Files) {
if (isArchMatched(New, Ret)) if (isArchMatched(New, Ret))
continue; continue;
if (!isArchMatched(Ret, New)) { if (!isArchMatched(Ret, New)) {
error("target ISA '" + getArchName(Ret) + "' is incompatible with '" + error("incompatible target ISA:\n>>> " + toString(Files[0].File) + ": " +
getArchName(New) + "': " + F.Filename); getFullArchName(Ret) + "\n>>> " + toString(F.File) + ": " +
getFullArchName(New));
return 0; return 0;
} }
Ret = New; Ret = New;
...@@ -284,8 +291,7 @@ static uint32_t getArchFlags(ArrayRef<FileFlags> Files) { ...@@ -284,8 +291,7 @@ static uint32_t getArchFlags(ArrayRef<FileFlags> Files) {
template <class ELFT> uint32_t elf::calcMipsEFlags() { template <class ELFT> uint32_t elf::calcMipsEFlags() {
std::vector<FileFlags> V; std::vector<FileFlags> V;
for (InputFile *F : ObjectFiles) for (InputFile *F : ObjectFiles)
V.push_back( V.push_back({F, cast<ObjFile<ELFT>>(F)->getObj().getHeader()->e_flags});
{F->getName(), cast<ObjFile<ELFT>>(F)->getObj().getHeader()->e_flags});
if (V.empty()) if (V.empty())
return 0; return 0;
checkFlags(V); checkFlags(V);
......
...@@ -71,8 +71,14 @@ __start: ...@@ -71,8 +71,14 @@ __start:
# R1R2-NEXT: EF_MIPS_CPIC # R1R2-NEXT: EF_MIPS_CPIC
# R1R2-NEXT: ] # R1R2-NEXT: ]
# R3R32: target ISA 'mips3' is incompatible with 'mips32': {{.*}}mips-elf-flags-err.s.tmp2.o # R3R32: error: incompatible target ISA:
# R6OCTEON: target ISA 'mips64r6' is incompatible with 'octeon': {{.*}}mips-elf-flags-err.s.tmp2.o # 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 # FPABI: target floating point ABI '-mdouble-float' is incompatible with '-mgp32 -mfp64': {{.*}}mips-elf-flags-err.s.tmp2.o
# OCTEON: Flags [ # OCTEON: Flags [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment