Skip to content

bindgen and Windows build (for conda-forge packet manager) #179

@jcamiel

Description

@jcamiel

Hi, I'm one of the maintainer of a Hurl, happy user of the libxml crates since a few years.

This issue is just for getting some advices and help, fell free to close it after discussion!

Hurl is avaible as packet for many platforms and we've just published a new version 7.0.0. This new version uses libxml and, for the first time, the "bindgen way" of generating the libxml binding.
For the moment, everythin looks OK (for instance, on macOS, Hurl 7.0.0 is available through brew without anny issue apart adding a new dependency on libclang).

Hurl is also available for macOS (arm64 & x86), Linux (arm64 & x86) and Windows (x86) through conda-forge.

For the 7.0.0 update, I strugle to make the new conda-forge version: evrything is OK for Linux and macOS, but the conda-forge "recipe" (a declarative file about how to build Hurl) is not builing on Windows.

You can see some logs here, the gist of it is this kind of error when trying to build libxml crate:

error[E0080]: evaluation of constant value failed
    --> D:\bld\hurl_1753997882865\work\target\release\build\libxml-71faa281837ea7b0\out/bindings.rs:5008:37
     |
5008 |   ["Size of _xmlParserNodeInfoSeq"][::std::mem::size_of::<_xmlParserNodeInfoSeq>() - 24usize];
     |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `16_usize - 24_usize`, which would overflow

In the binding.rs file, this corresponds to this check on struct layout:

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _xmlParserNodeInfoSeq {
  pub maximum: ::std::os::raw::c_ulong,
  pub length: ::std::os::raw::c_ulong,
  pub buffer: *mut xmlParserNodeInfo,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
  ["Size of _xmlParserNodeInfoSeq"][::std::mem::size_of::<_xmlParserNodeInfoSeq>() - 24usize];
  ["Alignment of _xmlParserNodeInfoSeq"][::std::mem::align_of::<_xmlParserNodeInfoSeq>() - 8usize];
  ["Offset of field: _xmlParserNodeInfoSeq::maximum"]
    [::std::mem::offset_of!(_xmlParserNodeInfoSeq, maximum) - 0usize];
  ["Offset of field: _xmlParserNodeInfoSeq::length"]
    [::std::mem::offset_of!(_xmlParserNodeInfoSeq, length) - 8usize];
  ["Offset of field: _xmlParserNodeInfoSeq::buffer"]
    [::std::mem::offset_of!(_xmlParserNodeInfoSeq, buffer) - 16usize];
};

What I understand (I'm clearly not in my comfort zone) is that the binding.rs check expects that ::std::os::raw::c_long is 8 bytes, whereas, as I understand, ::std::os::raw::c_long should be 4 bytes on Windows targets with msvc compiler, which conda-forge uses.

My questions:

  • in your comprehension, is it normal that this check fails for Windows and msvc compiler? I know that you build in CI for Windows target so I strugle to understand why this check can't pass on conda-forge CI/CD
  • if I manage to disable this check (I think I can patch the Hurl recipe to set .layout_tests(false) in libxml crate build.rs), it will compile (I hope) but will it work ? Will the Hurl binary panic as soon as it uses libxml call?
  • apart from patching some code, do you see anything I can try to make the build work

Once again, this is not an issue, just a request for advice and recommendation. Any help even minimal is welcome,

Thanks a lot!

Jc

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions