-
Notifications
You must be signed in to change notification settings - Fork 263
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
Standard libraries and separate compilation #5981
base: master
Are you sure you want to change the base?
Standard libraries and separate compilation #5981
Conversation
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.
Love the option, just quibbling about default behavior and documentation.
I think it's worth mentioning this option in https://github.com/dafny-lang/dafny/blob/master/Source/DafnyStandardLibraries/README.md too, so users are more likely to discover it.
if (options.Backend is LibraryBackend) { | ||
options.Set(CommonOptionBag.TranslateStandardLibrary, false); | ||
} | ||
|
||
// For now the standard libraries are still translated from scratch. | ||
// This breaks separate compilation and will be addressed in https://github.com/dafny-lang/dafny/pull/4877 |
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 think you're addressing "this breaks separate compilation" with this change so just that part of the comment can be removed, although I think the rest still applies (although I think we might publish the libraries separately rather than embed them in the runtimes)
if (Options.Backend is LibraryBackend) { | ||
Options.Set(CommonOptionBag.TranslateStandardLibrary, false); | ||
} | ||
|
||
// For now the standard libraries are still translated from scratch. | ||
// This breaks separate compilation and will be addressed in https://github.com/dafny-lang/dafny/pull/4877 |
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.
Ditto
@@ -102,6 +102,7 @@ static DafnyCommands() { | |||
CommonOptionBag.NewTypeInferenceDebug, | |||
Method.ReadsClausesOnMethods, | |||
CommonOptionBag.UseStandardLibraries, | |||
CommonOptionBag.TranslateStandardLibrary, |
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.
Shouldn't it be a translation option? It doesn't make sense to pass this to resolve
or verify
@"Currently Dafny does not prevent separately built Dafny projects from each including the standard library, | ||
leading to conflicts. When combining such projects, please ensure that only one of them has --translate-standard-library set to true. |
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.
The first sentence feels overly defensive to me, but it might be because we see the current state differently. I don't think it's inherently wrong to merge doo files personally, building larger aggregate libraries, as long as you don't use them incorrectly.
public static readonly Option<bool> TranslateStandardLibrary = new("--translate-standard-library", () => true, | ||
@"Currently Dafny does not prevent separately built Dafny projects from each including the standard library, | ||
leading to conflicts. When combining such projects, please ensure that only one of them has --translate-standard-library set to true. | ||
When building a Dafny library (.doo file), this option will automatically be set to false. |
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.
This feels like it's going to be confusing and hard to debug, especially since it's a change in behavior. Wouldn't it be better to fail instead, and make users set --translate-standard-library:false
explicitly?
Fixes dafny-lang/dafny-gradle-plugin#11
What was changed?
--translate-standard-library
that enables using--standard-libraries
in conjunction with separate compilationHow has this been tested?
comp/separate-compilation/standard-libaries/user.dfy
By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.