Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include path in clang_args() ignored #2958

Open
mrjbom opened this issue Oct 18, 2024 · 0 comments
Open

Include path in clang_args() ignored #2958

mrjbom opened this issue Oct 18, 2024 · 0 comments

Comments

@mrjbom
Copy link

mrjbom commented Oct 18, 2024

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 mrjbom closed this as completed Oct 18, 2024
@mrjbom mrjbom reopened this Oct 18, 2024
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

No branches or pull requests

1 participant