www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Building GDC with auto-generated header files

reply Eduard Staniloiu <edi33416 gmail.com> writes:
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
Jul 29 2019
parent reply rikki cattermole <rikki cattermole.co.nz> writes:
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.
Jul 29 2019
parent Johannes Pfau <nospam example.com> writes:
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
Jul 29 2019