Skip to content

Conversation

@nagisa
Copy link
Member

@nagisa nagisa commented Nov 10, 2025

In libloading 0.9 the argument bound changed from AsRef<OsStr> to libloading::AsFilename. This was necessary in order to enable compilation of libloading for usecases that cannot depend on libstd. libloading::AsFilename supports most of the same types, but cannot be implemented generally for any T: AsRef<OsStr> due to the orphan rule.

This makes the generated code support both 0.8 and 0.9 versions of libloading transparently, and at the same time it also reduces the number of different instantiations of Library::new.

When bindgen is adjusted to work with libloading 0.9 only, it will be worthwhile to adjust the generation of from_library to use c"string" literals over b"string\0" ones as those can forgo any runtime checking of the argument(s). However we can't do it right while libloading 0.8 is still supported.

In libloading 0.9 the argument bound changed from `AsRef<OsStr>` to
`libloading::AsFilename`. This was necessary in order to enable
compilation of libloading for usecases that cannot depend on libstd.
`libloading::AsFilename` supports most of the same types, but cannot be
implemented generally for any `T: AsRef<OsStr>` due to the orphan rule.

This makes the generated code support both 0.8 and 0.9 versions of
libloading transparently, and at the same time it also reduces the
number of different instantiations of `Library::new`.

When bindgen is adjusted to work with libloading 0.9 only it will be
worthwhile to adjust the generation of `from_library` to use `c"string"`
literals over `b"string\0"` ones as those can forgo any runtime checking
of the argument(s). However we can't do it right while libloading 0.8 is
still supported.
@emilio emilio added this pull request to the merge queue Nov 10, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 10, 2025
@emilio emilio added this pull request to the merge queue Nov 10, 2025
@emilio
Copy link
Contributor

emilio commented Nov 10, 2025

I think the failure was spurious, trying again.

Merged via the queue into rust-lang:main with commit 5813198 Nov 10, 2025
51 checks passed
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.

2 participants