-
-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ignore --arch switch if it doesn't affect the build
This change has two consequences, one it can improve caching as specifying `--arch=<default_arch>` will lead to the same build id as not specifying it at all but, more importantly, it improves the usability of external tools that rely on dub generated files. Take as an example the meson build system. It supports for a project to depend on a dub build library. The internal code calls `dub describe --build=... --compiler=... --arch=...` and gathers the cache artifact file from that. Because of always specifying `--arch` the package will always need to be rebuilt when used by meson. This is not intuitive to someone who doesn't know how the --arch switch is used internally in dub. This has come up as an issue in meson's CI system. The CI system is setup to build test images to be used in a container, periodically, which include all the needed dependencies and common files that are shared across test runs to improve test times. For dub this implies that dub packages that are needed during the tests are fetched + built during the building of the CI images, not when running tests. However, the packages were built with `dub build --compiler=... <pkg>` which would log to stdout that it built <pkg> debug configuration with <comp> on x86_64. During the tests meson would fail to find the built packages because of the `--arch` switch it used internally and it recommended that the package should be built with `--compiler=<comp> --build=debug --arch=x86_64` witch is exactly what dub reported the package was built with. This has lead to frustrating debugging and the install scripts calling dub like `dub run --yes dub-build-deep -- <pkg> --arch=x86_64 --compiler=<comp> --build=debug` because nobody can figure out what flags are actually needed. Signed-off-by: Andrei Horodniceanu <a.horodniceanu@proton.me>
- Loading branch information
Showing
7 changed files
with
115 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
name "ignore-useless-arch-switch" | ||
targetType "executable" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import std.json; | ||
import std.path; | ||
import std.process; | ||
import std.stdio; | ||
|
||
string getCacheFile (in string[] program) { | ||
auto p = execute(program); | ||
with (p) { | ||
if (status != 0) { | ||
assert(false, "Failed to invoke dub describe: " ~ output); | ||
} | ||
return output.parseJSON["targets"][0]["cacheArtifactPath"].str; | ||
} | ||
} | ||
|
||
void main() | ||
{ | ||
version (X86_64) | ||
string archArg = "x86_64"; | ||
else version (X86) | ||
string archArg = "x86"; | ||
else { | ||
string archArg; | ||
writeln("Skipping because of unsupported architecture"); | ||
return; | ||
} | ||
|
||
const describeProgram = [ | ||
environment["DUB"], | ||
"describe", | ||
"--compiler=" ~ environment["DC"], | ||
"--root=" ~ __FILE_FULL_PATH__.dirName.dirName, | ||
]; | ||
immutable plainCacheFile = describeProgram.getCacheFile; | ||
|
||
const describeWithArch = describeProgram ~ [ "--arch=" ~ archArg ]; | ||
immutable archCacheFile = describeWithArch.getCacheFile; | ||
|
||
assert(plainCacheFile == archCacheFile, "--arch shouldn't have modified the cache file"); | ||
} |