meson icon indicating copy to clipboard operation
meson copied to clipboard

Subprojects can only be built for the host machine

Open dcbaker opened this issue 3 years ago • 8 comments

Discussed in https://github.com/mesonbuild/meson/discussions/11120

Originally posted by LunarLambda November 30, 2022 Project A can be cross-compiled (it's a library for command-line parsing), so does not specify native: true.

Project B must be cross-compiled (single-platform embedded project), but wants to use Project A as a subproject dependency for native: true executables.

Is there any way for Project B to tell meson it should build Project A using the native compiler?

Or would Project A need to expose a custom build option (i.e. -Dnative=true), or would it need to expose two dependencies (one cross, one native)

Something like subproject(..., native: true) would be nice, however I can see this clashing with the rule of "every subproject is executed only once", as well as fallback subprojects used with wraps.

dcbaker avatar Nov 30 '22 19:11 dcbaker

It would be nice to maybe use this time to come up with something much easier to understand than native: true | false (deprecation). For instance, subproject(..., native: true) would look a whole lot better as subproject(..., machines: [host_machine, build_machine]).

Every time I deal with native: true | false I have to go consult the docs.

But maybe now is not the time since I know @dcbaker has had some qualms about the way machines are currently done given what systemd has to deal with.

tristan957 avatar Nov 30 '22 20:11 tristan957

It is definitely not going to yield an array of subprojects.

eli-schwartz avatar Nov 30 '22 20:11 eli-schwartz

Good point.

Maybe subproject(..., machine: build_machine)

tristan957 avatar Nov 30 '22 20:11 tristan957

I had thought about having machines : ['build', 'host'] as an option, but in that case I thought the better solution is to return a special type that can act as either a host or a build as appropriate, kinda like both_libraries, as that would make it 100% backwards compatible

dcbaker avatar Nov 30 '22 21:11 dcbaker

or possibly machine: Literal['host', 'build', 'both'] = 'host'

dcbaker avatar Nov 30 '22 21:11 dcbaker

Are you using 'build' and 'host' so someone doesn't supply target_machine?

tristan957 avatar Nov 30 '22 21:11 tristan957

among other things, yes. but also 'both' is more ergonomic than [host_machine, build_machine]

dcbaker avatar Nov 30 '22 21:11 dcbaker

Your proposal seems reasonable.

tristan957 avatar Nov 30 '22 22:11 tristan957