Skip to content
This repository was archived by the owner on Feb 4, 2020. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion clcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,21 @@ def getManifestHash(compilerBinary, commandLine, sourceFile):
# One of the few exceptions to this rule is the /MP switch, which only
# defines how many compiler processes are running simultaneusly.
commandLine = [arg for arg in commandLine if not arg.startswith("/MP")]
arguments, inputFiles = CommandLineAnalyzer.parseArgumentsAndInputFiles(commandLine)
collapseBasedirInCmdPath = lambda path: collapseBasedirToPlaceholder(os.path.normcase(os.path.abspath(path)))

commandLineArgs = []
projectSpecificArgs = ("AI", "I", "FU")
for k in sorted(arguments.keys()):

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you use sorted here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually the sorted is very important to have repeatable manifest hashes. As dictionaries in python are unordered the only way to guarantee that we generate the same hash every invocation is to iterate over the keys in the same order. It is the same case that #235 solved.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, so this basically improves the manifest cache hit rate, i.e. it's an improvement but not directly related to the BASEDIR feature? Ok.

@siu siu Nov 8, 2016

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is going to have that side effect but at same time it is needed for correctness since the implementation changed in this PR to use a dictionary.

if k in projectSpecificArgs:
commandLineArgs.extend(["/" + k + collapseBasedirInCmdPath(arg) for arg in arguments[k]])
else:
commandLineArgs.extend(["/" + k + arg for arg in arguments[k]])

commandLineArgs.extend(collapseBasedirInCmdPath(arg) for arg in inputFiles)

additionalData = "{}|{}|{}".format(
compilerHash, commandLine, ManifestRepository.MANIFEST_FILE_FORMAT_VERSION)
compilerHash, commandLineArgs, ManifestRepository.MANIFEST_FILE_FORMAT_VERSION)
return getFileHash(sourceFile, additionalData)

@staticmethod
Expand Down