-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[LLD][COFF] Use parentName for import files in toString. #106104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Inspired by @zmodem's comment in #102738. We currently explicitly ignore parentName for import files in toString, which makes error/warning messages less expressive than they would otherwise be. I tracked the check in toString down to https://reviews.llvm.org/D54802. It looks like this commit set ParentName on import files, so I guess the change was about preserving previous behaviour. However, using it seems reasonable to me. It looks like toString is already used only by error, warnings and logs, so it seems to be a good fit. |
@llvm/pr-subscribers-lld-coff @llvm/pr-subscribers-lld Author: Jacek Caban (cjacek) ChangesFull diff: https://github.com/llvm/llvm-project/pull/106104.diff 4 Files Affected:
diff --git a/lld/COFF/InputFiles.cpp b/lld/COFF/InputFiles.cpp
index f9a22b0a7a5f0f..3ecd4d241f2cd4 100644
--- a/lld/COFF/InputFiles.cpp
+++ b/lld/COFF/InputFiles.cpp
@@ -61,7 +61,7 @@ static StringRef getBasename(StringRef path) {
std::string lld::toString(const coff::InputFile *file) {
if (!file)
return "<internal>";
- if (file->parentName.empty() || file->kind() == coff::InputFile::ImportKind)
+ if (file->parentName.empty())
return std::string(file->getName());
return (getBasename(file->parentName) + "(" + getBasename(file->getName()) +
diff --git a/lld/test/COFF/delayimports-error.test b/lld/test/COFF/delayimports-error.test
index cced9fb65e6142..5f45083cf5e613 100644
--- a/lld/test/COFF/delayimports-error.test
+++ b/lld/test/COFF/delayimports-error.test
@@ -8,7 +8,7 @@
# RUN: /alternatename:__delayLoadHelper2=main /opt:noref >& %t.log
# RUN: FileCheck %s < %t.log
-# CHECK: cannot delay-load foo.dll due to import of data: __declspec(dllimport) datasym
+# CHECK: cannot delay-load foo.lib(foo.dll) due to import of data: __declspec(dllimport) datasym
--- !COFF
header:
diff --git a/lld/test/COFF/duplicate.test b/lld/test/COFF/duplicate.test
index 76c88b070ff375..11e5aa06318fe0 100644
--- a/lld/test/COFF/duplicate.test
+++ b/lld/test/COFF/duplicate.test
@@ -13,5 +13,5 @@ RUN: not lld-link /out:gamma.exe /subsystem:console /entry:mainCRTStartup gamma.
CHECK-GAMMA: error: duplicate symbol: __declspec(dllimport) f
CHECK-GAMMA: defined at {{.*}}gamma.obj
-CHECK-GAMMA: defined at alpha.dll
+CHECK-GAMMA: defined at alpha.lib(alpha.dll)
diff --git a/lld/test/COFF/implib-machine.s b/lld/test/COFF/implib-machine.s
index 32deff0fc25f89..92f01bbc72799b 100644
--- a/lld/test/COFF/implib-machine.s
+++ b/lld/test/COFF/implib-machine.s
@@ -6,10 +6,10 @@
# RUN: llvm-mc -triple x86_64-windows-msvc %t.dir/test.s -filetype=obj -o %t.dir/test64.obj
# RUN: not lld-link -dll -noentry -out:%t32.dll %t.dir/test32.obj %t.dir/test64.lib 2>&1 | FileCheck --check-prefix=ERR32 %s
-# ERR32: error: test.dll: machine type x64 conflicts with x86
+# ERR32: error: test64.lib(test.dll): machine type x64 conflicts with x86
# RUN: not lld-link -dll -noentry -out:%t64.dll %t.dir/test64.obj %t.dir/test32.lib 2>&1 | FileCheck --check-prefix=ERR64 %s
-# ERR64: error: test.dll: machine type x86 conflicts with x64
+# ERR64: error: test32.lib(test.dll): machine type x86 conflicts with x64
#--- test.s
.def @feat.00;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good because some libraries have members all named the same (ie.Microsoft) and it it’s not always clear from which archive the symbol comes from. Thanks for the change, LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a nice improvement for users. Thanks!
Merged, thanks for reviews. |
No description provided.