vulkan-go / vulkan

Vulkan API bindings for Go programming language
MIT License
742 stars 55 forks source link

Unable to generate bindings on Linux #46

Open jclc opened 4 years ago

jclc commented 4 years ago

I would like to update the bindings to the latest version but the code generation script fails with the following error:

[jclc@nakkimuki vulkan]$ make
c-for-go -ccdefs -out .. vulkan.yml
  processing vulkan.yml ⠋[ERR] vulkan/vk_platform.h:71:10: include file not found: stddef.h. Search paths:
    /usr/include
    /home/jclc/devel/vulkan
    /usr/include
    /home/jclc/devel/vulkan (and 1 more errors)
make: *** [Makefile:2: all] Error 1

I believe this was related to a c-for-go issue where the script expects all headers to be located in /usr/include. On Linux compiler-specific headers such as this are located in subdirectories such as /lib/gcc/<target>/<version>/include for gcc and /lib/clang/<version>/include for clang to avoid conflicts.

The code generation script should query the compiler for include directories instead of assuming only one path.

jclc commented 4 years ago

Turns out c-for-go supported compiler-specific include dirs all along, I just had to enable the -ccincl flag! The only problem is that the resultant files now have int and uint in place of every int64 and uint64, even when the headers clearly use explicit types like https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkDeviceSize.html. Any clue what could be causing this?

jclc commented 4 years ago

There are also some errors related to new types/enums/functions, it is unclear to me how vulkan.yml should be edited to accomodate changes. Perhaps a short contribution guide could be added in the readme?

nickswang commented 3 years ago

@jclc Have you made any progress with this? The Vulkan version supported by the bindings here is officially 1.18

jclc commented 3 years ago

The issue here is that the bindings generator https://github.com/xlab/c-for-go isn't producing the same results on different operating systems. I haven't had the time to delve deeper into the root cause of the issue.

xlab commented 3 years ago

@jclc regarding int/uint issues, I hope this commit will help to generate more consistent code:

https://github.com/xlab/c-for-go/commit/ddcfe2673053652b6566fa8fabe6d0966a6b4ed9

lentus commented 3 years ago

Took a shot at regenerating the bindings, it seems like some uint/uint8/uint64/long are changed to uint32. Go build runs fine though (Ubuntu 20.04, Go 1.15.1, gcc 9.3.0 in case that's relevant). You can find my fork here: https://github.com/lentus/vulkan/commit/fc4636f5c6d297bd003a22dae31d89f6e95eb7e9.

Also tried generating bindings for Vulkan 1.2.166, but ran into some issues when doing go build. As jclc commented it is not entirely clear to me how I should edit the vulkan.yml to get this fixed, I'll give it another try sometime soon.