-
-
Notifications
You must be signed in to change notification settings - Fork 145
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
Use "-i" to prevent rdmd from having to invoke compiler twice. #271
Conversation
Thanks for your pull request, @marler8997! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Some tips to help speed things up:
Bear in mind that large or tricky changes may require multiple rounds of review and revision. Please see CONTRIBUTING.md for more information. 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. |
c15d950
to
d3b345c
Compare
c671539
to
7d700ec
Compare
I tried to run the rdmd unit tests of this + dlang/dmd#7099:
The rdmd test suite fails:
It looks like an issue with Lines 178 to 179 in f1d60cd
|
Yeah I already kinds knew it was going to break exclude. Was going to wait until the dmd PR was integrated until I finish implementing everything in this PR :) |
Are you sure that the dmd PR has everything needed, though, and we won't run into some issue after it's merged? Having the rdmd test suite pass would give us some guarantee of completeness, and is probably the best metric we have for measuring that. |
Yeah that's a good point. At the moment I'm trying to add some tests in the dmd repo for the new feature. I'll see if I can finish the rdmd implementation after that. |
7d700ec
to
d30eb1d
Compare
Got the tests to pass now. I also took some performance measurements before and after this change with the following command:
Before Change
After Change
About a 30% decrease in run time :) |
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.
Looks really good!
Pro tip: use this url to look at the diff - https://github.com/dlang/tools/pull/271/files?w=1
rdmd.d
Outdated
@@ -321,6 +311,28 @@ int main(string[] args) | |||
} | |||
} | |||
|
|||
if(makeDepend || makeDepFile !is null) | |||
{ | |||
auto resolvedDeps = (initialDeps is null) ? cast(const(string[string]))readDepsFile(objDir, depsFilename) : initialDeps; |
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.
How about letting tryGetDependencies
and readDepsFile
return a const(string[string]
instead of the "ugly" cast?
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.
Wouldn't that just move the cast to the tryGetDependencies and readDepsFile functions?
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.
It works for me:
diff --git a/rdmd.d b/rdmd.d
index 3bc7460..3e17fbd 100755
--- a/rdmd.d
+++ b/rdmd.d
@@ -313,7 +313,8 @@ int main(string[] args)
if(makeDepend || makeDepFile !is null)
{
- auto resolvedDeps = (initialDeps is null) ? cast(const(string[string]))readDepsFile(objDir, depsFilename) : initialDeps;
+ auto resolvedDeps = (initialDeps is null) ? readDepsFile(objDir, depsFilename) : initialDeps;
assert(resolvedDeps !is null, "code bug: dependencies were not properly generated from the build");
// --makedepend mode. Just print dependencies and exit.
@@ -610,7 +611,7 @@ private int exec(string[] args)
return run(args, null, true);
}
-string[string] readDepsFile(string objDir, string depsFilename)
+const(string[string]) readDepsFile(string objDir, string depsFilename)
{
string d2obj(string dfile)
{
@@ -705,7 +706,7 @@ string[string] readDepsFile(string objDir, string depsFilename)
// directory workDir. The mapping is obtained by reading the 'rdmd.deps' file
// that would have been generated on a previous build.
-private string[string] tryGetDependencies(string rootModule,
+private const(string[string]) tryGetDependencies(string rootModule,
string objDir, string[] compilerFlags, string depsFilename)
{
// Check if the old dependency file is fine
@@ -495,10 +507,20 @@ private int rebuild(string root, string fullExe, | |||
~ [ "-of" ~ fullExeTemp ] | |||
~ [ "-od" ~ objDir ] | |||
~ [ "-I" ~ dirName(root) ] | |||
~ [ "-i" ] | |||
~ [ "-v" ] |
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 assume this was just for development / testing?
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.
Actually it's necessary. Before this change the compiler was called using -v
for the "first call" to the compiler, now both calls are combined into a single call. rdmd still uses the output from -v
to read the dependencies to know when a rebuild is necessary.
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.
Ah fair enough. Thanks for the explanation!
Looks amazing! Before we merge this, we should add a changelog entry mentioning the awesome speed up. Maybe you are even interested in preparing a short article for the next release on the blog? |
An article? Hmm, maybe... |
Yes, please! |
@marler8997 will rdmd's |
Yes, I haven't tested it yet but I think it will also fix https://issues.dlang.org/show_bug.cgi?id=18042 |
@MartinNowak I'm trying to triage the jenkins failure, but after I logged in I get this mesesage: Access Denied |
Yeah you need write access to restart jobs, I just did this for you. You can always force-push the same commit to kick the CIs |
That patch was spun from problems with this patch. To quote yourself:
Ergo, regression. While its obvious that optlink is the culprit that needs fixing, there still needs to be consideration in supporting older versions of tools going back at least two years (I think 2 years is fairly relaxed a constraint, but project maintainers of rdmd may be more lax or strict as they see fit). I see no direct approach to take, every move should be treated like chess pieces. You make a change with the intent to make use of in the future. You've pushed your change in the compiler, so the natural thing to do is wait until that change becomes ubiquitous. |
Yes, that PR is not a full solution to the problem. I figured that I should get the support in now and maybe in 2 years we can start using it :) Until then we will need to settle for a backwards compatible approach such as filtering messages, or we could rely on fixing OPTLINK and say that it's ok to drop linker errors if you are using an old version of OPTLINK. We have options. That PR gives us more options for this one, but like I said, it should ultimately be considered independent of this one. |
|
Some improvements to the test suite that should make it easier to run |
Yes please :) |
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 PR is obsoleted by #292 but comments here still hold
// parsing the linker's command line (as specified in dmd.conf/sc.ini). | ||
// Go for best-effort instead. | ||
string[] dirs = ["."]; | ||
foreach (envVar; ["LIB", "LIBRARY_PATH", "LD_LIBRARY_PATH"]) |
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.
DYLD_LIBRARY_PATH on OSX
would be nice to abstract out OS specific things eg:
foreach (envVar; ["LIB", "LIBRARY_PATH", os_LD_LIBRARY_PATH]) {...}
module rdmd.util;
string os_LD_LIBRARY_PATH(){ // find a better name
version(OSX) return "DYLD_LIBRARY_PATH";
else version(linux) return "LD_LIBRARY_PATH";
else assert(0);
}
{ | ||
return buildPath(objDir, dfile.baseName.chomp(".d") ~ objExt); | ||
string[] names = ["lib" ~ libName ~ ".a", "lib" ~ libName ~ ".so"]; |
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.
.dylib on OSX
same comment as above:
string[] names = ["lib" ~ libName ~ ".a", "lib" ~ libName ~ os_so_ext];
This patch is something of a proof-of-concept for using rdmd_test's new `--test-compilers` flag to test rdmd using multiple different compilers. The travis config now ensures that LDC is installed (providing the ldmd2 DMD-alike compiler interface), and the `travis.sh` CI script sets both dmd and ldmd2 as test compilers when calling `make -f posix.mak test`. This should probably not be the final form for setting up multi compiler tests, but serves as an initial stage which should at a minimum flag up issues like that observed with dlang#271.
This patch is something of a proof-of-concept for using rdmd_test's new `--test-compilers` flag to test rdmd using multiple different compilers. The travis config now ensures that GDC and LDC are installed (providing the gdmd and ldmd2 DMD-alike compiler interfaces), and the `travis.sh` CI script sets dmd, gdmd and ldmd2 as test compilers when calling `make -f posix.mak test`. This should probably not be the final form for setting up multi compiler tests, but serves as an initial stage which should at a minimum flag up issues like that observed with dlang#271.
This patch is something of a proof-of-concept for using rdmd_test's new `--test-compilers` flag to test rdmd using multiple different compilers. The `install.sh` script is used to install LDC (including the `ldmd2` DMD-alike compiler interface), both `dmd` and `ldmd2` as test compilers when calling `make -f posix.mak test`. A little trickery using `find` is used to work around the problem that `ldmd2` is not in the `PATH`. This should probably not be the final form for setting up multi compiler tests, but serves as an initial stage which should at a minimum flag up issues like that observed with dlang#271.
This patch is something of a proof-of-concept for using rdmd_test's new `--test-compilers` flag to test rdmd using multiple different compilers. The `install.sh` script is used to install GDC and LDC (including the `gdmd` and `ldmd2` DMD-alike compiler interfaces), and specify all three of `dmd`, `gdmd` and `ldmd2` with the `RDMD_TEST_COMPILERS` environment variable when invoking `make -f posix.mak test`. A little trickery with `find` is used to work around the problem that the install locations of `gdmd` and` ldmd2` are not added to `PATH`. The `VERBOSE_RDMD_TEST` flag is set to ensure that the Travis build logs will contain a full summary of the individual `rdmd` calls from the test suite, for each of the test compilers. This should probably not be the final form for setting up multi compiler tests, but serves as an initial stage which should at a minimum flag up issues like that observed with dlang#271. While in development it has already shown up at least one `rdmd` issue (fixed in dlang#303), so we can reasonably hope that it will prevent others from arising in the first place.
This patch is something of a proof-of-concept for using rdmd_test's new `--test-compilers` flag to test rdmd using multiple different compilers. The `install.sh` script is used to install LDC (including the DMD-alike `ldmd2` compiler interface interface), and the `make -f posix.mak test` call is updated to specify both `dmd` and `ldmd2` as test compilers for the `rdmd_test` test suite. A little trickery with `find` is necessary to work around the problem that the install location of` ldmd2` is not added to `PATH`. The `VERBOSE_RDMD_TEST` flag is set to ensure that the Travis build logs will contain a full summary of the individual `rdmd` calls from the test suite, for each of the test compilers. This should probably not be the final form for setting up multi compiler tests, but serves as an initial stage which should at a minimum flag up issues like that observed with dlang#271. While in development it has already shown up at least one `rdmd` issue (fixed in dlang#303), so we can reasonably hope that it will prevent others from arising in the first place.
This patch is something of a proof-of-concept for using rdmd_test's new `--test-compilers` flag to test rdmd using multiple different compilers. The `install.sh` script is used to install LDC (including the DMD-alike `ldmd2` compiler interface interface), and the `make -f posix.mak test` call is updated to specify both `dmd` and `ldmd2` as test compilers for the `rdmd_test` test suite. A little trickery with `find` is necessary to work around the problem that the install location of` ldmd2` is not added to `PATH`. The `VERBOSE_RDMD_TEST` flag is set to ensure that the Travis build logs will contain a full summary of the individual `rdmd` calls from the test suite, for each of the test compilers. This should probably not be the final form for setting up multi compiler tests, but serves as an initial stage which should at a minimum flag up issues like that observed with dlang#271. While in development it has already shown up at least one `rdmd` issue (fixed in dlang#303), so we can reasonably hope that it will prevent others from arising in the first place.
@ibuclaw Does |
To me the question becomes: Why do we need RDMD now ? |
It's a tool that supports a different flow that some people (incl. me, and Andrei I guess) are used to. Without rdmd, there's nothing in-between "use the compiler directly" (for single-file programs, no caching) and "use this build tool / package manager which requires creating a project in its own directory with I don't use rdmd but I use @marler8997's rdmd-like build tool rund (now part of @dragon-lang apparently) which is essentially rdmd with |
Oh, just realized I misunderstood your question (thought you asked, why do we need rdmd today). The main gimmick is that |
If dmd started doing caching (e.g. like Btw, I would have preferred if |
Not much, I think the main issue is that rdmd is a bit opinionated in how it does caching. And, I agree. Either a library or some kind of subprocess protocol like LSP. |
@Geod24 other than having no caching feature, |
And another reason to avoid |
Should result in a big performance improvement to rdmd (about 30% decrease in run time). Depends on this commit from dmd (dlang/dmd#7099).