-
-
Notifications
You must be signed in to change notification settings - Fork 636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate all .o .deps and binaries to generated/ #6562
Conversation
3b9ece9
to
72278c1
Compare
src/posix.mak
Outdated
|
||
GENERATED = ../generated | ||
G = $(GENERATED)/$(OS)$(MODEL) | ||
$(shell mkdir -p $G) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that there is no good reason to have two unused levels in the hierarchy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that there is no good reason to have two unused levels in the hierarchy
Well you can do debug
and release
builds at the same time without any issues ... and there are tons of other different build types available for DMD: https://github.com/dlang/dmd/blob/master/src/posix.mak#L160
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is interesting. A few explanations follow.
-
Currently the code does not make the situation any worse than before - it just moves all generated files elsewhere, indiscriminately.
-
The structure
generated/$(OS)$(MODEL)
(as opposed to Phobos'generated/$(OS)/$(MODEL)
) was chosen by @RazvanN7 and I after discussing for a while and figuring there's no real need for two separate levels in the dir hierarchy. -
We could actually simply use
generated/
without the OS or the model, BUT:
- It is reasonable to generate 32 and 64 binaries on a given machine
- Even on a given OS, there may be multiple "OS"s - consider generating Windows and Cygwin binaries on Windows. Are there any others? Not sure how important this is, but putting the OS in the dirname helps such situations.
- Now (this is getting to @wilzbach's point), we have the situation in which changing CFLAGS and DFLAGS affects the generated binaries in many ways, per https://github.com/dlang/dmd/blob/master/src/posix.mak#L160. The "total" solution to that is to canonicalize and place the controlling flags in the dir names, i.e. (after removing
ENABLE
) in alphabetical order:COVERAGE
,DEBUG
,LTO
,PGO_GENERATE
,PGO_USE
,PROFILE
,PROFILING
,RELEASE
,UNITTEST
. Then the dir name of a generated bunch of binaries would be something likegenerated/posix64/DEBUG_PROFLE_UNITTEST
. The "final release" version should sit ingenerated/$(OS)$(MODEL/
so flags do not affect tool developers. This scheme may be overkill even if technically appropriate. I think @WalterBright and @MartinNowak should chime in here because they'll be the first and most affected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is interesting. A few explanations follow.
- The structure generated/$(OS)$(MODEL) (as opposed to Phobos' generated/$(OS)/$(MODEL)) was chosen by @RazvanN7 and I after discussing for a while and figuring there's no real need for two separate levels in the dir hierarchy.
I doesn't cost anything either, and consistency across repos seems more important (in particular for scripting, e.g. release scripts). So let's please just stick with generated/$OS/$BUILD/$MODEL
as anywhere else.
Even on a given OS, there may be multiple "OS"s - consider generating Windows and Cygwin binaries on Windows. Are there any others? Not sure how important this is, but putting the OS in the dirname helps such situations.
I also allows to more easily rsync code from other machines/VMs.
Now (this is getting to @wilzbach's point), we have the situation in which changing CFLAGS and DFLAGS affects the generated binaries in many ways, per https://github.com/dlang/dmd/blob/master/src/posix.mak#L160. The "total" solution to that is to canonicalize and place the controlling flags in the dir names, i.e. (after removing ENABLE) in alphabetical order: COVERAGE, DEBUG, LTO, PGO_GENERATE, PGO_USE, PROFILE, PROFILING, RELEASE, UNITTEST.
Those are hardly maintained and rarely used, let's not overshoot and leave it to maintainers.
Separating debug and relase builds is quite helpful though.
An alternative would be to dump all flags to some file and error on mismatch (requiring a clean step). This is the usual configure/Make approach to changing flags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK with @MartinNowak, @RazvanN7 can you please execute? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, what will be the final path of the created dmd
binary when make is invoked with the default settings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the end, the path will be generated/dmd, but until then we will keep a copy of dmd in src/ so that we will have a smooth transition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the path will be generated/dmd
Didn't we agree on generated/linux/debug/64/dmd
?
In the final build step you could create a symlink to the last built binary (e.g generated/dmd
->
$(abspath generated/linux/debug/64/dmd)`) if you really want to ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right. Sorry, I misread the comments
I don't have a windows setup, so my strategy is to spam the auto-tester. If someone with a windows machine wishes to co-op this PR, be my guest. |
72278c1
to
0039af1
Compare
@RazvanN7 please give me the rational for using the generated folder. |
|
9fac9bb
to
87e0612
Compare
With all the changes happening anyways, would there be a possibility of adding druntime/phobos as submodules into dmd? The make files expect a specific file structure for where dmd, druntime, and phobos should be located relative to each other. Having them be submodules in dmd will make building from source easier. It will also know which specific version of druntime/phobos to use, rather than having to checkout the correct version for every repo. |
Building out of tree is a common best practice and immediately useful to separate debug and release objects to avoid errors during development.
Let's please not open another can of worms. @CyberShadow has an exterior repo that tracks all repos, https://bitbucket.org/cybershadow/d (used by Digger). |
Let's not move |
This is probably the only time to do so. A lot of the changes that would have to be made are on the same lines that this change is going to cause. Relying on an external tool and external repo for building kind of proves my point. |
df17adb
to
060531b
Compare
060531b
to
e27753a
Compare
The last commit was called "Added |
I believe the problem occurred at the time the commit is created - your shell evaluated |
@CyberShadow thanks! I should have known that this would happen. |
Looking green! Well. almost. What's the failure with DAutoTest? Thanks! cc @CyberShadow maybe you could help. |
Is it the DMD source code DDoc stuff? Not really familiar with that. |
No, the first commit moves the file and the second one moves it back. So a squash is fine in this case. |
9371658
to
a745a9e
Compare
way we go... |
Question still unanswered in light of the latest changes :) Need to know what to update DIgger to use, so that we can delete |
AFAIK it's supposed to be |
@CyberShadow : @wilzbach is right. that will be the path, same as in the phobos makefile |
Hmm, dlang.org autodeploy build failed:
|
Something changed in this PR which for some reason kept working on the documentation tester but didn't work on the dlang.org autodeployer, even though they use nearly the same environment and build commands. |
Found the bug: Odd that it worked on DAutoTest :) |
Fixed. CyberShadow/ae@13bc434 |
|
Seems like this broken the build script @RazvanN7, could you please have a look.
|
@MartinNowak Since so many things seem to have broken nightly builds recently, is there a possibility of adding it as a CI? (Bonus: you can download a version of D that includes a certain PR to test it out) |
@MartinNowak it seems that the rule to make the target ..\generated\Windows...\dmd.exe doesn't exist in the makefile. That is odd, since the rule definitely exists in the makefile that I commited. The link you provided doesn't output this error. Could you, please, give me some more information? |
The cost for a real run is prohibitive atm. (too many OSes/VMs). |
http://nightlies.dlang.org/dmd-master-2017-03-02/build.html, wrong date, my mistake. |
How about making it on-demand, or just whenever a makefile changes? |
Yes, we should work on replacing the create_dmd_release script and CI integration (heuristic sounds like a good idea) in the longer run, but I'm busy w/ other things atm. |
See #6585. |
Eww discovered a couple of more issues with the "new" Makefile: |
I created a directory src/ddmd where I moved all the files in src/, except makefiles. Other than that I modified optabgen.d to generate sources to src/ddmd/backend and I also moved tk.c to backend since it was the only .c file in src/ddmd.
I also modified the makefile to have all generated files (except .c .d and .h files - source code generated files) in a directory called generated/ which is on the root level (same level as src). After creating dmd, the executable is copied to src/dmd so that other tools aren't affected by this PR.
Now all the other tools can be updated to use the dmd from the generated/ folder whithout causing a major stall. After all the scripts are updated to use generated/dmd/ I will issue a new PR which renames ddmd to dmd and no longer generates dmd in the src folder. This way things will get smoothly in the right direction.
This is a WIP as I only applied the modifications to the posix makefile.
This is a duplicate of #6489 since it was more time consuming to apply these changes on that branch.