print functions require FILE and stdout to be available and cause
compilation errors on platforms that don't support the file system.
Details
- Reviewers
Mordante philnik - Group Reviewers
Restricted Project - Commits
- rG1cf970db4e54: [libc++][print] Make `<print>` tests require file system support.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
libcxx/utils/libcxx/test/header_information.py | ||
---|---|---|
48 | Language modes are a drive-by fix. |
I would really like it if we could add headers that make these kinds of things break. We should really look into using LLVM libc with the corresponding parts removed to improve the situation here. That being said, I think this patch is OK as-is. Leaving final approval to @Mordante, since he is the author of these utilities.
Yep, I was thinking of the same while working on this patch (e.g. the no-filesystem test should do something to make sure including a header that touches the file system would fail to compile).
I'm not against this patch, but I would like to investigate a bit further. When FILE is not available we will run into issues building the dylib. src/print.cpp includes <print> which has FILE in its interface. This works now because we build the dylib with C++20, but I expect it will fail when we switch to C++23. I have another patch for print(ostream&...) this patch uses FILE in the dylib, so that is another potential issue before we switch to C++23. Can you test whether changing building the dylib with C++23 works on the platform in question?
I wonder whether no-filesystem is intended to mean no cstdio. If this patch is not urgent I would like to discuss it when Louis is back. If it's urgent we can finish the patch and discuss afterwards.
libcxx/test/std/input.output/iostream.format/print.fun/lit.local.cfg | ||
---|---|---|
1 | Why do we need this? AFAIK we normally don't do this. Typically we disable all tests manually. | |
libcxx/utils/libcxx/test/header_information.py | ||
48 | Thanks good catch. |
It's somewhat urgent -- this patch is necessary to fix our internal build.
If I switch to C++23, I get the FILE-related errors while compiling print.cpp like you described.
I was trying to follow the approach previously laid out in https://reviews.llvm.org/D152168 for this patch. D152168 combined the check for support for <filesystem> and <fstream> into a single macro, which makes me feel we shouldn't introduce a separate macro for <cstdio>. There are platforms that don't provide FILE, so I believe we need some macro to express that, the only question is whether we want to combine it with no-filesystem or not.
libcxx/test/std/input.output/iostream.format/print.fun/lit.local.cfg | ||
---|---|---|
1 | This approach is used heavily in test/std/input.output, mostly to disable tests if localization is not available (there are 10 existing lit.local.cfg files in that directory). I did it this way mostly for consistency. |
As discussed on Discord, I'm happy to approve this now and look at a better solution later.
If I switch to C++23, I get the FILE-related errors while compiling print.cpp like you described.
Thanks for the confirmation.
LGTM modulo comments.
libcxx/test/std/input.output/iostream.format/print.fun/lit.local.cfg | ||
---|---|---|
1 | As discussed on Discord I prefer to use the explicit // UNSUPPORTED: no-filesystem to keep tests self-contained. |
Why do we need this? AFAIK we normally don't do this. Typically we disable all tests manually.