This is a hack that, combined with g-ir-scanner-wrapper, allows us to put /usr/lib inside LD_LIBRARY_PATH before all the other paths that g-ir-scanner appends. This is very important, because if we don't put /usr/lib first, the cross base will be first and during certain circumstances (musl, cross-endian) the compiler will fail to execute. We cannot use another way to append it, because we don't want to put /usr/lib inside the library paths for scanning - we don't want the gi scanner to process any of these libs. We just want the native executables to run correctly. As for using the literal LD_LIBRARY_PATH inside the environment - the scanner will actually read it, but it will put it at the *end*, which does not help us. Ping 'q66 ' for any questions. --- a/giscanner/ccompiler.py +++ b/giscanner/ccompiler.py @@ -180,6 +180,7 @@ class CCompiler(object): runtime_path_envvar = [] runtime_paths = [] + extra_ld_libpath = 'GI_SCANNER_EXTRA_LD_LIBRARY_PATH' if os.name == 'nt': runtime_path_envvar = ['LIB', 'PATH'] @@ -234,6 +235,12 @@ class CCompiler(object): else: os.environ[envvar] = os.pathsep.join(runtime_paths) + # extra paths to prepend, for cross-compiling + if extra_ld_libpath in os.environ: + os.environ[envvar] = os.pathsep.join([ + os.environ[extra_ld_libpath], os.environ[envvar] + ]) + def get_external_link_flags(self, args, libraries): # An "external" link is where the library to be introspected # is installed on the system; this case is used for the scanning