This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Don't try to build CTTestTidyModule for Windows with dylibs
ClosedPublic

Authored by mstorsjo on Mar 15 2022, 4:45 AM.

Details

Summary

In MinGW mode, it's possible to build LLVM/Clang with
LLVM_LINK_LLVM_DYLIB (which implicitly enables plugins too). Other
existing ways of building plugins on Windows is to build with
LLVM_EXPORT_SYMBOLS_FOR_PLUGINS, where each executable exports its
symbols.

With LLVM_LINK_LLVM_DYLIB, we can't generally skip building plugins
even if they are set up with PLUGIN_TOOL, as some plugins (e.g.
under clang/examples) set up that way do build properly (as
they manually call clang_target_link_libraries, which links in the
libclang-cpp.dll dylib).

For CTTestTidyModule, there's no corresponding dylib that would
provide the same exports.

Alternatively, we could make the condition
if (NOT WIN32 OR LLVM_EXPORT_SYMBOLS_FOR_PLUGINS), as that's the
only way this plugin would be possible to link on Windows.

(Currently, building this plugin with LLVM_EXPORT_SYMBOLS_FOR_PLUGINS
fails to link one symbol though, but in principle, it could
work.)

Diff Detail

Event Timeline

mstorsjo created this revision.Mar 15 2022, 4:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 15 2022, 4:45 AM
mstorsjo requested review of this revision.Mar 15 2022, 4:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 15 2022, 4:45 AM

@rnk Can you have a look at this?

rnk accepted this revision.Mar 21 2022, 1:43 PM

lgtm

This revision is now accepted and ready to land.Mar 21 2022, 1:43 PM
jeremyd2019 added inline comments.
clang-tools-extra/test/CMakeLists.txt
84

I only just noticed this patch, but it feels to me like this was intended to be OR here, because the condition to be avoided seems to be WIN32 AND LLVM_LINK_LLVM_DYLIB, which inverted is NOT WIN32 OR NOT LLVM_LINK_LLVM_DYLIB

mstorsjo added inline comments.Mar 25 2022, 12:09 PM
clang-tools-extra/test/CMakeLists.txt
84

Oh indeed, thanks, good catch! I'll push a patch fixing that.