This is an archive of the discontinued LLVM Phabricator instance.

[MinGW][libclang] Allow simultaneous shared and static lib
ClosedPublic

Authored by mati865 on Sep 11 2020, 12:05 PM.

Details

Reviewers
mstorsjo
Group Reviewers
Restricted Project
Commits
rG7da941939902: [MinGW][libclang] Allow simultaneous shared and static lib
Summary

It builds fine for MinGW on Windows.

Diff Detail

Event Timeline

mati865 created this revision.Sep 11 2020, 12:05 PM
mati865 requested review of this revision.Sep 11 2020, 12:05 PM

Does the static lib built in this case include any dllexport attributes (that can cause issues if linking it statically into another DLL)?

We had this patch at MSYS2 for years and I'm not aware of any issues with the static library.
I think the library looks fine:

$ nm lib/liblibclang.a | grep __imp_
                 U __imp___acrt_iob_func
                 U __imp___acrt_iob_func
                 U __imp_GetModuleFileNameA
                 U __imp_VirtualQuery
                 U __imp___acrt_iob_func
                 U __imp___acrt_iob_func
                 U __imp___acrt_iob_func

We had this patch at MSYS2 for years and I'm not aware of any issues with the static library.
I think the library looks fine:

$ nm lib/liblibclang.a | grep __imp_
                 U __imp___acrt_iob_func
                 U __imp___acrt_iob_func
                 U __imp_GetModuleFileNameA
                 U __imp_VirtualQuery
                 U __imp___acrt_iob_func
                 U __imp___acrt_iob_func
                 U __imp___acrt_iob_func

What about llvm-readobj --coff-directives | grep -i export:? The effect is often very subtle - if you build another DLL, that has no explicit dllexports of its own but rely on the default of exporting all symbols - it fails if a statically linked dependency contains explicit dllexports and only exports the dependency's symbols.

bin/llvm-readobj --coff-directives lib/liblibclang.dll.a | grep -i export shows nothing.

bin/llvm-readobj --coff-directives lib/liblibclang.dll.a | grep -i export shows nothing.

That's the import library, not the static library.

Sorry, pasted wrong command. I was curious if import library has it (since static one did not) but in the end neither import nor static library shows any export.

mstorsjo accepted this revision.Sep 12 2020, 7:00 AM

LGTM then! Can apply it a bit later.

This revision is now accepted and ready to land.Sep 12 2020, 7:00 AM
This revision was automatically updated to reflect the committed changes.