-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add a full.carbon
min-prelude that pulls in the full production prelude
#5703
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
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 get the impression, though haven't looked closely, that file_test is pretty well tested independently of the specific carbon use case where possible - so maybe it'd be possible/valuable to split this patch in two - one to implement the new extra args support including generic tests for that (it's possibly I'm speculating too rampantly and it's not practical to do this... ), and then separately support for... actually I guess there's two steps here - support+tests for expect-full-prelude, and support+tests for multiple exclude-dump-file-prefixes?
for (auto prefix : options_->exclude_dump_file_prefixes) { | ||
if (unit->input_filename().starts_with(prefix)) { | ||
return false; | ||
} | ||
} | ||
return 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.
Could write this as:
return llvm::none_of(options_->exclude_dump_file_prefixes, [&](auto prefix) { return unit->inut_filename().starts_with(prefix); });
I sometimes find the predicate form a bit more readable, but it's certainly marginal/debateable.
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.
Oh that's nice, yeah, thanks. Done.
Note this is tested by toolchain/lower/testdata/operators/arithmetic.carbon
using the full.carbon prelude, which then has 2 paths that need to be excluded in semir. If this is wrong, we get more (unwanted) semir output in the test. For example:
+// CHECK:STDOUT: ; ModuleID = 'min_prelude/full.carbon'
+// CHECK:STDOUT: source_filename = "min_prelude/full.carbon"
+// CHECK:STDOUT:
+// CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
+// CHECK:STDOUT: !llvm.dbg.cu = !{!2}
...
Or:
+// CHECK:STDOUT: ; ModuleID = '/private/var/tmp/_bazel_danakj/1c85fcb7c35d2ecb3905beb34bfff611/execroot/_main/bazel-out/darwin_arm64-dbg/bin
/toolchain/install/prefix_root/lib/carbon/../../lib/carbon/core/io.carbon'
+// CHECK:STDOUT: source_filename = "/private/var/tmp/_bazel_danakj/1c85fcb7c35d2ecb3905beb34bfff611/execroot/_main/bazel-out/darwin_arm64-db
g/bin/toolchain/install/prefix_root/lib/carbon/../../lib/carbon/core/io.carbon"
+// CHECK:STDOUT:
+// CHECK:STDOUT: define i32 @_CEOF.Core() !dbg !4 {
+// CHECK:STDOUT: entry:
+// CHECK:STDOUT: ret i32 -1, !dbg !7
+// CHECK:STDOUT: }
...
Oh I will have to look, I haven't really poked at tests of file_test before. I can't test expect-full-prelude itself in this PR really since it does nothing yet, until we get all tests using a min-prelude, though I test that it does nothing successfully by including it in one test file. |
I guess you're thinking of //testing/file_test tests, but these changes are not general for file_test as a testing platform, they are specific to the toolchain's implementation of file_test (changes are all under //toolchain/testing/, preludes are a toolchain-specific concept). We don't have tests at that level, and the file tests themselves are themselves mostly tests of it - the semir output being what we expect requires the prelude inclusion, and path exclusion, to be correct. When they are wrong, the semir output changes. The one thing not tested is that we make an error when no prelude flag is passed, but we don't do that yet. I can instantiate and mock out parts of ToolchainFileTest but that will require a fairly large refactoring. How much risk do you think there is of the error stopping working and us not noticing? |
Ah, yep. Makes sense - thanks for looking/explaining and sorry for the dead end suggestion. |
Trying to figure out an easy way to debug semir in the prelude, #5703 removed an option to set `--exclude-dump-file-prefix` to empty. But, this is probably an improvement over that flow... With this change, it's possible to add `//@dump-sem-ir-file` to a specific prelude file, and its full IR will be printed. Additionally, it becomes an option with the default `--dump-sem-ir-ranges=only` to add `//@dump-sem-ir-file` and get the full file's IR.
The
full.carbon
prelude just sets a flag indicating an explicit intent to include the full prelude. Once all tests include some prelude file, an error can be enabled (currently it's commented out) that requires anINCLUDE-FILE
of some min-prelude to be present in allcheck/
andlower/
file tests.