Skip to content

detect_include_paths may use a different clang #2682

Open
@workingjubilee

Description

@workingjubilee

Bindgen often is deployed to build code using libclang's dynamic library, set by LIBCLANG_PATH. However, in bindgen, there is this code:

rust-bindgen/bindgen/lib.rs

Lines 824 to 830 in 4f9fa49

let clang = match clang_sys::support::Clang::find(
None,
&clang_args_for_clang_sys,
) {
None => return,
Some(clang) => clang,
};

This starts with the following check:

https://github.com/KyleMayes/clang-sys/blob/b7992e864eaa2c8cb5c014a52074b962f257e29b/src/support.rs#L59-L65

Unfortunately, this means rust-bindgen can easily wind up pulling a different clang than libclang, and it never consults LIBCLANG_PATH. If this is an intended hazard of the detect_include_paths function, then it should be documented appropriately. However, as it can easily cause subtly but hazardously incorrect bindings to be generated, it is likely not intended that this is the default.

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