Skip to content

Commit 36a1258

Browse files
committed
Replace printf with cout in JitCall tests
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`.
1 parent b797dbb commit 36a1258

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,8 @@ if(MSVC)
466466
_Init_thread_footer
467467
?nothrow@std@@3Unothrow_t@1@B
468468
??_7type_info@@6B@
469+
__emutls_v._Init_thread_epoch
470+
__emutls_get_address
469471
)
470472

471473
if(CMAKE_SIZEOF_VOID_P EQUAL 8)

unittests/CppInterOp/FunctionReflectionTest.cpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -875,9 +875,14 @@ TEST(FunctionReflectionTest, GetFunctionCallWrapper) {
875875

876876
GetAllTopLevelDecls(code, Decls);
877877

878+
// Here we replace printf with cout for JitCall tests on Windows, where the stdout buffer is not flushed when we utilise JitCall::Invoke
879+
// 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:
880+
// `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`.
881+
878882
Interp->process(R"(
879883
#include <string>
880-
void f2(std::string &s) { printf("%s", s.c_str()); };
884+
#include <iostream>
885+
void f2(std::string &s) { std::cout << s.c_str(); };
881886
)");
882887

883888
Interp->process(R"(
@@ -922,10 +927,11 @@ TEST(FunctionReflectionTest, GetFunctionCallWrapper) {
922927

923928
// FIXME: Do we need to support private ctors?
924929
Interp->process(R"(
930+
#include <iostream>
925931
class C {
926932
public:
927-
C() { printf("Default Ctor Called\n"); }
928-
~C() { printf("Dtor Called\n"); }
933+
C() { std::cout << "Default Ctor Called\n"; }
934+
~C() { std::cout << "Dtor Called\n"; }
929935
};
930936
)");
931937

0 commit comments

Comments
 (0)