From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1873) id 63B1C385783A; Sat, 10 Apr 2021 15:22:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 63B1C385783A Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Iain Buclaw To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/ibuclaw/heads/mingw)] Fix hello world with std.stdio X-Act-Checkin: gcc X-Git-Author: Iain Buclaw X-Git-Refname: refs/users/ibuclaw/heads/mingw X-Git-Oldrev: 8ca3da33932e4c8fc889c822111e912224c1cdf6 X-Git-Newrev: b063aded0533fb19b406f5ca2bec334eb1faded3 Message-Id: <20210410152223.63B1C385783A@sourceware.org> Date: Sat, 10 Apr 2021 15:22:23 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2021 15:22:23 -0000 https://gcc.gnu.org/g:b063aded0533fb19b406f5ca2bec334eb1faded3 commit b063aded0533fb19b406f5ca2bec334eb1faded3 Author: Iain Buclaw Date: Wed Mar 24 22:11:10 2021 +0100 Fix hello world with std.stdio Diff: --- libphobos/configure | 74 +++++++++++++++++++++++++++++++ libphobos/configure.ac | 1 + libphobos/libdruntime/config/mingw/msvc.c | 21 ++++----- libphobos/m4/druntime/libraries.m4 | 14 ++++++ 4 files changed, 98 insertions(+), 12 deletions(-) diff --git a/libphobos/configure b/libphobos/configure index fe7cd9c11ff..e483fcd8360 100755 --- a/libphobos/configure +++ b/libphobos/configure @@ -15067,6 +15067,80 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu fi + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + case "$druntime_cv_target_os" in + mingw*) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing _fputc_nolock" >&5 +$as_echo_n "checking for library containing _fputc_nolock... " >&6; } +if ${ac_cv_search__fputc_nolock+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char _fputc_nolock (); +int +main () +{ +return _fputc_nolock (); + ; + return 0; +} +_ACEOF +for ac_lib in '' ucrtbase; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search__fputc_nolock=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search__fputc_nolock+:} false; then : + break +fi +done +if ${ac_cv_search__fputc_nolock+:} false; then : + +else + ac_cv_search__fputc_nolock=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search__fputc_nolock" >&5 +$as_echo "$ac_cv_search__fputc_nolock" >&6; } +ac_res=$ac_cv_search__fputc_nolock +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + + ;; + esac + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + druntime_check_both=no ac_fn_c_check_func "$LINENO" "connect" "ac_cv_func_connect" if test "x$ac_cv_func_connect" = xyes; then : diff --git a/libphobos/configure.ac b/libphobos/configure.ac index 3b5a830cccf..1b1ce5008f0 100644 --- a/libphobos/configure.ac +++ b/libphobos/configure.ac @@ -160,6 +160,7 @@ WITH_LOCAL_DRUNTIME([ DRUNTIME_LIBRARIES_ATOMIC DRUNTIME_LIBRARIES_BACKTRACE DRUNTIME_LIBRARIES_DLOPEN +DRUNTIME_LIBRARIES_IO DRUNTIME_LIBRARIES_NET DRUNTIME_LIBRARIES_UCONTEXT DRUNTIME_LIBRARIES_ZLIB diff --git a/libphobos/libdruntime/config/mingw/msvc.c b/libphobos/libdruntime/config/mingw/msvc.c index 25b15a06950..85ce3741bca 100644 --- a/libphobos/libdruntime/config/mingw/msvc.c +++ b/libphobos/libdruntime/config/mingw/msvc.c @@ -27,17 +27,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see /* The symbols for stdin, stdout, and stderr are defined for D in the core.stdc.stdio module. Save the macros and redeclare them here. */ -#define c_stdin stdin -#undef stdin -extern FILE *stdin; +__attribute__((weakref ("stdin"))) +static FILE *core_stdc_stdin; -#define c_stdout stdout -#undef stdout -extern FILE *stdout; +__attribute__((weakref ("stdout"))) +static FILE *core_stdc_stdout; -#define c_stderr stderr -#undef stderr -extern FILE *stderr; +__attribute__((weakref ("stderr"))) +static FILE *core_stdc_stderr; /* Set to 1 if run-time is using ucrtbase.dll. */ unsigned char msvcUsesUCRT; @@ -48,7 +45,7 @@ void init_msvc() msvcUsedUCRT = 1; #endif - stdin = c_stdin; - stdout = c_stdout; - stderr = c_stderr; + core_stdc_stdin = stdin; + core_stdc_stdout = stdout; + core_stdc_stderr = stderr; } diff --git a/libphobos/m4/druntime/libraries.m4 b/libphobos/m4/druntime/libraries.m4 index 743d3e3e17c..194602c1bf1 100644 --- a/libphobos/m4/druntime/libraries.m4 +++ b/libphobos/m4/druntime/libraries.m4 @@ -233,3 +233,17 @@ AC_DEFUN([DRUNTIME_LIBRARIES_UCONTEXT], AC_MSG_ERROR([swapcontext required but not found])) fi ]) + +# DRUNTIME_LIBRARIES_IO +# ----------------------- +# Autodetect and add IO library to LIBS if necessary. +AC_DEFUN([DRUNTIME_LIBRARIES_IO], +[ + AC_LANG_PUSH([C]) + case "$druntime_cv_target_os" in + mingw*) + AC_SEARCH_LIBS([_fputc_nolock], [ucrtbase]) + ;; + esac + AC_LANG_POP([C]) +])