Skip to content
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

Replace printf with cout in JitCall tests #501

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aaronj0
Copy link
Collaborator

@aaronj0 aaronj0 commented Feb 12, 2025

This hints towards a larger underlying problem in the driver when going through cling: On windows, the stdout buffer is not flushed. With gtest, all the printf statements in functions invoked with JitCall like: void f2(std::string &s) { std::cout << s.c_str(); }; appear at the end of the test suite run. Attempting to fix this issue by force flushing does not work, and printf statements in the test code itself appear on the screen. This indicates issues with linking, since the Interpreter runtime operating on a different buffer than the compile runtime. We ideally want to support the usage of printf statements when invoked through JitCall

@aaronj0 aaronj0 requested a review from vgvassilev February 12, 2025 13:08
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Comment on lines +878 to +881
// Here we replace printf with cout for JitCall tests on Windows, where the stdout buffer is not flushed when we utilise JitCall::Invoke
// This hints towards a larger underlying problem in the driver when going through cling: On windows, the `stdout` buffer is not flushed. With gtest, all the printf statements in functions invoked with `JitCall` like:
// `void f2(std::string &s) { std::cout << s.c_str(); };` appear at the end of the test suite run. Attempting to fix this issue by force flushing does not work, and printf statements in the test code itself appear on the screen. This indicates issues with linking, since the Interpreter runtime operating on a different buffer than the compile runtime. We ideally want to support the usage of printf statements when invoked through `JitCall`.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd open an issue with that text and mark disable these tests on windows.

Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Copy link

codecov bot commented Feb 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.17%. Comparing base (b797dbb) to head (6e9dafe).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #501   +/-   ##
=======================================
  Coverage   71.17%   71.17%           
=======================================
  Files           9        9           
  Lines        3552     3552           
=======================================
  Hits         2528     2528           
  Misses       1024     1024           

@mcbarton
Copy link
Collaborator

@aaronj0 @vgvassilev Basically anything that tries to write to stdout and stdcerr will fail on Windows. Tests that try to do this are the ones I had to disable previously, to remove continue on error on Windows. This is not just a Cling issue. The PR I am referencing is here https://github.com/compiler-research/CppInterOp/pull/313/files#diff-8c5a89c16b6f30f9e3333ab9dd311a7b915d32a4acf44fdd8fa4b5077f99dfca

Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@@ -875,9 +875,14 @@ TEST(FunctionReflectionTest, GetFunctionCallWrapper) {

GetAllTopLevelDecls(code, Decls);

// Here we replace printf with cout for JitCall tests on Windows, where the stdout buffer is not flushed when we utilise JitCall::Invoke
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mcbarton, how could clang-format be happy with these lengthy lines?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If your asking why doesn't it complain, then its because for some reason the clang-format workflow isn't detecting the changed files (see https://github.com/compiler-research/CppInterOp/actions/runs/13305769758/job/37156307205?pr=501#step:5:25)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think maybe we exclude the folder from formatting... which is probably fine...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes your right. We don't technically disclude it, but only reference the include and lib folder in the clang-format command (see https://github.com/compiler-research/CppInterOp/blob/b797dbb4c8134349a1207d01b24dc3c4d93158de/.github/workflows/clang-format.yml#L44C1-L44C93). Maybe its something that was overlooked in the workflow.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that was intentional.

Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@aaronj0 aaronj0 marked this pull request as draft February 13, 2025 11:27
This hints towards a larger underlying problem in the driver when going through cling: On windows, the `stdout` buffer is not flushed. With gtest, all the printf statements in functions invoked with `JitCall` like:
`void f2(std::string &s) { std::cout << s.c_str(); };` appear at the end of the test suite run. Attempting to fix this issue by force flushing does not work, and printf statements in the test code itself appear on the screen. This indicates issues with linking, since the Interpreter runtime operating on a different buffer than the compile runtime. We ideally want to support the usage of printf statements when invoked through `JitCall`.
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants