[glib: 1/2] meson: Check rres.compiled() before calling rres.returncode()




commit 07fb19ee6eca1e0cac72656b13b80ec297244ba9
Author: illiliti <illiliti protonmail com>
Date:   Fri May 6 23:27:03 2022 +0300

    meson: Check rres.compiled() before calling rres.returncode()
    
    As per meson spec, returncode() produces unspecified data if
    compiled() == false. Check compiled() first to avoid relying
    upon unspecified data.
    
    In addition, muon -- an implemetation of meson written in C goes
    further and forbids returning unspecified data. This is a good
    decision, but also makes it harder to support applications which
    wrongly use meson API. Therefore, application needs to be fixed.

 gmodule/meson.build | 2 +-
 meson.build         | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/gmodule/meson.build b/gmodule/meson.build
index f0e7e12a1a..e4c1023ec2 100644
--- a/gmodule/meson.build
+++ b/gmodule/meson.build
@@ -30,7 +30,7 @@ if g_module_impl == 'G_MODULE_IMPL_DL'
     rres = cc.run(dlopen_dlsym_test_code,
                   dependencies : libdl_dep,
                   name : 'dlsym() preceding underscores')
-    if host_system == 'windows' or rres.returncode() == 0
+    if host_system == 'windows' or (rres.compiled() and rres.returncode() == 0)
       g_module_need_uscore = 1
     endif
   else
diff --git a/meson.build b/meson.build
index 7e1b433729..13f28638a6 100644
--- a/meson.build
+++ b/meson.build
@@ -1714,7 +1714,7 @@ va_list_val_copy_prog = '''
 
 if cc_can_run
   rres = cc.run(va_list_val_copy_prog, name : 'va_lists can be copied as values')
-  glib_va_val_copy = rres.returncode() == 0
+  glib_va_val_copy = rres.compiled() and rres.returncode() == 0
 else
   glib_va_val_copy = meson.get_cross_property('va_val_copy', true)
 endif
@@ -1993,7 +1993,7 @@ stack_grows_check_prog = '''
 
 if cc_can_run
   rres = cc.run(stack_grows_check_prog, name : 'stack grows check')
-  growing_stack = rres.returncode() == 0
+  growing_stack = rres.compiled() and rres.returncode() == 0
 else
   growing_stack = meson.get_cross_property('growing_stack', false)
 endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]