On Fedora, cross compilers are provided without runtime or header files. Thus, even if program is present, it can't be used to compile files directly. Check this, and fallback on docker if not working.
Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Tested-by: Aniket Sahu <[email protected]> Signed-off-by: Pierrick Bouvier <[email protected]> --- tests/tcg/meson.build | 12 ++++++++++++ tests/tcg/test_cc.c | 9 +++++++++ 2 files changed, 21 insertions(+) create mode 100644 tests/tcg/test_cc.c diff --git a/tests/tcg/meson.build b/tests/tcg/meson.build index ab7090a62fe..9809695f3b8 100644 --- a/tests/tcg/meson.build +++ b/tests/tcg/meson.build @@ -109,6 +109,18 @@ foreach target, plan: tcg_tests cc = find_program(plan['cc'], required : false) cc_from_system = cc.found() has_cc = cc.found() + if has_cc + check_flags = ['-static'] + if target.endswith('softmmu') + check_flags = ['-nostdlib', '-ffreestanding', '-r'] + endif + + cmd = run_command([cc, files('test_cc.c'), check_flags, '-o', '/dev/null'], + check: false) + has_cc = cmd.returncode() == 0 + cc_from_system = has_cc + endif + build_test_depends = [] build_test_depend_files = [] diff --git a/tests/tcg/test_cc.c b/tests/tcg/test_cc.c new file mode 100644 index 00000000000..d3614a01fe6 --- /dev/null +++ b/tests/tcg/test_cc.c @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +/* Include a standard header to make sure cross compiler provides them */ +#include <stdint.h> + +int main(void) +{ + return 0; +} -- 2.43.0
