From fa7c7d919a8dbac8f09ef7a043e23116d655033d Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 21 Sep 2023 20:45:22 -0700 Subject: rust: properly rematerialize static dependencies as well as dynamic ones Rustc expects to be provided both a search path `-L`, and a link arg `-l kind=libname`, but we don't handle that correctly. Because we combine -L and -l arguments from pkg-config the backend must rematerialize the -L and -l split. We currently don't do this for static archives. --- mesonbuild/backend/ninjabackend.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 3d3eefdcc..a57b249fe 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -2090,13 +2090,14 @@ class NinjaBackend(backends.Backend): if a in rustc.native_static_libs: # Exclude link args that rustc already add by default continue - if a.endswith(('.dll', '.so', '.dylib')): + if a.endswith(('.dll', '.so', '.dylib', '.a', '.lib')): dir_, lib = os.path.split(a) linkdirs.add(dir_) lib, ext = os.path.splitext(lib) if lib.startswith('lib'): lib = lib[3:] - args.extend(['-l', f'dylib={lib}']) + _type = 'static' if a.endswith(('.a', '.lib')) else 'dylib' + args.extend(['-l', f'{_type}={lib}']) elif a.startswith('-L'): args.append(a) elif a.startswith('-l'): -- cgit v1.2.3