rust-bindgen icon indicating copy to clipboard operation
rust-bindgen copied to clipboard

Include path in clang_args() ignored

Open mrjbom opened this issue 1 year ago • 0 comments

I am trying to create a binding to a file that should use header files from GCC. I am passing arguments specifying the paths to the header files using clang_args(), however, for some reason this does not work.

let builder = bindgen::Builder::default()
        .clang_args(["--target=x86_64-elf", "-ffreestanding", "-fno-builtin", "-nostdinc"])
        .clang_args(&include_paths_with_isystem)
        .header(buddy_alloc_header_path.display().to_string());

    println!("cargo:warning=Include flags: {:?}", include_paths_with_isystem);

    builder.generate()
        .expect("Failed to generate binding");

Error

cargo:warning=Include flags: ["-isystem /home/oiu/dev/x86_64-elf-13.2.0-Linux-x86_64/bin/../lib/gcc/x86_64-elf/13.2.0/include", "-isystem /home/oui/dev/x86_64-elf-13.2.0-Linux-x86_64/bin/../lib/gcc/x86_64-elf/13.2.0/include-fixed"]

  Failed to generate binding: ClangDiagnostic("/mnt/c/Rust/buddy_alloc_rs/buddy_alloc_sys/buddy_alloc_1.2.0_x86_64-elf-gcc_freestanding/buddy_alloc.h:19:10: fatal error: 'limits.h' file not found\n")

However, a direct clang call with the same flags works well.

clang --target=x86_64-elf -ffreestanding -fno-builtin -nostdinc -isystem /home/oui/dev/x86_64-elf-13.2.0-Linux-x86_64/bin/../lib/gcc/x86_64-elf/13.2.0/include -isystem /home/oui/dev/x86_64-elf-13.2.0-Linux-x86_64/bin/../lib/gcc/x86_64-elf/13.2.0/include-fixed -g -c buddy_alloc_1.2.0.c.h -o aaa.o

Of course, the limits.h file does exist

find /home/oui/dev/x86_64-elf-13.2.0-Linux-x86_64/bin/../lib/gcc/x86_64-elf/13.2.0/include -name limits.h
/home/oiu/dev/x86_64-elf-13.2.0-Linux-x86_64/bin/../lib/gcc/x86_64-elf/13.2.0/include/limits.h

A direct call to the bindgen cli work fine.

mrjbom avatar Oct 18 '24 15:10 mrjbom