Skip to content
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

Meta issue to track changes for adding plugin and LLVM_BUILD_LLVM_DYLIB support for Windows #109483

Open
21 of 40 tasks
fsfod opened this issue Sep 20, 2024 · 4 comments
Open
21 of 40 tasks
Labels
cmake Build system in general and CMake in particular metabug Issue to collect references to a group of similar or related issues. platform:windows

Comments

@fsfod
Copy link
Contributor

fsfod commented Sep 20, 2024

This is meta issue to track adding support for building LLVM and Clang as a shared library on windows and to also allow the use on plugins for Support clang plugins on Windows GSOC project. This will mostly be achieved by adding explicit visibility macros to public API surface that will dllexport'ed. These changes will also benefit non windows platforms by reducing the numbers of exported symbols when the default symbol visibility is set to hidden at a latter time.
Some rational for these changes is explained in this old LLVM discourse post Supporting LLVM_BUILD_LLVM_DYLIB on Windows.

With the current code merged in it is possible build a LLVM DLL using clang-cl, but not all the required symbols exported yet so tools aren't buildable. A branch with most of the changes from the open PR's merged in can be found here along with full visibility macros to create a working windows build with working plugins for LLVM and Clang. The CMake options to use are -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_BUILD_LLVM_DYLIB_VIS=ON -DLLVM_LINK_LLVM_DYLIB=ON -DCLANG_LINK_CLANG_DYLIB=ON

LLVM

Clang

Clang Tooling Fixes and improvements

  • Update Clang to store source location for explicit function template instantiation definitions and declarations so tool can annotate them and not guess
  • Make FrontendAction::BeginSourceFile virtual so proxy Actions work correctly
  • Fix non usable API in FixItRewriter to access computed changes without writing a file
@EugeneZelenko EugeneZelenko added cmake Build system in general and CMake in particular platform:windows and removed new issue labels Sep 20, 2024
fsfod added a commit to fsfod/llvm-project that referenced this issue Oct 27, 2024
Use LLVM_ALWAYS_EXPORT for __jit_debug_descriptor and __jit_debug_register_code so
there exported even if LLVM is not built as a shared library.

This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and plugins on windows llvm#109483.
fsfod added a commit to fsfod/llvm-project that referenced this issue Oct 28, 2024
Use LLVM_ALWAYS_EXPORT for __jit_debug_descriptor and __jit_debug_register_code so
there exported even if LLVM is not built as a shared library.

This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and plugins on windows llvm#109483.
fsfod added a commit to fsfod/llvm-project that referenced this issue Nov 5, 2024
Use LLVM_ALWAYS_EXPORT for __jit_debug_descriptor and __jit_debug_register_code so
there exported even if LLVM is not built as a shared library.

This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and plugins on windows llvm#109483.
@annamthomas
Copy link
Contributor

hi @fsfod , I'm having trouble building my local downstream fork of LLVM which uses dynamic build and link (i.e. these options are present: -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON).

If I revert back to before the first change landed in this series, it builds completely fine.
The reason is that we have some dynamic dependencies between our downstream library and LLVM and when building those files, it complains of same issue as reported here: #107687

i.e.

[02:35:10] #include "llvm/CodeGen/GenVT.inc"
[02:35:10]          ^~~~~~~~~~~~~~~~~~~~~~~~
[02:35:10] 1 error generated.

Is there any workarounds you can suggest for this? I've tried adding the -DLLVM_BUILD_LLVM_DYLIB_VIS=ON but it does not help.

@fsfod
Copy link
Contributor Author

fsfod commented Nov 5, 2024

I'm not sure why my changes would cause that file not to be generated. I did notice there was a merged PR thats looks similar to your issue #109306

@annamthomas
Copy link
Contributor

I'm on truck but that didn't fix it.

After multiple iterations, what I see finally helped is reverting the change:
283c2c8: "[TableGen] Add explicit symbol visibility macros to code generated (#107873)"

And I can build on trunk. How does the visibility macros work actually?

@fsfod
Copy link
Contributor Author

fsfod commented Nov 5, 2024

For non windows and i think mingw it would be turned in to __attribute__((visibility("default"))) which is redundant atm because the default symbols visibility has not yet been changed to hidden. On windows platforms it should be empty unless LLVM_BUILD_LLVM_DYLIB_VIS is used.

@EugeneZelenko EugeneZelenko added the metabug Issue to collect references to a group of similar or related issues. label Nov 5, 2024
vgvassilev pushed a commit that referenced this issue Nov 7, 2024
Use LLVM_ALWAYS_EXPORT for __jit_debug_descriptor and
__jit_debug_register_code so there exported even if LLVM is not built as
a shared library.

This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and plugins on
windows #109483.
s-perron pushed a commit to s-perron/llvm-project that referenced this issue Nov 7, 2024
)

Use LLVM_ALWAYS_EXPORT for __jit_debug_descriptor and
__jit_debug_register_code so there exported even if LLVM is not built as
a shared library.

This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and plugins on
windows llvm#109483.
Groverkss pushed a commit to iree-org/llvm-project that referenced this issue Nov 15, 2024
)

Use LLVM_ALWAYS_EXPORT for __jit_debug_descriptor and
__jit_debug_register_code so there exported even if LLVM is not built as
a shared library.

This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and plugins on
windows llvm#109483.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmake Build system in general and CMake in particular metabug Issue to collect references to a group of similar or related issues. platform:windows
Projects
None yet
Development

No branches or pull requests

3 participants