aravis icon indicating copy to clipboard operation
aravis copied to clipboard

g-ir-scanner calls native compiler with cross-compiler options

Open eudoxos opened this issue 4 years ago • 11 comments

https://github.com/AravisProject/aravis/blob/c139db0127a8a0d10e9c7cf87c81c9fd5f963030/meson.build#L34

I am using x86_64-linux-gnu-gcc cross-compiler under Linux, it is version 9.3.0, and the -Wenum-conversion is not understood (it is understood by the native gcc 9.3.0, curiously):

x86_64-linux-gnu-gcc: error: unrecognized command line option ‘-Wenum-conversion’; did you mean ‘-Wno-conversion’?

eudoxos avatar Jul 25 '21 07:07 eudoxos

Hi,

The point of cc.get_supported_arguments is to filter the options to the one actually supported by the compiler. Which means -Wenum-conversion should not be passed to gcc if it is not supported. Are you trying to use meson cross compilation ?

EmmanuelP avatar Jul 25 '21 07:07 EmmanuelP

Are you trying to use meson cross compilation ?

Yes, exactly. As described here: https://github.com/eudoxos/aravis/blob/winbuild/README.md#cross-compilation-for-windows

eudoxos avatar Jul 25 '21 10:07 eudoxos

Unless I have misunderstood crossroad, you are not using meson cross compilation support. I was asking because if meson cross compilation is used, there is a distinction in meson between the native compiler and the cross one, which could explain why the unsupported option is used during compilation.

https://mesonbuild.com/Cross-compilation.html

EmmanuelP avatar Jul 25 '21 17:07 EmmanuelP

crossroad meson will add the --cross-file to (native) meson according to the current platform; the wrapping is here and this is the cross-file toolchain-w64.meson. So it should be running the cross-compiler for the checks (as well as for the compilation). Strange that it fails in this case. I will try to look closer what meson calls.

eudoxos avatar Jul 25 '21 17:07 eudoxos

After a closer look, I understand better now. The failure is when calling (native) g-ir-scanner which passes all flags for the cross-compiler to the native compiler. And as it happens, the cross-compiler does support Wenum-conversion (hence it does not get filtered out by get_supported_arguments) whereas the native gcc internally called by g-ir-scanner does not and fails.

I was misled by the original post seeing x86_64-linux-gnu-gcc (which is native, normally called just gcc ;) ) as opposed to x86_64-w64-mingw32-gcc (which is the cross-compiler).

eudoxos avatar Jul 26 '21 07:07 eudoxos

It seems to be meson's upstream issue here. It takes compile arguments from the dependency (which is aravis_library in this case) but calls native compiler with them. I will see if they can do something about it.

eudoxos avatar Jul 26 '21 07:07 eudoxos

My idea was to use only common warning options for cross-compilation:

  warning_c_args=cc.get_supported_arguments(warning_c_args)
  if meson.is_cross_build()
    native_cc = meson.get_compiler('c', native: true)
    warning_c_args = native_cc.get_supported_arguments(warning_c_args)
  endif

but that is not enough as g-ir-scanner also runs linker, which does not find host libraries, being native linker.

So I'd say for now that introspection is unsupporter for cross-compilation, unless a solution is found.

eudoxos avatar Jul 26 '21 08:07 eudoxos

Did you try to only add '-Wenum-conversion' if the build is native ?

EmmanuelP avatar Jul 26 '21 08:07 EmmanuelP

Did you try to only add '-Wenum-conversion' if the build is native ?

Yes, that is what the extra filtering step above would do. But anyway, the g-ir-scanner will fail at link-time.

eudoxos avatar Jul 26 '21 09:07 eudoxos

What I'm proposing is different:

if not meson.is_cross_build()
  warning_c_args += '-Wenum-conversion`
endif

EmmanuelP avatar Jul 26 '21 09:07 EmmanuelP

That will only for for my particular combination of compilers, unlike the second filter for warning_c_args which I proposed above. But anyway, I'd make introspection off by default for cross-compilation, until it is resolved (on meson side, or wherever the issue stems from).

eudoxos avatar Jul 26 '21 10:07 eudoxos