-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Makefile caching helpers for lazy, expensive evaluations
Makefiles natively offer two variable expansion modes: immediate and deferred. When expanding variables that require invocations of external programs (such as `llvm-config`) immediate expansion is almost always preferred, as it will run the external command once, exactly when the makefile variable is defined. Deferred mode, on the other hand, will expand the variable every time it is used, running the external program again and again. When the external program is expensive, this cost can slow down the build significantly, however when the external program requires some setup (for instance, when it itself is downloaded through other rules in the Makefile) it cannot always be immediately expanded. To address this, we build a caching layer that allows for deferred expansion, but once it has been expanded once, the variable is replaced with the result of running the command, and further hits to the same variable will return the cached value. (With the slight caveat that an empty result will cause the external command to be run again in the future). As an example usecase, this commit converts our relative path calculation to use a python script and showcases how to cache this operation. This will be used for further JLL stdlib work where the invocation is much more expensive.
- Loading branch information
1 parent
a645d7f
commit ad907d5
Showing
8 changed files
with
61 additions
and
47 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
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,10 @@ | ||
import sys, os | ||
if len(sys.argv) != 3: | ||
sys.stderr.write("\nrelative_path.py - incomplete arguments: %s\n"%(sys.argv)) | ||
sys.exit(1) | ||
|
||
# We always use `/` as the path separator, no matter what OS we're running on, since our | ||
# shells and whatnot during the build are all POSIX shells/cygwin. We rely on the build | ||
# system itself to canonicalize to `\` when it needs to, and deal with the shell escaping | ||
# and whatnot at the latest possible moment. | ||
sys.stdout.write(os.path.relpath(sys.argv[2], sys.argv[1]).replace(os.path.sep, '/')) |
This file was deleted.
Oops, something went wrong.
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