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

Honor includes in partial_dependency of externals dependencies #14318

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bruchar1
Copy link
Member

@bruchar1 bruchar1 commented Mar 3, 2025

This is different than the approach in #10122, as it doesn't interfere with the order of cflags. It only return a subset of them, in the case the dependency is an external dependency, and partial_dependency requests includes but not compile_args.

@bruchar1 bruchar1 requested a review from jpakkane as a code owner March 3, 2025 16:35
@bruchar1 bruchar1 force-pushed the partial-dep-keep-includes branch from 4b97885 to 736f06e Compare March 3, 2025 16:36
@@ -420,13 +420,14 @@ def get_partial_dependency(self, *, compile_args: bool = False,
new = copy.copy(self)
new._id = uuid.uuid4().int
if not compile_args:
new.compile_args = []
if includes:
new.compile_args = [c for c in self.compile_args if c.startswith('-I')]
Copy link
Member

Choose a reason for hiding this comment

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

That's not sufficient, at the very least this needs to be c.startswith(('-I', '/I', '-isystem', '-idir-after')), but even that probably isn't sufficient.

I'm also really, really, hesitant to do this in general, since the only valid case where a we could get a raw include is from pkg-config (or maybe CMake?). I'd tried to fix this previously and ran into pkgconf bugs on mingw: #10122

At the very least I think this should be limited to pkg-config dependencies.

Copy link
Member

Choose a reason for hiding this comment

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

I was actually thinking about that PR this weekend

Copy link
Member Author

Choose a reason for hiding this comment

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

I see... But OTOH, it will not change the behavior if compile_args is true. The only thing it changes is when you request includes but not compile_args.

Not sure about -isystem and -idirafter. Should includes from a dependency include system dirs? For /I, I though it was already replaced by -I by meson, but I may be wrong... The only thing I know is that pkgconf --cflags-only-I will only keep arguments beginning with -I.

Copy link
Member Author

Choose a reason for hiding this comment

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

I proposed this because I get caught this morning, trying to use the includes from a dependency. I forgot it was only working for internal dependencies...

Copy link
Member

Choose a reason for hiding this comment

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

My concern is it changes the behavior of a declare_dependency()

x = declare_dependency(compile_args : ['-Dfoo', '-Ibar']).partial_dependency(include_directories : true)

Currently gives an empty declare_dependency. This is what we intend, we don't support putting -I flags in compile_args, you get to keep the pieces if you do that.

Copy link
Member Author

Choose a reason for hiding this comment

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

This wouldn't change, since my changes only apply to external dependencies. Behavior of internal_dependencies remains the same.

Copy link
Member

Choose a reason for hiding this comment

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

hmmm, I'm still not sure. I'll have a look at what ends up here and then go from there.

Either way a test would be good. There might be something in that PR I linked you could steal.

@bruchar1 bruchar1 force-pushed the partial-dep-keep-includes branch from 736f06e to ae506e9 Compare March 3, 2025 19:28
@bonzini
Copy link
Collaborator

bonzini commented Mar 14, 2025

I think, generally speaking, extracting includes from a dependency is a bad idea. For example glib has -mms-bitfields in the compile-time arguments and extracting includes would leave that out, thus compiling with a different ABI.

In fact, I would rather deprecate includes and make compile_args return includes even for internal dependencies...

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.

3 participants