-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add message about non-release mode to crystal --version
#13254
Conversation
* Allow passing in git sha and date to Makefile * Remove empty parens when date is "" * Add message when compiler was not compiled in release mode When building in a nix derivation, there is no git directory, so you have to pass in the sha manually. Also, all the file modification times are set to epcoh, and I think it'd be nicer to just have the builds not have a date rather than the obviously wrong 1970-01-01. I don't think we need to always have release mode information, but it would be useful I think to have a way to see when you're working with a non-release compiler.
src/compiler/crystal/config.cr
Outdated
<<-DOC | ||
Crystal #{version} #{formatted_sha}(#{date}) | ||
Crystal #{version} #{formatted_sha}#{formatted_date} |
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.
If a date isn't available, the description would have a trailing space on this line
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.
Good catch, I updated it to use Enumerable#join
I would prefer to only add a note about release mode when the compiler is not built in release mode. Such a note is helpful if you use a development build of the compiler, so it's sufficient to to mention in that case. |
@straight-shoota that was my initial thought as well and it was that way with the first patch, before I applied @Sija's suggestions. I can put it back to only when not release. |
Maybe make it a normal sentence, though? "The compiler was not built in release mode." |
Ok I put it back to only in development mode and with a message. I figured an extra empty line makes it look nicer than with the two things with labels and colons.
Also fixed the extra trailing space by using I realized that I should have done the first review patch as a git fixup, so I fixed that with a force push, but it's otherwise the same commit to make it easier to track what changed. Then the second review fixes as a second fixup commit. Sorry about the force push, but I think it would have been more weird to have one review patch as a fixup and the other not. |
src/compiler/crystal/config.cr
Outdated
details = [version] | ||
details << "[#{build_commit}]" if build_commit | ||
details << "(#{date})" unless date.empty? |
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.
Using an array + join is fine, we can merge it with that. But it's suboptimal.
A better way would be what we had before, just with leading whitespace added to each optional piece. Or String.build
could also be an alternative.
This is an optional suggestion, my approval doesn't depend on it.
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 updated this with String.build just now
Using a sentence would make it harder to parse by a 3rd party tools. |
On a related note, IMO Crystal programs themselves should be able to know whether they are compiled under a release build of the compiler via |
In my case (raven.cr) I need to query these information from within the Crystal program, so using CLI is not an option. |
I don't think it makes any difference for machine readability if you grep the version config for |
|
The compiler spec failure on CI proves my point, as the failing spec expects that the last line of |
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 just have a minor suggestion to reorder the output. But apart from that I'm good.
src/compiler/crystal/config.cr
Outdated
io << "\n\nLLVM: " << llvm_version | ||
io << "\nDefault target: " << host_target | ||
|
||
io << "\n\nThe compiler was not built in release mode." unless release_mode? |
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.
In light of #13254 (comment) I would suggest to put this not in the last line. I think it also makes more sense semantically as a second line, after the compiler build info, and before the LLVM version.
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.
What if someone else tries to get the host target from Crystal::DESCRIPTION.lines[3]
instead? You cannot avoid a breakage either way so I wouldn't worry about which line the new text shows up on
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.
Yeah, it's not a strong improvement (although I would argue that lines[-1]
is much more obvious than lines[3]
).
But I also think it makes more sense semantically after the build info.
Crystal::Config.description
Crystal::Config.description
crystal --version
When building in a nix derivation, there is no git directory, so you have to pass in the sha manually. Also, all the file modification times are set to epcoh, and I think it'd be nicer to just have the builds not have a date rather than the obviously wrong 1970-01-01.
I don't think we need to always have release mode information, but it would be useful I think to have a way to see when you're working with a non-release compiler.