Since MinGW supports automatically importing external variables from DLLs even without the DLLImport attribute, we shouldn't mark them as DSO local unless we actually know them to be local for sure.
Keep marking thread local variables as DSO local.
Paths
| Differential D51382
[MinGW] Don't mark external variables as DSO local ClosedPublic Authored by mstorsjo on Aug 28 2018, 2:03 PM.
Details Summary Since MinGW supports automatically importing external variables from DLLs even without the DLLImport attribute, we shouldn't mark them as DSO local unless we actually know them to be local for sure. Keep marking thread local variables as DSO local.
Diff Detail
Event Timeline
Comment Actions Changed the condition to GV->isDeclarationForLinker(), updated tests accordingly (weak_bar in CodeGen/dso-local-executable.c lost the dso_local flag) and added more tests in CodeGenCXX/dso-local-executable.cpp as requested. Comment Actions lgtm
This revision is now accepted and ready to land.Aug 29 2018, 8:39 AM
Closed by commit rC340941: [MinGW] Don't mark external variables as DSO local (authored by mstorsjo). · Explain WhyAug 29 2018, 10:28 AM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 163134 lib/CodeGen/CodeGenModule.cpp
test/CodeGen/dllimport.c
test/CodeGen/dso-local-executable.c
test/CodeGenCXX/dllexport.cpp
test/CodeGenCXX/dllimport-members.cpp
test/CodeGenCXX/dllimport.cpp
test/CodeGenCXX/dso-local-executable.cpp
|
I think this linkage and declaration check should be GV->isDeclarationForLinker(), since that will catch available_externally globals as well. Those would come from a static data member of a class template that has an explicit instantiation declaration:
Yep, that does it on x86_64-windows-gnu. We probably want a stub for Foo<int>::x.
Can you add a test at clang/test/CodeGenCXX/dso-local.cpp for this?