-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[Cygwin] Fix global variable dll import #121439
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
|
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
5062f77 to
694e20e
Compare
mstorsjo
left a comment
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.
LGTM, thanks.
Ideally, any functional change like this would warrant a change to a test case though. One way of identifying an existing test case relating to this, would be to e.g. break the existing code and run ninja check-llvm or similar, and see which tests now fail. That would show e.g. this list of tests:
LLVM :: CodeGen/AArch64/mingw-refptr.ll
LLVM :: CodeGen/ARM/Windows/mingw-refptr.ll
LLVM :: CodeGen/ARM/Windows/pic.ll
LLVM :: CodeGen/ARM/emutls_generic.ll
LLVM :: CodeGen/ARM/win32-ssp.ll
LLVM :: CodeGen/X86/PR40322.ll
LLVM :: CodeGen/X86/br-fold.ll
LLVM :: CodeGen/X86/mingw-refptr.ll
LLVM :: CodeGen/X86/stack-protector.ll
LLVM :: CodeGen/X86/win32-ssp.ll
LLVM :: CodeGen/X86/win64-byval.ll
So it might be possible to copy some of these, or add RUN lines within the existing ones, for doing the same test for a cygwin target.
mati865
left a comment
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.
You beat me to it, I was planning to look into it this month 😉
In case @Berrysoft isn't familiar with adding tests, do you think you could look into adding a test for this change? |
|
I can look into it, but probably not sooner than mid-January. My initial plan was to keep the changes as patches for MSYS2 and, after confirming they work, upstream them. |
|
Thank you. I'm really not familiar with adding tests. If @mati865 has a larger plan including this patch, I think it's also OK. I just wanted to solve the problem. |
We generally require test additions to go along with the functional changes, unless there's a good reason not to, or there is a high urgency to unbreak things. For this case, just add this change to your patch: diff --git a/llvm/test/CodeGen/X86/mingw-refptr.ll b/llvm/test/CodeGen/X86/mingw-refptr.ll
index 73f1a9880913..82a90aba3865 100644
--- a/llvm/test/CodeGen/X86/mingw-refptr.ll
+++ b/llvm/test/CodeGen/X86/mingw-refptr.ll
@@ -1,4 +1,5 @@
; RUN: llc < %s -mtriple=x86_64-w64-mingw32 | FileCheck %s -check-prefix=CHECK-X64
+; RUN: llc < %s -mtriple=x86_64-pc-cygwin | FileCheck %s -check-prefix=CHECK-X64
; RUN: llc < %s -mtriple=i686-w64-mingw32 | FileCheck %s -check-prefix=CHECK-X86
; RUN: llc < %s -mtriple=i686-w64-mingw32-none-elf | FileCheck %s -check-prefix=CHECK-X86-ELF
I tested that this is enough. Without the change in this patch, this added test fails (you can run |
694e20e to
80b347a
Compare
|
Thank you very much, @mstorsjo ! I have added the test. |
|
@llvm/pr-subscribers-backend-x86 Author: 王宇逸 (Berrysoft) ChangesThis PR is necessary for cygwin target of Rust. References: Full diff: https://github.com/llvm/llvm-project/pull/121439.diff 2 Files Affected:
diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp
index c0985f3be91a53..d5365f3c047437 100644
--- a/llvm/lib/Target/TargetMachine.cpp
+++ b/llvm/lib/Target/TargetMachine.cpp
@@ -204,7 +204,7 @@ bool TargetMachine::shouldAssumeDSOLocal(const GlobalValue *GV) const {
// don't assume the variables to be DSO local unless we actually know
// that for sure. This only has to be done for variables; for functions
// the linker can insert thunks for calling functions from another DLL.
- if (TT.isWindowsGNUEnvironment() && GV->isDeclarationForLinker() &&
+ if (TT.isOSCygMing() && GV->isDeclarationForLinker() &&
isa<GlobalVariable>(GV))
return false;
diff --git a/llvm/test/CodeGen/X86/mingw-refptr.ll b/llvm/test/CodeGen/X86/mingw-refptr.ll
index 73f1a9880913c9..82a90aba386546 100644
--- a/llvm/test/CodeGen/X86/mingw-refptr.ll
+++ b/llvm/test/CodeGen/X86/mingw-refptr.ll
@@ -1,4 +1,5 @@
; RUN: llc < %s -mtriple=x86_64-w64-mingw32 | FileCheck %s -check-prefix=CHECK-X64
+; RUN: llc < %s -mtriple=x86_64-pc-cygwin | FileCheck %s -check-prefix=CHECK-X64
; RUN: llc < %s -mtriple=i686-w64-mingw32 | FileCheck %s -check-prefix=CHECK-X86
; RUN: llc < %s -mtriple=i686-w64-mingw32-none-elf | FileCheck %s -check-prefix=CHECK-X86-ELF
|
mstorsjo
left a comment
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.
LGTM, thanks!
Please go ahead. My work is still in an early stage. |
|
@Berrysoft Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
This PR is necessary for cygwin target of Rust.
References: