-
Notifications
You must be signed in to change notification settings - Fork 274
add git shortened sha1sum to CBMC version for unique id #668
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
Conversation
I think this is a very good idea; yet I'd have a slightly different proposal lying around that I'd like to put forward for discussion. I'll post a link to a branch in a few minutes. |
I am curious to see this. Obviously my approach is not mergeable right away as it does not format nicely in the CBMC |
I have pushed tautschnig/cbmc@6694d4e - comments much appreciated. |
@mgudemann I'll move the discussion in here if that's ok? Just to have the full trail in one place. Quoting yourself in the context of my use of @mgudemann said in tautschnig/cbmc@6694d4e:
Quite frankly I wasn't aware of The key difference between our approaches is the use of command-line defines vs generating a file. Can the file-base approach deal with uncommitted changes? |
|
I have no useful opinion on which to pick but I'd really like that one
of them is picked. This will make my job working with customers much
easier!
|
I think @tautschnig's solution is better, this together with |
@mgudemann Would you mind doing the following, in an attempt to preserve the discussion: cherry-pick my commit into your branch for this pull request, possibly discard your commit, and add the suggested improvements such as using |
A luxury variant of this would recognise that a particular version is a release, and then mark it as such. |
@kroening I believe we would actually get that via the proposed |
68d4ed6
to
f8b3ab9
Compare
@tautschnig I took your commit and adapted to current master |
The benefit of the earlier variant was that the build system would notice that a new version got checked out, and then re-build the files that include version.h. Right now, that will only work when a manual 'make clean' is issued. |
@kroening Isn't that only an issue when placing a tag? Any code changes would obviously trigger a rebuild and therefore the binaries would have the most up-to-date version information. If the only change is the version (but no files have been touched), then the only case where that can occur is when a tag has been placed. This seems to be a quarterly activity (at most), hence it might be acceptable to do |
Yes, code changes would trigger a rebuild, but not necessarily to the file that prints the version number; i.e., you would get a binary that has a hash in that is inconsistent with the code that was compiled. |
Ah, of course, apologies for missing that. There should actually be a setup such that a file is re-built whenever the version string changes. I'll think about a suitable make rule. |
how about
and adding git_new_version to the relevant build goals ? |
@mgudemann My concern here is that it wouldn't update on a dirty code base!? |
@martin-cs @mgudemann @kroening For identifying a version used by DiffBlue customers we use versioning from https://github.com/diffblue/platform/tree/develop/docker (private repo). The customers won't directly run cbmc from command line, so whatever approach is implemented here, they will not see it. |
Here's how to make the version string update (not sure tabs paste well):
|
@tautschnig you could attach the patch, as zip if it doesn't work directly |
I'm sorry, I should have done that before: |
@forejtv There are two important use cases for this. One is me looking at logs to work out what is going wrong and being able to remotely replicate what is happening on customer sites -- they may not see it but I will. Second is for https://github.com/diffblue/test-gen/issues/187 . Both of these are causing pain in supporting customers so please could we remove the do not merge? @tautschnig @mgudemann Can't this be done with simple keyword substitution in one file, like subversion would? Apparently https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes#Keyword-Expansion gives a recipe for this. |
@forejtv I actually don't know why this is marked do-not-merge? @martin-cs Thanks for the pointer to keyword substitution! Yet I'm not sure there's a genuine problem with the proposed solution? Note that keyword substitution won't cover the local-changes-in-repository problem, which the proposed patch does address. |
I'll refrain from approving a PR that contains changes by myself ;-) For regression tests, actually the keyword expansion might come into play: we could have a test that checks that the specific git commit id is included in the --version output. |
@tautschnig one thing I saw is this
maybe better have something like
|
Indeed; how about
to make the implementation via |
@tautschnig we have this now
|
@forejtv I think this is becoming mergeable |
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 am not able to figure out how I should test this. When I check the branch out and compile, I don't see a git sha anywhere when I run cbmc
, cbmc -help
or cbmc --version
, I am always just getting "5.7".
What should I be running to see the sha?
@forejtv That's rather surprising. I've just done this:
(And you should also see |
@@ -53,6 +53,14 @@ CLEANFILES = cbmc$(EXEEXT) | |||
|
|||
all: cbmc$(EXEEXT) | |||
|
|||
ifeq ($(BUILD_ENV_),MSVC) | |||
CP_CXXFLAGS += /DCBMC_TAG_VERSION='"""$(CBMC_VERSION)"""' \ | |||
/DCBMC_VERSION='"""($(GIT_INFO))"""' |
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.
Why is this different from https://github.com/diffblue/cbmc/pull/668/files#diff-d9c95ec27fc25a0481354de531adad56R34?
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.
When I delete the .git
directory before compiling, as a result I get
CBMC version (n/a) 64-bit x86_64 linux
Is that expected? We're still keeping version info in https://github.com/diffblue/cbmc/pull/668/files/4df4a36b894fdf1f5fcfe4ad196505f2d334e36e#diff-b4a2f4e2f20572b496e8590dcf1dec51R33, so maybe that one should be used, with some suffix indicating that the version cannot be determined?
@tautschnig It worked for me on the next compilation attempt, I must have had a bad day. |
Ok, good to know it worked. Your concerns are of course valid and need a solution. |
The key problem I see is that this requires a 'make clean' to make sure that all files that use the define get recompiled. Is there an intend to add dependencies on .release_info? The key benefit of using an include is that the dependency system takes care of incremental builds. Thus, I'd suggest:
|
The dependencies are addressed via changes to common - and it would be possible to use the .release_info files for grabbing the version string. |
@mgudemann Any chance to push this further? |
@mgudemann Is there any chance you might be able to progress this PR? Do let me know if you'd like to hand off this PR to someone else. I'm repeatedly running into the issue that people have results with some version of CBMC and we then cannot figure out what exact source version that had been compiled from. |
+1 would love to see this functionality merged. |
+1 would love to see this too. |
I'm happy to create a new PR to drive this myself, but I don't want to do what could be seen as a hostile takeover as @mgudemann hasn't commented on this. |
@tautschnig I am happy with you taking this over. For TG we have a cmake solution, we should keep that in mind when adding that to CBMC / JBMC. |
Taking over work on this in #2373. |
this adds the output of
git describe --tags --always
to the CBMC version string, making exact identification of a binary CBMC version possible.