This is an archive of the discontinued LLVM Phabricator instance.

[libc++][print] Make `<print>` tests require file system support.
ClosedPublic

Authored by var-const on Jul 28 2023, 6:23 PM.

Details

Summary

print functions require FILE and stdout to be available and cause
compilation errors on platforms that don't support the file system.

Diff Detail

Event Timeline

var-const created this revision.Jul 28 2023, 6:23 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 28 2023, 6:23 PM
Herald added a subscriber: arichardson. · View Herald Transcript
var-const requested review of this revision.Jul 28 2023, 6:23 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 28 2023, 6:23 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
var-const added inline comments.Jul 28 2023, 6:24 PM
libcxx/utils/libcxx/test/header_information.py
48

Language modes are a drive-by fix.

philnik accepted this revision as: philnik.Jul 28 2023, 6:28 PM
philnik added a subscriber: philnik.

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.

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.

var-const marked 2 inline comments as done.Jul 31 2023, 2:40 PM

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.

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.

Mordante accepted this revision.Jul 31 2023, 11:25 PM

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.

It's somewhat urgent -- this patch is necessary to fix our internal build.

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.

This revision is now accepted and ready to land.Jul 31 2023, 11:25 PM
var-const updated this revision to Diff 546243.Aug 1 2023, 3:24 PM
var-const marked 2 inline comments as done.

Address feedback

This revision was landed with ongoing or failed builds.Aug 4 2023, 12:24 AM
This revision was automatically updated to reflect the committed changes.

Note: I believe the CI issues are unrelated and spurious.