Thread overview
Building GDC with auto-generated header files
Jul 29, 2019
Eduard Staniloiu
Jul 30, 2019
rikki cattermole
Jul 30, 2019
Johannes Pfau
July 29, 2019
Cheers, everybody

I'm working on this as part of my GSoC project [0].

I'm working on building gdc with the auto-generated `frontend.h` [1], but I'm having some issues

There are functions in dmd that don't have an `extern (C)` or `extern (C++)` but they are used by gdc (are exposed in `.h` files)

An example of such a function is `checkNonAssignmentArrayOp`[2] from `dmd/arrayop.d` which is can be found in `gcc/d/dmd/expression.h` [3]

How does the linker find the right match in dmd? Since the function is `extern (D)`, isn't it mangled differently than C++?

[0] - https://forum.dlang.org/thread/djurwumzfrrttvtdgajs@forum.dlang.org
[1] - https://github.com/dlang/dmd/pull/9971
[2] - https://github.com/dlang/dmd/blob/master/src/dmd/arrayop.d#L85
[3] - https://github.com/gcc-mirror/gcc/blob/master/gcc/d/dmd/expression.h#L84
July 30, 2019
On 30/07/2019 4:11 AM, Eduard Staniloiu wrote:
> Cheers, everybody
> 
> I'm working on this as part of my GSoC project [0].
> 
> I'm working on building gdc with the auto-generated `frontend.h` [1], but I'm having some issues
> 
> There are functions in dmd that don't have an `extern (C)` or `extern (C++)` but they are used by gdc (are exposed in `.h` files)
> 
> An example of such a function is `checkNonAssignmentArrayOp`[2] from `dmd/arrayop.d` which is can be found in `gcc/d/dmd/expression.h` [3]

It may have previously been extern(C) or its a gdc specific patch.
Either way PR please.
July 30, 2019
Am Tue, 30 Jul 2019 15:19:44 +1200 schrieb rikki cattermole:

> On 30/07/2019 4:11 AM, Eduard Staniloiu wrote:
>> Cheers, everybody
>> 
>> I'm working on this as part of my GSoC project [0].
>> 
>> I'm working on building gdc with the auto-generated `frontend.h` [1], but I'm having some issues
>> 
>> There are functions in dmd that don't have an `extern (C)` or `extern
>> (C++)` but they are used by gdc (are exposed in `.h` files)
>> 
>> An example of such a function is `checkNonAssignmentArrayOp`[2] from `dmd/arrayop.d` which is can be found in `gcc/d/dmd/expression.h` [3]
> 
> It may have previously been extern(C) or its a gdc specific patch.
> Either way PR please.

Actually the code at https://github.com/gcc-mirror/gcc/blob/master/gcc/d/ dmd is still the C++ frontend. The DMD frontend in upstream master (https://github.com/dlang/dmd/blob/master/) and in GCC master are very different versions, so mismatches are expected.

The latest DDMD GDC is here: https://github.com/gcc-mirror/gcc/commits/ ibuclaw/gdc However, it's still not a good idea to mix and match files from DMD upstream master and that GDC branch, as they will not be 100% in sync. It's best to simply use only files from the gcc/d repo, as that's what's used when compiling GDC.

You could also have a look at the gcc/d/dmd/MERGE file, which will tell you what upstream DMD commit has been used in the respective GDC tree.

-- 
Johannes