diff --git a/llvm/test/tools/llvm-ifs/conflict-weak.ifs b/llvm/test/tools/llvm-ifs/conflict-weak.ifs --- a/llvm/test/tools/llvm-ifs/conflict-weak.ifs +++ b/llvm/test/tools/llvm-ifs/conflict-weak.ifs @@ -1,12 +1,8 @@ -# RUN: not llvm-ifs -action write-ifs -o - %s %S/func.ifs 2>&1 | \ +# RUN: llvm-ifs -action write-ifs -o - %s %S/func.ifs 2>&1 | \ # RUN: FileCheck %s --check-prefixes=CHECK-IFS -# Here we are testing to see if two symbols with identical names will fail to -# merge in conflict due to one being weak and one not. Eventually this will work -# when llvm-ifs has support for resolving these kinds of conflicts. -# CHECK-IFS: error: Interface Stub: Weak Mismatch for a. -# CHECK-IFS-NEXT: Filename: -# CHECK-IFS-NEXT: Weak Values: 1 0 +# CHECK-IFS: Symbols: +# CHECK-IFS-NEXT: a: { Type: Func, Weak: true } --- !experimental-ifs-v1 IfsVersion: 1.0 diff --git a/llvm/test/tools/llvm-ifs/default-empty.ifs b/llvm/test/tools/llvm-ifs/default-empty.ifs new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-ifs/default-empty.ifs @@ -0,0 +1,25 @@ +# RUN: llvm-ifs -action write-ifs -o - %s | FileCheck --check-prefixes=CHECK-DEFAULT %s +# RUN: llvm-ifs -action write-ifs -o - %s %S/weak.ifs | FileCheck --check-prefixes=CHECK-MERGE %s + +# CHECK-DEFAULT: --- !experimental-ifs-v1 +# CHECK-DEFAULT-NEXT: IfsVersion: 1.2 +# CHECK-DEFAULT-NEXT: Triple: '' +# CHECK-DEFAULT-NEXT: ObjectFileFormat: ELF +# CHECK-DEFAULT-NEXT: Symbols: {} +# CHECK-DEFAULT-NEXT: ... + +# CHECK-MERGE: --- !experimental-ifs-v1 +# CHECK-MERGE-NEXT: IfsVersion: 1.0 +# CHECK-MERGE-NEXT: Triple: x86_64-unknown-linux-gnu +# CHECK-MERGE-NEXT: ObjectFileFormat: ELF +# CHECK-MERGE-NEXT: Symbols: +# CHECK-MERGE-DAG: _Z8weakFuncv: { Type: Func, Weak: true } +# CHECK-MERGE-DAG: _Z10strongFuncv: { Type: Func } +# CHECK-MERGE: ... + +--- !experimental-ifs-v1 +IfsVersion: 1.2 +Triple: '' +ObjectFileFormat: ELF +Symbols: {} +... diff --git a/llvm/test/tools/llvm-ifs/strong.ifs b/llvm/test/tools/llvm-ifs/strong.ifs new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-ifs/strong.ifs @@ -0,0 +1,17 @@ +# RUN: llvm-ifs -action write-ifs -o - %s %S/strong.ifs | FileCheck %s --check-prefixes=CHECK-IFS + +# CHECK-IFS: --- !experimental-ifs-v1 +# CHECK-IFS-NEXT: IfsVersion: 1.0 +# CHECK-IFS-NEXT: Triple: x86_64-unknown-linux-gnu +# CHECK-IFS-NEXT: ObjectFileFormat: ELF +# CHECK-IFS-NEXT: Symbols: +# CHECK-IFS-DAG: _Z8weakFuncv: { Type: Func } +# CHECK-IFS: ... + +--- !experimental-ifs-v1 +IfsVersion: 1.0 +Triple: x86_64-unknown-linux-gnu +ObjectFileFormat: ELF +Symbols: + _Z8weakFuncv: { Type: Func } +... diff --git a/llvm/tools/llvm-ifs/llvm-ifs.cpp b/llvm/tools/llvm-ifs/llvm-ifs.cpp --- a/llvm/tools/llvm-ifs/llvm-ifs.cpp +++ b/llvm/tools/llvm-ifs/llvm-ifs.cpp @@ -422,6 +422,10 @@ Stub.SOName = TargetStub->SOName; Stub.NeededLibs = TargetStub->NeededLibs; } else { + Stub.ObjectFileFormat = !Stub.ObjectFileFormat.empty() + ? Stub.ObjectFileFormat + : TargetStub->ObjectFileFormat; + if (Stub.IfsVersion != TargetStub->IfsVersion) { if (Stub.IfsVersion.getMajor() != IFSVersionCurrent.getMajor()) { WithColor::error() @@ -434,7 +438,8 @@ if (TargetStub->IfsVersion > Stub.IfsVersion) Stub.IfsVersion = TargetStub->IfsVersion; } - if (Stub.ObjectFileFormat != TargetStub->ObjectFileFormat) { + if (Stub.ObjectFileFormat != TargetStub->ObjectFileFormat && + !TargetStub->ObjectFileFormat.empty()) { WithColor::error() << "Interface Stub: ObjectFileFormat Mismatch." << "\nFilenames: " << PreviousInputFilePath << " " << InputFilePath << "\nObjectFileFormat Values: " @@ -442,7 +447,7 @@ << TargetStub->ObjectFileFormat << "\n"; return -1; } - if (Stub.Triple != TargetStub->Triple) { + if (Stub.Triple != TargetStub->Triple && !TargetStub->Triple.empty()) { WithColor::error() << "Interface Stub: Triple Mismatch." << "\nFilenames: " << PreviousInputFilePath << " " << InputFilePath @@ -494,13 +499,8 @@ return -1; } if (Symbol.Weak != SI->second.Weak) { - // TODO: Add conflict resolution for Weak vs non-Weak. - WithColor::error() << "Interface Stub: Weak Mismatch for " - << Symbol.Name << ".\nFilename: " << InputFilePath - << "\nWeak Values: " << SI->second.Weak << " " - << Symbol.Weak << "\n"; - - return -1; + Symbol.Weak = false; + continue; } // TODO: Not checking Warning. Will be dropped. }