Thread overview
importC to bindings via -Hf=your.di intermediate ?
Sep 06, 2023
Bruce Carneal
Sep 06, 2023
Bruce Carneal
Sep 06, 2023
Bruce Carneal
Sep 10, 2023
Adam Wilson
Sep 10, 2023
Bruce Carneal
Sep 10, 2023
Adam Wilson
September 06, 2023
I'm trying to use importC to help automate .di and targeted library production (for the Nvidia libs that dcompute taps into).

As you'll note if you try this yourself, the -Hf output of an importC run looks pretty interesting but has some, obvious, systemic problems.  For example:

  typedef SomeOpaqueStructYoureNotSupposedToSeeInside *HandleT;
becomes
  alias HandleT = struct SomeOpaqueStructYoureNotSupposedToSeeInside*;

I wondered if others have experience generating bindings with importC and suggestions they'd care to share.

I will note that I've had some luck using importC directly, with a little fiddling, but it looks like it could also be a supported/robust 99%+ binding generator going forward with some work.

September 06, 2023
On Wednesday, 6 September 2023 at 00:53:40 UTC, Bruce Carneal wrote:
> I'm trying to use importC to help automate .di and targeted library production (for the Nvidia libs that dcompute taps into).
>
> As you'll note if you try this yourself, the -Hf output of an importC run looks pretty interesting but has some, obvious, systemic problems.  For example:
>
>   typedef SomeOpaqueStructYoureNotSupposedToSeeInside *HandleT;
> becomes
>   alias HandleT = struct SomeOpaqueStructYoureNotSupposedToSeeInside*;
>
> I wondered if others have experience generating bindings with importC and suggestions they'd care to share.
>
> I will note that I've had some luck using importC directly, with a little fiddling, but it looks like it could also be a supported/robust 99%+ binding generator going forward with some work.

Sorry, typo, left out "struct" in the C typedef:
  typedef struct SomeOpaqueStructYoureNotSupposedToSeeInside *HandleT;
September 06, 2023
On Wednesday, 6 September 2023 at 00:55:57 UTC, Bruce Carneal wrote:
> On Wednesday, 6 September 2023 at 00:53:40 UTC, Bruce Carneal wrote:
>> ...
>> I will note that I've had some luck using importC directly, with a little fiddling, but it looks like it could also be a supported/robust 99%+ binding generator going forward with some work.
>

Here "some work" may actually be a Herculean challenge but I think not since the errors all seem to be of the form: "the information is in the compiler but was not processed properly for -Hf".

In any event, commentary from those in the know would be most appreciated.


September 10, 2023
On Wednesday, 6 September 2023 at 01:14:47 UTC, Bruce Carneal wrote:
> On Wednesday, 6 September 2023 at 00:55:57 UTC, Bruce Carneal wrote:
>> On Wednesday, 6 September 2023 at 00:53:40 UTC, Bruce Carneal wrote:
>>> ...
>>> I will note that I've had some luck using importC directly, with a little fiddling, but it looks like it could also be a supported/robust 99%+ binding generator going forward with some work.
>>
>
> Here "some work" may actually be a Herculean challenge but I think not since the errors all seem to be of the form: "the information is in the compiler but was not processed properly for -Hf".
>
> In any event, commentary from those in the know would be most appreciated.

I am using this process to update the ODBC bindings in etc.c.odbc, however, I currently have two active bugs against ImportC because when I try to generate a DI binding from an H file that has an tagged enum in it I get a segfault. But if you comment out the offending bits it actually works pretty much as you'd expect.
September 10, 2023
On Sunday, 10 September 2023 at 01:45:58 UTC, Adam Wilson wrote:
> On Wednesday, 6 September 2023 at 01:14:47 UTC, Bruce Carneal wrote:
...
>>> On Wednesday, 6 September 2023 at 00:53:40 UTC, Bruce Carneal wrote:
>>>> ...
>>>> I will note that I've had some luck using importC directly, with a little fiddling, ...
>>
>> Here "some work" may actually be a Herculean challenge but I think not since the errors all seem to be of the form: "the information is in the compiler but was not processed properly for -Hf".
>>
>> In any event, commentary from those in the know would be most appreciated.
>
> I am using this process to update the ODBC bindings in etc.c.odbc, however, I currently have two active bugs against ImportC because when I try to generate a DI binding from an H file that has an tagged enum in it I get a segfault. But if you comment out the offending bits it actually works pretty much as you'd expect.

Good to hear.  I'll look at the -Hf path again down the road but went back to using importC directly for #include <cuda.h> bindings.  Everything works AFAICT from my testing apart from importC ignoring #defines that should be function aliases for functions being declared elsewhere in the file, as in:

#define someStableFuncName actualFuncNameOfFunctionDefinedInThisFile
...

I'm not sure where I should report this "bug" in importC or even if it is considered a bug, but I've worked around it with a simple helper program, importC having done the heavy lifting.

September 10, 2023
On Sunday, 10 September 2023 at 05:15:59 UTC, Bruce Carneal wrote:
> I'm not sure where I should report this "bug" in importC or even if it is considered a bug, but I've worked around it with a simple helper program, importC having done the heavy lifting.

I would file the report. Walter is looking for bugs in ImportC and either it's already been fixed and it's not an issue to file a dup, or it hasn't and Walter can make it work right.