From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1521) id 85DF73858409; Fri, 4 Nov 2022 00:43:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 85DF73858409 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1667522638; bh=UZUMlAQNQRQD0V9Ni+5iQrlwvQAWDW1CtcZ68jsk3i0=; h=From:To:Subject:Date:From; b=GYwgM0e+6Pm+9w9tDCjjUPsZKfFaVBGHJzdejq648qeAHqbzxtw+h8PhOr5v7DmTh Zi0x+RXipsIt2NG6yN+y2uBg423xSPg+eQflIiq+N01P0qNWfhcShcwVWIxPFT9BFL RYl7TPekJZr+2xjsb2CWIe11JODn0VGu7APj7iuU= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Frysinger To: gdb-cvs@sourceware.org Subject: [binutils-gdb] sim: build: change AC_CHECK_LIB to AC_SEARCH_LIBS X-Act-Checkin: binutils-gdb X-Git-Author: Mike Frysinger X-Git-Refname: refs/heads/master X-Git-Oldrev: 49ea4303bf1248e422b2858a22e085e25ac34a9d X-Git-Newrev: 051081585e40a3145028cda8e2a16c010a33ebe9 Message-Id: <20221104004358.85DF73858409@sourceware.org> Date: Fri, 4 Nov 2022 00:43:58 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D051081585e40= a3145028cda8e2a16c010a33ebe9 commit 051081585e40a3145028cda8e2a16c010a33ebe9 Author: Mike Frysinger Date: Thu Nov 3 15:21:12 2022 +0700 sim: build: change AC_CHECK_LIB to AC_SEARCH_LIBS =20 With more C libraries moving functions entirely into the main -lc, change the AC_CHECK_LIB calls to AC_SEARCH_LIBS so we look in there first and avoid extra linkage when possible. Diff: --- sim/config.h.in | 12 --- sim/configure | 235 ++++++++++++++++++++++++++++--------------= ---- sim/m4/sim_ac_platform.m4 | 10 +- 3 files changed, 150 insertions(+), 107 deletions(-) diff --git a/sim/config.h.in b/sim/config.h.in index ba167b36a7c..7c0087fcd0b 100644 --- a/sim/config.h.in +++ b/sim/config.h.in @@ -120,18 +120,6 @@ /* Define to 1 if you have the `kill' function. */ #undef HAVE_KILL =20 -/* Define to 1 if you have the `dl' library (-ldl). */ -#undef HAVE_LIBDL - -/* Define to 1 if you have the `m' library (-lm). */ -#undef HAVE_LIBM - -/* Define to 1 if you have the `nsl' library (-lnsl). */ -#undef HAVE_LIBNSL - -/* Define to 1 if you have the `socket' library (-lsocket). */ -#undef HAVE_LIBSOCKET - /* Define to 1 if you have the `link' function. */ #undef HAVE_LINK =20 diff --git a/sim/configure b/sim/configure index c91cad2e25e..fdb72656466 100755 --- a/sim/configure +++ b/sim/configure @@ -12770,13 +12770,12 @@ CC=3D"$lt_save_CC" =20 =20 =20 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for bind in -lsocket" >&5 -$as_echo_n "checking for bind in -lsocket... " >&6; } -if ${ac_cv_lib_socket_bind+:} false; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing b= ind" >&5 +$as_echo_n "checking for library containing bind... " >&6; } +if ${ac_cv_search_bind+:} false; then : $as_echo_n "(cached) " >&6 else - ac_check_lib_save_LIBS=3D$LIBS -LIBS=3D"-lsocket $LIBS" + ac_func_search_save_LIBS=3D$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ =20 @@ -12795,33 +12794,44 @@ return bind (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_socket_bind=3Dyes -else - ac_cv_lib_socket_bind=3Dno +for ac_lib in '' socket; do + if test -z "$ac_lib"; then + ac_res=3D"none required" + else + ac_res=3D-l$ac_lib + LIBS=3D"-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_bind=3D$ac_res fi rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=3D$ac_check_lib_save_LIBS + conftest$ac_exeext + if ${ac_cv_search_bind+:} false; then : + break fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_bind" >= &5 -$as_echo "$ac_cv_lib_socket_bind" >&6; } -if test "x$ac_cv_lib_socket_bind" =3D xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBSOCKET 1 -_ACEOF +done +if ${ac_cv_search_bind+:} false; then : =20 - LIBS=3D"-lsocket $LIBS" +else + ac_cv_search_bind=3Dno +fi +rm conftest.$ac_ext +LIBS=3D$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_bind" >&5 +$as_echo "$ac_cv_search_bind" >&6; } +ac_res=3D$ac_cv_search_bind +if test "$ac_res" !=3D no; then : + test "$ac_res" =3D "none required" || LIBS=3D"$ac_res $LIBS" =20 fi =20 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -ln= sl" >&5 -$as_echo_n "checking for gethostbyname in -lnsl... " >&6; } -if ${ac_cv_lib_nsl_gethostbyname+:} false; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing g= ethostbyname" >&5 +$as_echo_n "checking for library containing gethostbyname... " >&6; } +if ${ac_cv_search_gethostbyname+:} false; then : $as_echo_n "(cached) " >&6 else - ac_check_lib_save_LIBS=3D$LIBS -LIBS=3D"-lnsl $LIBS" + ac_func_search_save_LIBS=3D$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ =20 @@ -12840,33 +12850,44 @@ return gethostbyname (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_nsl_gethostbyname=3Dyes -else - ac_cv_lib_nsl_gethostbyname=3Dno +for ac_lib in '' nsl; do + if test -z "$ac_lib"; then + ac_res=3D"none required" + else + ac_res=3D-l$ac_lib + LIBS=3D"-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_gethostbyname=3D$ac_res fi rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=3D$ac_check_lib_save_LIBS + conftest$ac_exeext + if ${ac_cv_search_gethostbyname+:} false; then : + break fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostbyn= ame" >&5 -$as_echo "$ac_cv_lib_nsl_gethostbyname" >&6; } -if test "x$ac_cv_lib_nsl_gethostbyname" =3D xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBNSL 1 -_ACEOF +done +if ${ac_cv_search_gethostbyname+:} false; then : =20 - LIBS=3D"-lnsl $LIBS" +else + ac_cv_search_gethostbyname=3Dno +fi +rm conftest.$ac_ext +LIBS=3D$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gethostbyna= me" >&5 +$as_echo "$ac_cv_search_gethostbyname" >&6; } +ac_res=3D$ac_cv_search_gethostbyname +if test "$ac_res" !=3D no; then : + test "$ac_res" =3D "none required" || LIBS=3D"$ac_res $LIBS" =20 fi =20 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fabs in -lm" >&5 -$as_echo_n "checking for fabs in -lm... " >&6; } -if ${ac_cv_lib_m_fabs+:} false; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing f= abs" >&5 +$as_echo_n "checking for library containing fabs... " >&6; } +if ${ac_cv_search_fabs+:} false; then : $as_echo_n "(cached) " >&6 else - ac_check_lib_save_LIBS=3D$LIBS -LIBS=3D"-lm $LIBS" + ac_func_search_save_LIBS=3D$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ =20 @@ -12885,33 +12906,44 @@ return fabs (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_m_fabs=3Dyes -else - ac_cv_lib_m_fabs=3Dno +for ac_lib in '' m; do + if test -z "$ac_lib"; then + ac_res=3D"none required" + else + ac_res=3D-l$ac_lib + LIBS=3D"-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_fabs=3D$ac_res fi rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=3D$ac_check_lib_save_LIBS + conftest$ac_exeext + if ${ac_cv_search_fabs+:} false; then : + break fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_fabs" >&5 -$as_echo "$ac_cv_lib_m_fabs" >&6; } -if test "x$ac_cv_lib_m_fabs" =3D xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBM 1 -_ACEOF +done +if ${ac_cv_search_fabs+:} false; then : =20 - LIBS=3D"-lm $LIBS" +else + ac_cv_search_fabs=3Dno +fi +rm conftest.$ac_ext +LIBS=3D$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_fabs" >&5 +$as_echo "$ac_cv_search_fabs" >&6; } +ac_res=3D$ac_cv_search_fabs +if test "$ac_res" !=3D no; then : + test "$ac_res" =3D "none required" || LIBS=3D"$ac_res $LIBS" =20 fi =20 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for log2 in -lm" >&5 -$as_echo_n "checking for log2 in -lm... " >&6; } -if ${ac_cv_lib_m_log2+:} false; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing l= og2" >&5 +$as_echo_n "checking for library containing log2... " >&6; } +if ${ac_cv_search_log2+:} false; then : $as_echo_n "(cached) " >&6 else - ac_check_lib_save_LIBS=3D$LIBS -LIBS=3D"-lm $LIBS" + ac_func_search_save_LIBS=3D$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ =20 @@ -12930,34 +12962,45 @@ return log2 (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_m_log2=3Dyes -else - ac_cv_lib_m_log2=3Dno +for ac_lib in '' m; do + if test -z "$ac_lib"; then + ac_res=3D"none required" + else + ac_res=3D-l$ac_lib + LIBS=3D"-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_log2=3D$ac_res fi rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=3D$ac_check_lib_save_LIBS + conftest$ac_exeext + if ${ac_cv_search_log2+:} false; then : + break fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_log2" >&5 -$as_echo "$ac_cv_lib_m_log2" >&6; } -if test "x$ac_cv_lib_m_log2" =3D xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBM 1 -_ACEOF +done +if ${ac_cv_search_log2+:} false; then : =20 - LIBS=3D"-lm $LIBS" +else + ac_cv_search_log2=3Dno +fi +rm conftest.$ac_ext +LIBS=3D$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_log2" >&5 +$as_echo "$ac_cv_search_log2" >&6; } +ac_res=3D$ac_cv_search_log2 +if test "$ac_res" !=3D no; then : + test "$ac_res" =3D "none required" || LIBS=3D"$ac_res $LIBS" =20 fi =20 =20 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 -$as_echo_n "checking for dlopen in -ldl... " >&6; } -if ${ac_cv_lib_dl_dlopen+:} false; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing d= lopen" >&5 +$as_echo_n "checking for library containing dlopen... " >&6; } +if ${ac_cv_search_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else - ac_check_lib_save_LIBS=3D$LIBS -LIBS=3D"-ldl $LIBS" + ac_func_search_save_LIBS=3D$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ =20 @@ -12976,23 +13019,35 @@ return dlopen (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_dl_dlopen=3Dyes -else - ac_cv_lib_dl_dlopen=3Dno +for ac_lib in '' dl; do + if test -z "$ac_lib"; then + ac_res=3D"none required" + else + ac_res=3D-l$ac_lib + LIBS=3D"-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_dlopen=3D$ac_res fi rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=3D$ac_check_lib_save_LIBS + conftest$ac_exeext + if ${ac_cv_search_dlopen+:} false; then : + break fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 -$as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" =3D xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBDL 1 -_ACEOF +done +if ${ac_cv_search_dlopen+:} false; then : =20 - LIBS=3D"-ldl $LIBS" +else + ac_cv_search_dlopen=3Dno +fi +rm conftest.$ac_ext +LIBS=3D$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlopen" >&5 +$as_echo "$ac_cv_search_dlopen" >&6; } +ac_res=3D$ac_cv_search_dlopen +if test "$ac_res" !=3D no; then : + test "$ac_res" =3D "none required" || LIBS=3D"$ac_res $LIBS" =20 fi =20 diff --git a/sim/m4/sim_ac_platform.m4 b/sim/m4/sim_ac_platform.m4 index 92fb00a3d79..74ac7fe14d4 100644 --- a/sim/m4/sim_ac_platform.m4 +++ b/sim/m4/sim_ac_platform.m4 @@ -145,12 +145,12 @@ AC_TYPE_UID_T LT_INIT =20 dnl Libraries. -AC_CHECK_LIB(socket, bind) -AC_CHECK_LIB(nsl, gethostbyname) -AC_CHECK_LIB(m, fabs) -AC_CHECK_LIB(m, log2) +AC_SEARCH_LIBS([bind], [socket]) +AC_SEARCH_LIBS([gethostbyname], [nsl]) +AC_SEARCH_LIBS([fabs], [m]) +AC_SEARCH_LIBS([log2], [m]) =20 -AC_CHECK_LIB(dl, dlopen) +AC_SEARCH_LIBS([dlopen], [dl]) if test "${ac_cv_lib_dl_dlopen}" =3D "yes"; then PKG_CHECK_MODULES(SDL, sdl2, [dnl SDL_CFLAGS=3D"${SDL_CFLAGS} -DHAVE_SDL=3D2"