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.

Signed-off-by: Pierrick Bouvier <[email protected]>
---
 tests/tcg/meson.build | 13 +++++++++++++
 tests/tcg/test_cc.c   |  7 +++++++
 2 files changed, 20 insertions(+)
 create mode 100644 tests/tcg/test_cc.c

diff --git a/tests/tcg/meson.build b/tests/tcg/meson.build
index 9db0692685f..6fd6f5bd187 100644
--- a/tests/tcg/meson.build
+++ b/tests/tcg/meson.build
@@ -106,6 +106,19 @@ 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', '-r']
+    endif
+
+    cmd = run_command([cc, files('test_cc.c'), check_flags, '-o', '/dev/null'],
+                      check: false)
+    avail = cmd.returncode() == 0
+    cc_from_system = has_cc
+    has_cc = avail
+  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..b8a0dae6c8a
--- /dev/null
+++ b/tests/tcg/test_cc.c
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#include <stdint.h>
+
+int main(void)
+{
+}
-- 
2.47.3


Reply via email to