Skip to content

WIP: modules/gnome: Set PATH environment variables for dependencies - #16140

Open
lb90 wants to merge 1 commit into
mesonbuild:masterfrom
lb90:generate-gir-ld-library-path
Open

WIP: modules/gnome: Set PATH environment variables for dependencies#16140
lb90 wants to merge 1 commit into
mesonbuild:masterfrom
lb90:generate-gir-ld-library-path

Conversation

@lb90

@lb90 lb90 commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

We set:

  • LD_LIBRARY_PATH on UNIX systems
  • DYLD_LIBRARY_PATH in addition for macOS
  • PATH on Windows

On UNIX systems the rpath also works, but it it's not very reliable outside of controlled systems. Basically, users can set arbitrary LD_LIBRARY_PATHs on their systems, and that takes precedence over rpaths stored in binaries. By setting LD_LIBRARY_PATH we avoid accidentally picking up wrong libraries. See #11119

On Windows there's no rpath, so we have to set PATH to make things work.

Fixes #12850

… target

We set:

 * LD_LIBRARY_PATH on all UNIX systems (macOS included)
 * DYLD_LIBRARY_PATH in addition for macOS
 * PATH on Windows

On UNIX systems the rpath also works, but it it's not very reliable
outside of controlled systems. Basicaly, users can set arbitrary
LD_LIBRARY_PATHs on their systems, which has precedence over rpaths
stored in binaries. By setting LD_LIBRARY_PATH we avoid accidentally
picking up the wrong library. See mesonbuild#11119

On Windows there's no rpath, so we have to set PATH to make things
work.

Fixes mesonbuild#12850
@lb90

lb90 commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

This is all it takes, but ideally we should make a small modification: rather than setting LD_LIBRARY_PATH, we should set a dedicated environment variable (say, GI_SCANNER_LIBRARY_PATH) that g-ir-scanner turns into LD_LIBRARY_PATH before launching the subprocess. Otherwise system g-ir-scanner (aka python) could be run with built libraries (libffi, libssl, etc.)

@lb90

lb90 commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

/cc @amyspark

@amyspark

Copy link
Copy Markdown
Contributor

Otherwise system g-ir-scanner (aka python) could be run with built libraries (libffi, libssl, etc.)

I have definitely seen this happen when building the GStreamer SDK for Linux without a wrapping Docker container, the system Glib takes precedence over the (older) one provided by the SDK.

Comment on lines +1286 to +1289
else:
kwargs['env'].prepend('LD_LIBRARY_PATH', list(libs_paths), ':')
if machine.is_darwin():
kwargs['env'].prepend('DYLD_LIBRARY_PATH', list(libs_paths), ':')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
else:
kwargs['env'].prepend('LD_LIBRARY_PATH', list(libs_paths), ':')
if machine.is_darwin():
kwargs['env'].prepend('DYLD_LIBRARY_PATH', list(libs_paths), ':')
elif machine.is_darwin():
kwargs['env'].prepend('DYLD_LIBRARY_PATH', list(libs_paths), ':')
else:
kwargs['env'].prepend('LD_LIBRARY_PATH', list(libs_paths), ':')

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lb90

lb90 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

rather than setting LD_LIBRARY_PATH, we should set a dedicated environment variable...

Hey, it's already supported! 😊 https://gitlab.gnome.org/GNOME/gobject-introspection/-/blob/1.86.0/giscanner/scannermain.py?ref_type=tags#L177. Added precisely for cross compilation in https://gitlab.gnome.org/GNOME/gobject-introspection/-/commit/48f41930

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gnome.generate_gir cannot run on Windows due to an incomplete PATH variable

2 participants