Re: large Windows mingw64 project in C99 --- need ABI compatible D compiler

2020-05-20 Thread IGotD- via Digitalmars-d-learn

On Wednesday, 20 May 2020 at 23:28:09 UTC, kinke wrote:


The ABI for MinGW targets in general. - Judging by 
https://forum.dlang.org/post/anfwqjjsteeyelbdh...@forum.dlang.org, you apparently use a very different definition of 'ABI'. See http://uclibc.org/docs/psABI-x86_64.pdf or https://docs.microsoft.com/en-us/cpp/build/x64-software-conventions?view=vs-2019 for what an ABI is.


I guess what you meant is the druntime API implicitly used by 
the compiler (mostly, the _d_* hooks like _d_assert, 
_d_newclass etc.). That's well-defined already, e.g., see 
https://github.com/ldc-developers/ldc/blob/master/gen/runtime.cpp.


That's what I was thinking about, the ABI of x86-64 which 
originates from the ones that designed the ISA. The word ABI is 
used or misused in other areas as well, for example libc++abi 
which is a compatibility layer for libc++, that's why the word 
ABI turns up in a discussion about the druntime abstract 
interface.


Re: large Windows mingw64 project in C99 --- need ABI compatible D compiler

2020-05-20 Thread kinke via Digitalmars-d-learn

On Wednesday, 20 May 2020 at 23:08:53 UTC, IGotD- wrote:
When you mention the ABI, is there something particular you 
have in mind or just in general?


The ABI for MinGW targets in general. - Judging by 
https://forum.dlang.org/post/anfwqjjsteeyelbdh...@forum.dlang.org, you apparently use a very different definition of 'ABI'. See http://uclibc.org/docs/psABI-x86_64.pdf or https://docs.microsoft.com/en-us/cpp/build/x64-software-conventions?view=vs-2019 for what an ABI is.


I guess what you meant is the druntime API implicitly used by the 
compiler (mostly, the _d_* hooks like _d_assert, _d_newclass 
etc.). That's well-defined already, e.g., see 
https://github.com/ldc-developers/ldc/blob/master/gen/runtime.cpp.


Re: large Windows mingw64 project in C99 --- need ABI compatible D compiler

2020-05-20 Thread NonNull via Digitalmars-d-learn

On Wednesday, 20 May 2020 at 23:10:12 UTC, IGotD- wrote:

On Wednesday, 20 May 2020 at 23:08:53 UTC, IGotD- wrote:

On Wednesday, 20 May 2020 at 21:37:23 UTC, kinke wrote:


You're welcome. If you do come across an ABI issue, make sure 
to file an LDC issue. While I have no interest in MinGW, I 
want at least a working ABI.


When you mention the ABI, is there something particular you 
have in mind or just in general?


That's a question to TS, NonNull.


General.


Re: large Windows mingw64 project in C99 --- need ABI compatible D compiler

2020-05-20 Thread IGotD- via Digitalmars-d-learn

On Wednesday, 20 May 2020 at 23:08:53 UTC, IGotD- wrote:

On Wednesday, 20 May 2020 at 21:37:23 UTC, kinke wrote:


You're welcome. If you do come across an ABI issue, make sure 
to file an LDC issue. While I have no interest in MinGW, I 
want at least a working ABI.


When you mention the ABI, is there something particular you 
have in mind or just in general?


That's a question to TS, NonNull.


Re: large Windows mingw64 project in C99 --- need ABI compatible D compiler

2020-05-20 Thread IGotD- via Digitalmars-d-learn

On Wednesday, 20 May 2020 at 21:37:23 UTC, kinke wrote:


You're welcome. If you do come across an ABI issue, make sure 
to file an LDC issue. While I have no interest in MinGW, I want 
at least a working ABI.


When you mention the ABI, is there something particular you have 
in mind or just in general?


Re: large Windows mingw64 project in C99 --- need ABI compatible D compiler

2020-05-20 Thread kinke via Digitalmars-d-learn

On Wednesday, 20 May 2020 at 20:45:26 UTC, NonNull wrote:
[...] so I will likely go with ldc2 with the option you 
suggested and see how it goes.


Thanks again!


You're welcome. If you do come across an ABI issue, make sure to 
file an LDC issue. While I have no interest in MinGW, I want at 
least a working ABI.


Re: large Windows mingw64 project in C99 --- need ABI compatible D compiler

2020-05-20 Thread NonNull via Digitalmars-d-learn

On Wednesday, 20 May 2020 at 19:25:27 UTC, kinke wrote:

On Wednesday, 20 May 2020 at 18:53:01 UTC, NonNull wrote:
Which D compiler should be used to be ABI compatible with 
mingw32? And which to be ABI compatible with mingw64?


The natural choice for coupling mingw[64]-gcc would be GDC. 
Especially wrt. ABI, gdc apparently doesn't have to do much by 
itself, in sharp contrast to LDC. No idea where gdc's 
MinGW[-w64] support is at though and whether you need more 
recent D features not available in gdc.

[...]


Thanks for the detailed information!

I see your point about gdc's ABI, but it seems gdc is not 
distributed for Windows at this juncture and I am looking for a 
simple way forward, so I will likely go with ldc2 with the option 
you suggested and see how it goes.


Thanks again!




Re: large Windows mingw64 project in C99 --- need ABI compatible D compiler

2020-05-20 Thread kinke via Digitalmars-d-learn

On Wednesday, 20 May 2020 at 18:53:01 UTC, NonNull wrote:
Which D compiler should be used to be ABI compatible with 
mingw32? And which to be ABI compatible with mingw64?


The natural choice for coupling mingw[64]-gcc would be GDC. 
Especially wrt. ABI, gdc apparently doesn't have to do much by 
itself, in sharp contrast to LDC. No idea where gdc's MinGW[-w64] 
support is at though and whether you need more recent D features 
not available in gdc.


Wrt. LDC, I think the C ABI for the `-mtriple=x86_64-windows-gnu` 
target should be okay. IIRC, MinGW mostly adheres to Microsoft's 
official Win64 ABI and mostly just diverges wrt. `real` (80-bit 
x87 C `long double` vs. 64-bit double precision for MSVC), and 
that's covered by LDC IIRC. The C++ ABI (Itanium mangling, not 
the MSVC one) should be okay-ish; there might be differences wrt. 
what's considered a POD between MinGW and MSVC. Exception 
handling almost certainly doesn't work; TLS may likely not work 
either.


In general, druntime and Phobos don't fully support MinGW[-w64], 
but if you restrict yourself to -betterC code, that might not be 
a problem.


How can I use D in this situation, where I need it to work 
directly with C data? building DLLs is not going to work here 
for that reason.


With -betterC, generating mixed DLLs shouldn't be any trouble at 
all.


Re: large Windows mingw64 project in C99 --- need ABI compatible D compiler

2020-05-20 Thread welkam via Digitalmars-d-learn

On Wednesday, 20 May 2020 at 18:53:01 UTC, NonNull wrote:
Which D compiler should be used to be ABI compatible with 
mingw32? And which to be ABI compatible with mingw64?
I am not expert here but doesnt all C compilers have the same 
ABI? If yes then compile your code in 32 bits for 32 bit C obj 
files. If you are on 64 bit OS then D compilers will produce 64 
bit executables by default. To change that use 
https://dlang.org/dmd-linux.html#switch-m32