use C mangling for unsigned long long for now#7523
Conversation
|
Thanks for your pull request, @WalterBright! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
7ead551 to
81afacf
Compare
|
I don't like where this is going. First with #7522 and now this, we have workarounds and temporary fixes to track and maintain. I'd like to see a more disciplined approach to dealing with the core problem. If we need a multi-step implementation, let's document it somewhere with specific tasks to be performed and specific dates on which to perform them. I suggest closing this, #7522, & #7519, and re-opening #7505 to revert the cause of this debacle until a more disciplined development plan is devised and documented. |
81afacf to
e8b00e1
Compare
|
I'm not concerned about workarounds, because the back end will be converted to D soon and the whole problem will go away. The correct fix is already in - using uint64_t/int64_t, which is a principled approach. |
That might solve it for DMD but I think the it needs to be possible to use |
That's outside the scope of this PR. |
4580ef9 to
b6d857d
Compare
src/dmd/backend/outbuf.d
Outdated
| q[1] = cast(ubyte)v; | ||
| p += 2; | ||
| } | ||
| } |
There was a problem hiding this comment.
Undefined symbols for architecture x86_64:
"Outbuffer::writeShort(int)", referenced from:
Outbuffer::writeChar(int) in dmd.o
99b92c0 to
ca95468
Compare
16fb9ca to
0831a3f
Compare
|
Seems like |
46cf455 to
400a7d9
Compare
400a7d9 to
55216c6
Compare
|
|
|
@wilzbach this is ready to pull now. |
wilzbach
left a comment
There was a problem hiding this comment.
I am not happy about this either, but I really don't like that our CIs (Travis in this case) are broken. If the conversion is really that imminent, we will get rid of most hacks anyways.
| void abytes(tym_t ty, uint offset, uint size, const(char)* ptr, uint nzeros); | ||
| void abytes(uint offset, uint size, const(char)* ptr, uint nzeros); | ||
| void dword(int value); | ||
| version (OSX) |
There was a problem hiding this comment.
I thought this is a clang issue?
There was a problem hiding this comment.
no, g++ on OSX behaves the same.
|
I'm a bit late here, but problems just popped up now when finalizing LDC's upgrade to 2.079. I agree with the previous concerns about this whole mangling change. As it stands now, a C++ |
|
For Posix |
|
[That's what I meant, without going into too many details.] What this size_t incompatibility means in practice is that basically there should be no occurrence of |
|
I wonder if this can work: and then handle it specially in the C++ name mangler. |
No, I don’t think that’s legal D code. I think enums require a value on the right side. |
That's still not a nice solution, as e.g. ints aren't implicitly converted to a |
It's not just ints that are not implicitly converted, it won't work for any numeric type since D doesn't have implicit constructions of structs. |
|
I tried adding support for specifying a mangling on an alias #7458 but I ran into some issues with type comparisons. |
|
I had another look at the mangling of numeric types in C++ and D. This table is the result:
Giving that result, this is how we should map C++ types in D:
With the current implementation, what is missing is |
|
It's probably not that simple as you seem to have tested on macOS only. 32-bit macOS seems to map size_t to
It'd be nicer than the magic structs with the implicit conversion problem, but how do you specify a C++-only mangle? A new pragma? I'm against touching D mangling here, I don't want D to repeat the C++ mistakes with ambiguous integer types... |
The definition of
When I originally had that idea it was as a more generic solution to the existing |
|
I find having to use Use LDC as an example for a non-trivial mixed D/C++ code base - who wants to replace all size_t's in the DMD frontend C++ headers to a |
|
It’s not ideal, I’m trying to come up with a middle ground. |
|
See #8152 |
|
I've experimentally added The expected result is that C++ uint64_t testlongmangle(int a, unsigned int b, int64_t c, uint64_t d);
unsigned long testCppLongMangle(long a, unsigned long b);
unsigned long long testCppLongLongMangle(long long a, unsigned long long b);
size_t testCppSizeTMangle(ptrdiff_t a, size_t b);and D extern(C++):
cpp_uint64_t testlongmangle(int a, uint b, cpp_int64_t c, cpp_uint64_t d);
cpp_ulong testCppLongMangle(cpp_long a, cpp_ulong b);
cpp_ulonglong testCppLongLongMangle(cpp_longlong a, cpp_ulonglong b);
size_t testCppSizeTMangle(ptrdiff_t a, size_t b);are mangled identically, i.e., that firstly all C++ integer types can be represented in D (on all platforms) and that secondly ptrdiff_t and size_t match up (excl. 32-bit macOS). Thx Walter for trying to fix the implicit conversion issue. |
Because of mangling problems on OSX for
unsigned long longwhen using a bootstrap dmd, we just use C mangling for now.