From patchwork Mon Apr 27 00:54:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1277269 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=oJpgtTO6; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 499RC331wVz9sRf for ; Mon, 27 Apr 2020 10:55:09 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F3D96384B0C0; Mon, 27 Apr 2020 00:55:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F3D96384B0C0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1587948906; bh=PsVAydIBtf2LQ8q989pbI8WrDpwNQsfv5DmIkiLMnNM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=oJpgtTO6KQgyXFq7usBJ7miTKiirGdTkVLiKBEpS5ndLbu1yzmQD8c9EuIXzX4aKV gN4eNsb9oYfJRZuHjvLlmfU5XsEfTelewq7Z8WzT5JkoVDCH9LKoutmoo09Gl0BPgo g0R1bzq/sH5CZE7RKaX64M6BPmkINyOQvaYkqVhU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by sourceware.org (Postfix) with ESMTPS id 041E2385DC1B for ; Mon, 27 Apr 2020 00:55:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 041E2385DC1B Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 499RBp5WzlzKmMr; Mon, 27 Apr 2020 02:54:58 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173]) (amavisd-new, port 10030) with ESMTP id netX1yFKr90C; Mon, 27 Apr 2020 02:54:54 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [committed] libphobos: Remove AC_CACHE_CHECK from network library tests. Date: Mon, 27 Apr 2020 02:54:51 +0200 Message-Id: <20200427005451.29931-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 7AAB61745 X-Rspamd-Score: 1.29 / 15.00 / 15.00 X-Spam-Status: No, score=-27.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi, This patch simplifies the socket library checks, as LIBS is the target variable ultimately being assigned to. The original comments from the deleted libjava directories have been restored as well. Regression tested on x86_64-linux-gnu, committed to mainline. Regards Iain. --- libphobos/ChangeLog: * configure: Regenerate. * m4/druntime/libraries.m4 (DRUNTIME_LIBRARIES_NET): Remove AC_CACHE_CHECK, simplify by setting LIBS directly. --- libphobos/configure | 103 ++++++++++++++--------------- libphobos/m4/druntime/libraries.m4 | 51 +++++++------- 2 files changed, 72 insertions(+), 82 deletions(-) diff --git a/libphobos/configure b/libphobos/configure index c923417532f..98d8dc255c1 100755 --- a/libphobos/configure +++ b/libphobos/configure @@ -14932,25 +14932,14 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket libraries" >&5 -$as_echo_n "checking for socket libraries... " >&6; } -if ${druntime_cv_lib_sockets+:} false; then : - $as_echo_n "(cached) " >&6 -else - druntime_cv_lib_sockets= - druntime_check_both=no - ac_fn_c_check_func "$LINENO" "connect" "ac_cv_func_connect" + druntime_check_both=no + ac_fn_c_check_func "$LINENO" "connect" "ac_cv_func_connect" if test "x$ac_cv_func_connect" = xyes; then : - druntime_check_socket=no -else - druntime_check_socket=yes -fi - if test "$druntime_check_socket" = "yes"; then - unset ac_cv_func_connect - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lsocket" >&5 -$as_echo_n "checking for main in -lsocket... " >&6; } -if ${ac_cv_lib_socket_main+:} false; then : +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for connect in -lsocket" >&5 +$as_echo_n "checking for connect in -lsocket... " >&6; } +if ${ac_cv_lib_socket_connect+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -14958,55 +14947,58 @@ LIBS="-lsocket $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 connect (); int main () { -return main (); +return connect (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_socket_main=yes + ac_cv_lib_socket_connect=yes else - ac_cv_lib_socket_main=no + ac_cv_lib_socket_connect=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_main" >&5 -$as_echo "$ac_cv_lib_socket_main" >&6; } -if test "x$ac_cv_lib_socket_main" = xyes; then : - druntime_cv_lib_sockets="-lsocket" +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_connect" >&5 +$as_echo "$ac_cv_lib_socket_connect" >&6; } +if test "x$ac_cv_lib_socket_connect" = xyes; then : + LIBS="$LIBS -lsocket" else druntime_check_both=yes fi - fi - if test "$druntime_check_both" = "yes"; then - druntime_old_libs=$LIBS - LIBS="$LIBS -lsocket -lnsl" - unset ac_cv_func_accept - ac_fn_c_check_func "$LINENO" "accept" "ac_cv_func_accept" +fi + + if test "$druntime_check_both" = "yes"; then + druntime_old_libs=$LIBS + LIBS="$LIBS -lsocket -lnsl" + ac_fn_c_check_func "$LINENO" "accept" "ac_cv_func_accept" if test "x$ac_cv_func_accept" = xyes; then : - druntime_check_nsl=no - druntime_cv_lib_sockets="-lsocket -lnsl" + +else + LIBS=$druntime_old_libs fi - unset ac_cv_func_accept - LIBS=$druntime_old_libs - fi - unset ac_cv_func_gethostbyname - druntime_old_libs="$LIBS" - ac_fn_c_check_func "$LINENO" "gethostbyname" "ac_cv_func_gethostbyname" + fi + ac_fn_c_check_func "$LINENO" "gethostbyname" "ac_cv_func_gethostbyname" if test "x$ac_cv_func_gethostbyname" = xyes; then : else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lnsl" >&5 -$as_echo_n "checking for main in -lnsl... " >&6; } -if ${ac_cv_lib_nsl_main+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lnsl" >&5 +$as_echo_n "checking for gethostbyname in -lnsl... " >&6; } +if ${ac_cv_lib_nsl_gethostbyname+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -15014,38 +15006,39 @@ LIBS="-lnsl $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 gethostbyname (); int main () { -return main (); +return gethostbyname (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_nsl_main=yes + ac_cv_lib_nsl_gethostbyname=yes else - ac_cv_lib_nsl_main=no + ac_cv_lib_nsl_gethostbyname=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_main" >&5 -$as_echo "$ac_cv_lib_nsl_main" >&6; } -if test "x$ac_cv_lib_nsl_main" = xyes; then : - druntime_cv_lib_sockets="$druntime_cv_lib_sockets -lnsl" +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostbyname" >&5 +$as_echo "$ac_cv_lib_nsl_gethostbyname" >&6; } +if test "x$ac_cv_lib_nsl_gethostbyname" = xyes; then : + LIBS="$LIBS -lnsl" fi fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $druntime_cv_lib_sockets" >&5 -$as_echo "$druntime_cv_lib_sockets" >&6; } - LIBS="$LIBS $druntime_cv_lib_sockets" - # Keep this in sync with core/thread.d, set druntime_fiber_asm_external to # "yes" for targets that have 'version = AsmExternal'. diff --git a/libphobos/m4/druntime/libraries.m4 b/libphobos/m4/druntime/libraries.m4 index 957bf98b442..743d3e3e17c 100644 --- a/libphobos/m4/druntime/libraries.m4 +++ b/libphobos/m4/druntime/libraries.m4 @@ -21,33 +21,30 @@ AC_DEFUN([DRUNTIME_LIBRARIES_DLOPEN], # Autodetect and add networking library to LIBS if necessary. AC_DEFUN([DRUNTIME_LIBRARIES_NET], [ - dnl Test for -lsocket and -lnsl. Copied from libjava/configure.ac. - AC_CACHE_CHECK([for socket libraries], druntime_cv_lib_sockets, - [druntime_cv_lib_sockets= - druntime_check_both=no - AC_CHECK_FUNC(connect, druntime_check_socket=no, druntime_check_socket=yes) - if test "$druntime_check_socket" = "yes"; then - unset ac_cv_func_connect - AC_CHECK_LIB(socket, main, druntime_cv_lib_sockets="-lsocket", - druntime_check_both=yes) - fi - if test "$druntime_check_both" = "yes"; then - druntime_old_libs=$LIBS - LIBS="$LIBS -lsocket -lnsl" - unset ac_cv_func_accept - AC_CHECK_FUNC(accept, - [druntime_check_nsl=no - druntime_cv_lib_sockets="-lsocket -lnsl"]) - unset ac_cv_func_accept - LIBS=$druntime_old_libs - fi - unset ac_cv_func_gethostbyname - druntime_old_libs="$LIBS" - AC_CHECK_FUNC(gethostbyname, , - [AC_CHECK_LIB(nsl, main, - [druntime_cv_lib_sockets="$druntime_cv_lib_sockets -lnsl"])]) - ]) - LIBS="$LIBS $druntime_cv_lib_sockets" + dnl Check for the existence of the -lsocket and -lnsl libraries. + dnl The order here is important, so that they end up in the right + dnl order in the command line generated by make. Here are some + dnl special considerations: + dnl 1. Use "connect" and "accept" to check for -lsocket, and + dnl "gethostbyname" to check for -lnsl. + dnl 2. Use each function name only once: can't redo a check because + dnl autoconf caches the results of the last check and won't redo it. + dnl 3. Use -lnsl and -lsocket only if they supply procedures that + dnl aren't already present in the normal libraries. + dnl 4. On some systems, can't use -lsocket without -lnsl too. + dnl To get around this problem, check for both libraries together + dnl if -lsocket doesn't work by itself. + druntime_check_both=no + AC_CHECK_FUNC(connect, , + [AC_CHECK_LIB(socket, connect, + LIBS="$LIBS -lsocket", druntime_check_both=yes)]) + if test "$druntime_check_both" = "yes"; then + druntime_old_libs=$LIBS + LIBS="$LIBS -lsocket -lnsl" + AC_CHECK_FUNC(accept, , LIBS=$druntime_old_libs) + fi + AC_CHECK_FUNC(gethostbyname, , + [AC_CHECK_LIB(nsl, gethostbyname, LIBS="$LIBS -lnsl")]) ]) # DRUNTIME_LIBRARIES_ZLIB