Conversation
|
Thanks for your pull request and interest in making D better, @MoonlightSentinel! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. 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. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + dmd#10801" |
thewilsonator
left a comment
There was a problem hiding this comment.
Thanks! First review pass, Indentation:
src/dmd/dtoh.d
Outdated
| buf.printf(" {}\n"); | ||
| } | ||
|
|
||
| version (none) |
There was a problem hiding this comment.
any ideas what this version none ins for?
There was a problem hiding this comment.
Not sure but the versioned code generates an additional constructor to set all fields, e.g.
S2(_d_int a, _d_int b, _d_long c) { this->a = a; this->b = b; this->c = c; }
for
extern (C++) struct S2
{
int a = 42;
int b;
long c;
this(int a) {}
}
Geod24
left a comment
There was a problem hiding this comment.
We could use a changelog entry describing the user-facing interface.
Things that immediately come to mind:
- What happens when doing
dmd a.d b.d c.d -HC? - Mention the scope (only applies to
extern(C)andextern(C++)declarations, ignore everything else) - Mention the limitations (semantic not run)
| OutBuffer buf; | ||
| buf.writestring("#pragma once\n"); | ||
| buf.writeByte('\n'); | ||
| buf.printf("// Automatically generated by dmd -HC\n"); |
There was a problem hiding this comment.
I'm wondering whether we should include the DMD version.
On one hand it's informative, on the other hand it would need to needless diff in the event a generated header is checked in and its generation is part of the process (it doesn't make sense to me, but I'm sure someone will do it).
Same issue would arise with a timestamp. However I can see a value in knowing a bit more about how the header was generated.
Last but not least, having the full command line might be helpful too. Things like -version and -debug will affect the output, won't they ?
There was a problem hiding this comment.
Indeed, that could be useful to track down errors but also annoying for diffs (and maybe reproducible builds). Maybe this behavior should be customizable via an optional argument to -HC. But i think this could be added later.
Last but not least, having the full command line might be helpful too. Things like
-versionand-debugwill affect the output, won't they ?
I think so.
There was a problem hiding this comment.
At the very least, use __VENDOR__, as it's not only dmd that would use this option.
|
As a side note, something that would be a life-saver for people using C++ interop easily is an automatic |
This could be added later. But for now the main goal is to integrate an initial version s.t. @TurkeyMan and other people can start contributing as well. |
00c74cd to
3585ac1
Compare
|
I've added a preliminary changelog but I'm unsure whether we should promote it right away. Some remaining TODO's:
But these should mostly be resolved in further PR's. |
Maybe state "experimental" support? So that it's clear that not everything is fully tested and bug reports are welcome.
Yes, please keep this one as small/low-effort as possible so that people can finally start testing it. Thank you very much for taking this to the finish line!! |
3585ac1 to
960e654
Compare
Done
Gotcha. Maybe such big features should be developed on a dedicated branch in the future. That would offer similar benefits to a draft PR while also keeping the work publicly accessible (everbody can make a small PR without adopting the entire stalled PR) |
|
@Geod24 @MoonlightSentinel Semantic is run before generating the cpp header files. The |
FYI: We have tried this before and even made nightly builds of these branches available. No one ever downloaded those (I guess it also was a problem of people not knowing about it). Additionally, you run the high risk of the branch having lots of merge conflicts with master, so IMHO the best thing we can do are feature flags (in some way, e.g. -preview or now this flag). |
This is not possible (should be read as hard to implement) for the dmd codebase, due to the differences between C++ and D when it comes to importing (vs includes) and forward references. @edi33416 tried this but it didn't work for the dmd codebase (I can't remember the reason though, it was something about having duplicate forward declarations). You can still generate individual header files, it's just that you have to invoke the compiler for every .d file separately. |
That is (sadly) not entirely true as some checks are delayed until IR / code generation (and hence occur after the header generation). E.g. fails to compile but does not issue an error when using |
Thanks, I did not know that. Seems like it's usually not the best idea. |
Agreed, this will be a bigger project for the future but i think it could be workable (at least by automating the proposed workaround) |
|
What's up with the weird spacing and random braces in the generated changelog? |
f9ddcdb to
27fe7b0
Compare
27fe7b0 to
1b7fbc8
Compare
|
Eliminated the remaining style issues and got the tests passing by switching from separate files to |
Fix: dlang/tools#390 |
0ac8330 to
ef47cce
Compare
- Documentation for dtoh.d - Removed redundant static - Add missing members to globals.h - Generate .h instead of .out files in tests - Add a changelog
ef47cce to
9525e6f
Compare
thewilsonator
left a comment
There was a problem hiding this comment.
Otherwise looks good to me.
|
So what's the plan to remove all the .h files from dmd-fe? We won't be able to market this feature if we aren't using it in-house. |
|
Step 0: merge this. |
|
Let's get this in! It seems that the buildkite failure is due to some version mismatch. probably unrelated to this PR. |
Correct: dlang/ci#410 |
|
I'll try to give this a review this weekend. |
All these steps aren't required. We talked about this before. It's no problem because: |
- remove unused variables - sort import in mars.d - remove unecessary braces - pointer style - replace duplication with goto - TODO comments for missing implementation - Replace Type[...].ty check + cast with isType[...]
- Remove leftover comment - Guard against multiple initializations - Add a dshell test
9525e6f to
d0d5f08
Compare
wilzbach
left a comment
There was a problem hiding this comment.
Awesome! Glad to get this finally started!
|
🎉🎉🎉 Awesome! Thank you so much everyone for working this through! |
I think this was my suggestion, it reminds contributors to regenerate the headers (it can be a make rule) before submitting the PR. Keeping it checked in is harmless anyway. There will always need to be a header present for the initial bootstrap (assume that for the next 2-3 years, the baseline D compiler doesn't have |
|
Also, this needs a little extra work, as the module in its current form both imports dmd-specific modules and doesn't export the main entrypoint to C++. |
|
Templates seems completely unhandled, and due to the way the FE treats |
|
@yebblies glad to hear from you as always. :-) |
Squashed rebase of #9971 without the changes to the existing C++ tests (as proposed in #9971 (comment)).
CC @edi33416, @TurkeyMan, @wilzbach