Add compatibility for glibc version 2.28 #10

Merged
laim-deshaw merged 1 commit from glibc228 into master 2024-07-13 16:11:37 +12:00
laim-deshaw commented 2024-07-13 05:39:19 +12:00 (Migrated from github.com)

This PR adds compatibility for glibc < 2.31, specifically for glibc 2.28. Building this crate on RHEL8 throws the following exception:

$ cargo build 
   Compiling libresolv-sys v0.3.0 (/u/laim/oss/resolv-rs/libresolv-sys)
error: failed to run custom build command for `libresolv-sys v0.3.0 (/u/laim/oss/resolv-rs/libresolv-sys)`

Caused by:
  process didn't exit successfully: `/u/laim/oss/resolv-rs/target/debug/build/libresolv-sys-8929fd21abdc2411/build-script-build` (exit status: 101)
  --- stderr
  Generating binding "resolv.rs" from "/usr/include/resolv.h" ...

  Checking available libresolv adapters to the generated binding "resolv.rs" ...

  Trying "lib.d/lib_234.rs" ...

  """
  error[E0432]: unresolved imports `resolv::RES_TRUSTAD`, `resolv::res_nquery`, `resolv::res_nsearch`
    --> lib.rs:21:5
     |
  21 |     RES_TRUSTAD,
     |     ^^^^^^^^^^^ no `RES_TRUSTAD` in `resolv`
  ...
  37 |     res_nquery,
     |     ^^^^^^^^^^ no `res_nquery` in `resolv`
  38 |     res_nsearch,
     |     ^^^^^^^^^^^ no `res_nsearch` in `resolv`
     |
  help: a similar name exists in the module
     |
  37 |     __res_nquery,
     |     ~~~~~~~~~~~~
  help: a similar name exists in the module
     |
  38 |     __res_nsearch,
     |     ~~~~~~~~~~~~~

  error: aborting due to 1 previous error

  For more information about this error, try `rustc --explain E0432`.
  """

  Trying "lib.d/lib_231.rs" ...

  """
  error[E0432]: unresolved import `resolv::RES_TRUSTAD`
    --> lib.rs:21:5
     |
  21 |     RES_TRUSTAD,
     |     ^^^^^^^^^^^ no `RES_TRUSTAD` in `resolv`

  error: aborting due to 1 previous error

  For more information about this error, try `rustc --explain E0432`.
  """

  thread 'main' panicked at libresolv-sys/build.rs:53:9:
  None of the available adapters compiled successfully!
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Removing the RES_TRUSTAD resolver solves this issue.

This PR adds compatibility for `glibc < 2.31`, specifically for `glibc 2.28`. Building this crate on RHEL8 throws the following exception: ``` $ cargo build Compiling libresolv-sys v0.3.0 (/u/laim/oss/resolv-rs/libresolv-sys) error: failed to run custom build command for `libresolv-sys v0.3.0 (/u/laim/oss/resolv-rs/libresolv-sys)` Caused by: process didn't exit successfully: `/u/laim/oss/resolv-rs/target/debug/build/libresolv-sys-8929fd21abdc2411/build-script-build` (exit status: 101) --- stderr Generating binding "resolv.rs" from "/usr/include/resolv.h" ... Checking available libresolv adapters to the generated binding "resolv.rs" ... Trying "lib.d/lib_234.rs" ... """ error[E0432]: unresolved imports `resolv::RES_TRUSTAD`, `resolv::res_nquery`, `resolv::res_nsearch` --> lib.rs:21:5 | 21 | RES_TRUSTAD, | ^^^^^^^^^^^ no `RES_TRUSTAD` in `resolv` ... 37 | res_nquery, | ^^^^^^^^^^ no `res_nquery` in `resolv` 38 | res_nsearch, | ^^^^^^^^^^^ no `res_nsearch` in `resolv` | help: a similar name exists in the module | 37 | __res_nquery, | ~~~~~~~~~~~~ help: a similar name exists in the module | 38 | __res_nsearch, | ~~~~~~~~~~~~~ error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0432`. """ Trying "lib.d/lib_231.rs" ... """ error[E0432]: unresolved import `resolv::RES_TRUSTAD` --> lib.rs:21:5 | 21 | RES_TRUSTAD, | ^^^^^^^^^^^ no `RES_TRUSTAD` in `resolv` error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0432`. """ thread 'main' panicked at libresolv-sys/build.rs:53:9: None of the available adapters compiled successfully! note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` Removing the `RES_TRUSTAD` resolver solves this issue.
mikedilger commented 2024-07-13 16:12:29 +12:00 (Migrated from github.com)

I moved ResolverOptions into libresolv-sys so it is defined based on your glibc version, that way we could take RES_TRUSTAD out of the 2.28 version while leaving it in the other versions.

I moved ResolverOptions into libresolv-sys so it is defined based on your glibc version, that way we could take RES_TRUSTAD out of the 2.28 version while leaving it in the other versions.
mikedilger commented 2024-07-13 16:46:31 +12:00 (Migrated from github.com)

Great. Now cargo package won't package it. Your commit was fine, then it doesn't like mine, even though I can build it I can't package it.

If you have any ideas I'd appreciate them.

Great. Now cargo package won't package it. Your commit was fine, then it doesn't like mine, even though I can build it I can't package it. If you have any ideas I'd appreciate them.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mikedilger/resolv-rs!10
No description provided.