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
Embedded GCC has_link_argument does not work because test program fails to link #10957
Comments
Ended up specifying # Assume GNU binutils (ld.bfd)
if find_program('ld', version: '>=2.39', required: false).found()
add_project_link_arguments('-Wl,--no-warn-rwx-segments', language: 'c')
endif If one overrides |
It sounds like that's probably a good idea to do in general, at least have some way to set up a cross environment that defines missing bits needed to correctly link under embedded environments. But indeed I don't think meson currently allows that. I think this may solely affect has_link_argument, e.g. cc.links would just use your own presumably embedded-compatible code. You could roll your own check with cc.links to check your own minimal source code and see if that flag works? But also, patches welcome to extend meson to handle this natively or with a small bit of cross file prompting. |
What would be a good way to improve meson's support there? Should I can see arguments for and against either approach, I'm not sure which would be considered more sound and compatible. |
I think extending the code used would be the best option. That allows people to write the obvious code in meson.build to check options etc. without having to manually construct tests via looking up the linker. Plus, it's related to the toolchain used, not the project, so keeping it as toolchain info seems more elegant. |
Right. Should it go in I think I can try my hand at a patch that allows setting flags and code for compile and link tests. On that note, if such properties are added, should they also be considered for |
I didn't end up finding the time to work on a PR for this sadly, too much on my plate with life currently. Would still like to see it land in meson at some point. cc.links() does make an acceptable workaround, since my project only has one target and toolchain. |
If I put this into the cross file:
the check for
This would return success, if it would not be for
What do you think? |
We usually prefer to fix things in core rather than adding more toggles for people to twiddle. The latter tends to lead to bad usability via a gajillion choices. Is there a way to make the check program detect this case and automatically do the necessary steps to make it work out of the box? |
Describe the bug
meson.get_compiler('c').has_link_argument('-Wl,--no-warn-rwx-segments')
doesn't work,C compiler is
arm-none-eabi-gcc (Arch Repository) 12.2.0
.Depending on how meson's detection works, it might be failing because the cross compiler can't simply produce a 'do nothing' executable without extra linker arguments, the way the native (
x86_64
) compiler can:vs
which works.
In the case of
arm-none-eabi-gcc
, the above do-nothing test can be fixed by specfiying-specs=nosys.specs
(assuming it's using newlib /c_stdlib
is not overriden), or changing the supplied source code to includevoid _exit(int x) {}
, however I am not sure if meson allows overriding compiler test behaviour like that.To Reproduce
Expected behavior
meson properly detects the availability of
--no-warn-rwx-segments
.system parameters
meson --version
0.63.3ninja --version
if it's a Ninja build 1.11.1The text was updated successfully, but these errors were encountered: