From 582a90e9178e4beefa8a0e9e4b98b53c006c36a5 Mon Sep 17 00:00:00 2001 From: Victor Perevertkin Date: Thu, 15 Aug 2019 21:45:48 +0300 Subject: [PATCH 1/3] [MSVCRTEX] Add the implementation of __acrt_iob_func --- sdk/lib/crt/msvcrtex.cmake | 3 ++- sdk/lib/crt/stdio/acrt_iob_func.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 sdk/lib/crt/stdio/acrt_iob_func.c diff --git a/sdk/lib/crt/msvcrtex.cmake b/sdk/lib/crt/msvcrtex.cmake index c46751007ada5..5be20560a53cb 100644 --- a/sdk/lib/crt/msvcrtex.cmake +++ b/sdk/lib/crt/msvcrtex.cmake @@ -39,7 +39,8 @@ list(APPEND MSVCRTEX_SOURCE misc/fltused.c misc/isblank.c misc/iswblank.c - misc/ofmt_stub.c) + misc/ofmt_stub.c + stdio/acrt_iob_func.c) if(MSVC) list(APPEND MSVCRTEX_SOURCE diff --git a/sdk/lib/crt/stdio/acrt_iob_func.c b/sdk/lib/crt/stdio/acrt_iob_func.c new file mode 100644 index 0000000000000..6ca100fe61e74 --- /dev/null +++ b/sdk/lib/crt/stdio/acrt_iob_func.c @@ -0,0 +1,16 @@ +/* + * PROJECT: ReactOS CRT library + * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later) + * PURPOSE: __acrt_iob_func implementation + * COPYRIGHT: Victor Perevertkin + */ + +#include + +/********************************************************************* + * __acrt_iob_func(MSVCRT.@) + */ +FILE * CDECL __acrt_iob_func(int index) +{ + return &__iob_func()[index]; +} From 60e1daa96af0d04f886296688d0a751d846a7d8e Mon Sep 17 00:00:00 2001 From: Colin Finck Date: Sat, 19 Oct 2019 16:07:58 +0200 Subject: [PATCH 2/3] Add an evil hack to persuade libstdc++, which tries to import __acrt_iob_func from a DLL. This can only be solved cleanly by adding a GCC-compatible C++ standard library to our tree. --- sdk/lib/crt/stdio/acrt_iob_func.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sdk/lib/crt/stdio/acrt_iob_func.c b/sdk/lib/crt/stdio/acrt_iob_func.c index 6ca100fe61e74..c53a3733a34ee 100644 --- a/sdk/lib/crt/stdio/acrt_iob_func.c +++ b/sdk/lib/crt/stdio/acrt_iob_func.c @@ -14,3 +14,7 @@ FILE * CDECL __acrt_iob_func(int index) { return &__iob_func()[index]; } + +// Evil hack necessary, because we're linking to the RosBE-provided libstdc++ when using GCC. +// This can only be solved cleanly by adding a GCC-compatible C++ standard library to our tree. +const void* _imp____acrt_iob_func = __acrt_iob_func; From 26d2a1b6097f208b6ac21f59cfe46c84de24489a Mon Sep 17 00:00:00 2001 From: Colin Finck Date: Sun, 20 Oct 2019 00:16:25 +0200 Subject: [PATCH 3/3] Make the entire __acrt_iob_func hack GCC-only as it's not needed for our MSVC builds. --- sdk/lib/crt/stdio/acrt_iob_func.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sdk/lib/crt/stdio/acrt_iob_func.c b/sdk/lib/crt/stdio/acrt_iob_func.c index c53a3733a34ee..223ea36b5fa34 100644 --- a/sdk/lib/crt/stdio/acrt_iob_func.c +++ b/sdk/lib/crt/stdio/acrt_iob_func.c @@ -5,6 +5,10 @@ * COPYRIGHT: Victor Perevertkin */ +// Evil hack necessary, because we're linking to the RosBE-provided libstdc++ when using GCC. +// This can only be solved cleanly by adding a GCC-compatible C++ standard library to our tree. +#ifdef __GNUC__ + #include /********************************************************************* @@ -15,6 +19,6 @@ FILE * CDECL __acrt_iob_func(int index) return &__iob_func()[index]; } -// Evil hack necessary, because we're linking to the RosBE-provided libstdc++ when using GCC. -// This can only be solved cleanly by adding a GCC-compatible C++ standard library to our tree. const void* _imp____acrt_iob_func = __acrt_iob_func; + +#endif