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

Start adding native : 'both' #12022

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

dcbaker
Copy link
Member

@dcbaker dcbaker commented Jul 21, 2023

This is based on top of #11981

This adds a new value to the native field of the add_languages() and add_*_args() functions. This allows targeting both the build and host machine explicitly, instead of implicitly in the case of add_languages(), or with two calls to add_*_args().

This is a first set of patches, I'm working toward extending both dependency() and the build_target() family to accept this as well, to simplify handling cases of needing both a host and a build dependency/target

@dcbaker dcbaker requested a review from jpakkane as a code owner July 21, 2023 18:47
@mattst88
Copy link
Contributor

mattst88 commented Aug 9, 2023

This is needed for cross-compiling Mesa. Could someone give it a review?

@@ -2,9 +2,12 @@ project('add language', 'c')

test('C', executable('cprog', 'prog.c'))

assert(add_languages('cpp', native: false), 'Add_languages returned false on success')
assert(add_languages('cpp', native: 'both'), 'Add_languages returned false on success')
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't that fail when not cross compiling?

Copy link
Member

Choose a reason for hiding this comment

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

Hm, better to accept it indeed, just like we allow native: true and native: false to mean the same thing when not cross compiling. But maybe that should be said in doc explicitly.

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've updated the docs to be explicit that in a host == build configuration, that all values to native have the same meaning.

native = kwargs['native']
if native is InterpreterMachineChoice.BOTH:
self._add_global_arguments(node, self.build.global_args[MachineChoice.HOST], args[0], kwargs)
self._add_global_arguments(node, self.build.global_args[MachineChoice.BUILD], args[0], kwargs)
Copy link
Member

Choose a reason for hiding this comment

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

Wondering if this would duplicate all args when doing a native build, because in that case HOST and BUILD machines are the same, right?

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 thought that at first too, and added a bunch of code, only to discover that no, it doesn't. I've added a test in the lastest version to ensure that.

@dcbaker dcbaker force-pushed the wip/2023-07/native-both branch from bb501ad to 76623b2 Compare August 9, 2023 17:23
@dcbaker
Copy link
Member Author

dcbaker commented Aug 9, 2023

I still haven't added the necessary skip test calls to get the cross only environments passing, just rebased and tried to address comments.

@dcbaker dcbaker force-pushed the wip/2023-07/native-both branch from 76623b2 to 46e2c61 Compare August 9, 2023 17:50
@Nomura-RH
Copy link
Contributor

Nomura-RH commented Aug 10, 2023

I'm working toward extending both dependency() and the build_target() family to accept this as well, to simplify handling cases of needing both a host and a build dependency/target

Forgive me for breaking into the discussion. Would that solve #10947?

@dcbaker
Copy link
Member Author

dcbaker commented Aug 10, 2023

@Nomura-RH not inherently, but it's something I want to solve to make dependency both work, so It's on my list of things to do.

@dcbaker dcbaker force-pushed the wip/2023-07/native-both branch 3 times, most recently from 676851f to 2a8fa76 Compare November 30, 2023 18:11
mesonbuild/interpreter/type_checking.py Outdated Show resolved Hide resolved
mesonbuild/interpreter/type_checking.py Outdated Show resolved Hide resolved
@dcbaker dcbaker force-pushed the wip/2023-07/native-both branch from 2a8fa76 to ee83941 Compare November 30, 2023 20:34
@tristan957
Copy link
Contributor

This PR looks good to me

@dcbaker dcbaker added this to the 1.4.0 milestone Dec 4, 2023
This allows at the interpreter level to specify that we want both the
host and build machine (if we're cross compiling). We don't want to pass
this out of the interpreter level, however, since this is an abstraction
in the interpreter to simplify cases like:
```meson
add_languages('c', native : true)
add_languages('c', native : false)
```
to
```
add_languages('c', native : 'both')
```
(plus other things later)
This keeps the behavior of not setting the `native` keyword argument,
but with an explicit way to to ask for both. As an added advantage we
can simplify things, and get rid of a warning abut not setting `native`.
This allows for arguments that are needed for both machines to be
passed to both at the same time. This can be helpful if when cross
compiling, when something like a `-D` option needs to be the same for
the host and the build targets.
@dcbaker dcbaker force-pushed the wip/2023-07/native-both branch from ee83941 to 66e5c4b Compare December 19, 2023 18:26
@kusma
Copy link
Contributor

kusma commented Jun 6, 2024

Any reason for this being stalled? We're interested in using libclc in Mesa to precompile some shaders for Panfrost, and it seems this is the only viable approach to not have to duplicate all involved dependencies and build-rules etc...

@bruchar1 bruchar1 removed this from the 1.4.0 milestone Jun 6, 2024
@tristan957
Copy link
Contributor

@kusma, dcbaker has been rather busy, so this PR has been stalled.

Sonicadvance1 added a commit to Sonicadvance1/FEX that referenced this pull request Aug 31, 2024
This is useful for some people.

This doesn't allow building thunks due to the cmake limitation about
tools binaries also getting cross compiled, we need to switch to meson
if we want that, since they recently started fixing this
mesonbuild/meson#12022

But that's an okay limitation for now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants