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

Add specific dependency handling for clang #13134

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

dcbaker
Copy link
Member

@dcbaker dcbaker commented Apr 23, 2024

Clang is fun. It has a C API library and C++ API libraries. It has the following configurations that need to be accounted for:

  • libclang (The C API) can be built as either static or shared, it is the only way to get the C API
  • for C++ you can build clang-cpp, which is always built as shared
  • for c++ you can also get individual libs, which can be built as shared or static, but AFAICT the shared individual libs are not a supported configuration (same as LLVM).

On top of that, to get the Clang Version for the C API you need to resort to some trickery. I've checked the implementation I came up with for clang 6-17 and it works for all of those. For the C++ API it's easy, because the header required is a C++ header.

TODO:

  • Needs tests for the C++ API
  • Needs to have CI skip expectations added

Copy link
Contributor

@tristan957 tristan957 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty reasonable so far.

Comment on lines 617 to 618
Both libclang (the C interface) and the C++ interfaces are supported via the
`language` keyword. The default is to search for the `C++` interface.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why we can't do this for Rust dependencies, @xclaesse.

docs/markdown/Dependencies.md Show resolved Hide resolved
mesonbuild/dependencies/dev.py Outdated Show resolved Hide resolved
mesonbuild/dependencies/dev.py Outdated Show resolved Hide resolved
mesonbuild/dependencies/dev.py Outdated Show resolved Hide resolved
@eli-schwartz
Copy link
Member

/cc @thesamesam

@dcbaker dcbaker force-pushed the submit/clang-dep branch 4 times, most recently from f65099e to 9a5107e Compare July 10, 2024 21:47
Copy link
Contributor

@tristan957 tristan957 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks solid.

docs/markdown/Dependencies.md Outdated Show resolved Hide resolved
docs/markdown/Dependencies.md Show resolved Hide resolved
mesonbuild/dependencies/dev.py Outdated Show resolved Hide resolved
@dcbaker dcbaker force-pushed the submit/clang-dep branch 7 times, most recently from ed30059 to 287c36b Compare July 12, 2024 19:01
run_project_tests.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@thesamesam thesamesam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this, this looks good to me.

@dcbaker dcbaker force-pushed the submit/clang-dep branch from 287c36b to 25c9116 Compare July 12, 2024 20:12
@dcbaker
Copy link
Member Author

dcbaker commented Jul 12, 2024

Now for the fun of getting the CI green.

@dcbaker dcbaker force-pushed the submit/clang-dep branch 7 times, most recently from 7c967db to e2718dc Compare July 15, 2024 13:57
@dcbaker dcbaker force-pushed the submit/clang-dep branch 13 times, most recently from 59050cc to 87afe53 Compare July 18, 2024 16:56
@dcbaker dcbaker force-pushed the submit/clang-dep branch 2 times, most recently from f81683b to 834ef61 Compare September 6, 2024 23:07
This check considers whether `-l{libname}` will find the lib correctly,
and that is true if library *must* be shared as well as if the library
should be shared, but can fall back to static.
…with modules

I don't understand why these wouldn't be used for modules if they exist,
and this breaks Clang, which only sets a global Clang_INCLUDE_DIRS, and
doesn't provide per-module support.
Clang has two ways to be found, CMake, and by hand. Clang has some
hurdles of use because of the way it's installed on many Linux distros,
either in a separate prefix, in a prefix with LLVM, or in a common
prefix, which requires some amount of effort to make it work.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants