Skip to content

Conversation

@sp1ritCS
Copy link
Contributor

@sp1ritCS sp1ritCS commented Aug 3, 2025

This was added on dcbaker request[0], but doesn't actually work the way
we need it too, as meson always has too assume the tools from the
pkg-config file are build machine tools.

[0]:mesonbuild#14422 (comment)
@sp1ritCS sp1ritCS requested a review from jpakkane as a code owner August 3, 2025 18:45
@sp1ritCS
Copy link
Contributor Author

sp1ritCS commented Aug 3, 2025

I think I'd be a good idea in the future to replace all the internal use of for_machine: MachineChoice & native: bool with a T.Set[MachineChoice], which explicitly defines what kind of dependencies/tools that particular method may return.

@tp-m
Copy link
Member

tp-m commented Aug 4, 2025

This seems to fix things for GStreamer's cerbero, thank you!

Verified it's using the Meson from this PR:

Running command ['git', 'reset', '--hard', 'refs/pull/14865'] in /builds/tpm/cerbero/cerbero-sources/meson
HEAD is now at 844172d67 gnome: Ensure g-ir-{scanner,compiler} have the correct architecture

# Check if pkgconfig has a variable
dep = self.dependency(depname, native=for_machine is MachineChoice.BUILD,
required=False, wanted=wanted)
dep = self.dependency(depname, native=True, required=False, wanted=wanted)
Copy link
Member

Choose a reason for hiding this comment

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

This looks wrong to me, since now pkg-config will return a program targeting the build machine even when it's been explicitly requested to get one for the host machine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The way meson handles find_program, we can't rely on anything being the of the machine type we requested (a find_program with HOST will still end up falling to the system binaries and a one with BUILD will still pick a overridden one for the HOST). IMO this has to change, which is why I talked about replacing all use of native & for_machine with a T.Set[MachineChoice], but that clearly shouldn't be part of a rc bugfix.

The issue specifically is, that meson just passes the path pointed at by the pkg-config into ExternalProgram, which will simply assume that the executable pointed to by the path is executable by the build machine, which it may not if it comes from a HOST dependency.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It is weird but it makes sense, a tool should preferrably be built for the build machine. You could have an extra argument support_cross: bool(*) and do native=support_cross or for_machine is MachineChoice.bool. But if support_cross is always true, one might as well write native=True.

(*) True if the output is machine-independent or can be tailored to an arbitrary machine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bonzini: Isn't that functionally the same as my proposed T.Set[MachineChoice]?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would leave it as is, no problem for me.

scan_command += ['--quiet']

if state.environment.is_cross_build() and state.environment.need_exe_wrapper():
if state.environment.is_cross_build() and state.environment.need_exe_wrapper() and giscanner.for_machine is MachineChoice.BUILD:
Copy link
Member

Choose a reason for hiding this comment

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

What is going on here? There should never need to be an exe_wrapper for the build machine, the build machine is the machine that is natively running the compilation. the exe_wrapper is to allow the build machine to run binaries compiled for the host machine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This checks if the giscanner is from the build machine (right now its a python script with a native module, so this should always be the case [but I plan to change that]).

The exe_wrapper check is to pass the --use-binary-wrapper ... --{begin,end}-binary-wrapper-args to the build machine g-ir-scanner if that is required. So meson invokes the g-ir-scanner on the build machine directly and it makes use of the exe_wrapper whenever it needs to itself internally.

@eli-schwartz
Copy link
Member

Given that #14908 required reverting part of the underlying PR this fixes, we should probably then also revert 5e627c entirely for now and revisit things after the release is out.

@jpakkane
Copy link
Member

I created a revert MR for this in #14929. If someone does not have a better course of action, I'll merge it tomorrow and then create rc3.

@bonzini
Copy link
Collaborator

bonzini commented Aug 19, 2025

@sp1ritCS can you rebase #14930 to include #14929 + all dependencies? Closing this in the meanwhile.

@bonzini bonzini closed this Aug 19, 2025
@bonzini bonzini removed this from the 1.10 milestone Aug 19, 2025
@eli-schwartz eli-schwartz reopened this Aug 19, 2025
@eli-schwartz eli-schwartz added this to the 1.9 milestone Aug 19, 2025
@jpakkane jpakkane force-pushed the master branch 2 times, most recently from 00d6953 to 6447832 Compare August 19, 2025 20:51
@bonzini bonzini modified the milestones: 1.9, 1.10 Aug 20, 2025
@bonzini
Copy link
Collaborator

bonzini commented Aug 20, 2025

Original patch reverted in #14929. I think this pull request should be closed (it doesn't even apply) and whatever it did reapplied in a respin of #14930.

@sp1ritCS
Copy link
Contributor Author

Part of #14933

@sp1ritCS sp1ritCS closed this Aug 20, 2025
@bonzini bonzini removed this from the 1.10 milestone Aug 24, 2025
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.

7 participants