rust: avoid clobbering LIBS
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gcc_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gcc_check--master-arm |
success
|
Test passed
|
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gcc_check--master-aarch64 |
success
|
Test passed
|
Commit Message
Save LIBS around calls to AC_SEARCH_LIBS to avoid clobbering $LIBS.
ChangeLog:
* configure: Regenerate.
* configure.ac: Save LIBS around calls to AC_SEARCH_LIBS.
Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Reviewed-by: Thomas Schwinge <tschwinge@baylibre.com>
Tested-by: Thomas Schwinge <tschwinge@baylibre.com>
---
Hello,
This has already been merged in our github repository: https://github.com/Rust-GCC/gccrs/pull/3121
When testing on Ubuntu 20.04, I (and Thomas, thanks for testing) get:
S["CRAB1_LIBS"]="-lpthread -ldl "
S["LIBS"]=""
So LIBS correctly stays unmodified by our calls to AC_SEARCH_LIBS.
Ok for master?
Marc
configure | 15 ++++++++-------
configure.ac | 15 ++++++++-------
2 files changed, 16 insertions(+), 14 deletions(-)
Comments
Hi Marc,
Patch looks good to me :) Thanks!
On 8/6/24 18:43, Marc Poulhiès wrote:
> Save LIBS around calls to AC_SEARCH_LIBS to avoid clobbering $LIBS.
>
> ChangeLog:
>
> * configure: Regenerate.
> * configure.ac: Save LIBS around calls to AC_SEARCH_LIBS.
>
> Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
> Reviewed-by: Thomas Schwinge <tschwinge@baylibre.com>
> Tested-by: Thomas Schwinge <tschwinge@baylibre.com>
> ---
> Hello,
>
> This has already been merged in our github repository: https://github.com/Rust-GCC/gccrs/pull/3121
> When testing on Ubuntu 20.04, I (and Thomas, thanks for testing) get:
> S["CRAB1_LIBS"]="-lpthread -ldl "
> S["LIBS"]=""
>
> So LIBS correctly stays unmodified by our calls to AC_SEARCH_LIBS.
>
> Ok for master?
>
> Marc
>
> configure | 15 ++++++++-------
> configure.ac | 15 ++++++++-------
> 2 files changed, 16 insertions(+), 14 deletions(-)
>
> diff --git a/configure b/configure
> index 51bf1d1add1..e9583f2ba0c 100755
> --- a/configure
> +++ b/configure
> @@ -8878,9 +8878,12 @@ fi
>
> # Rust requires -ldl and -lpthread if you are using an old glibc that does not include them by
> # default, so we check for them here
> -
> +# We are doing the test here and not in the gcc/configure to be able to nicely disable the
> +# build of the Rust frontend in case a dep is missing.
> missing_rust_dynlibs=none
>
> +save_LIBS="$LIBS"
> +LIBS=
> { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5
> $as_echo_n "checking for library containing dlopen... " >&6; }
> if ${ac_cv_search_dlopen+:} false; then :
> @@ -8993,16 +8996,14 @@ if test "$ac_res" != no; then :
>
> fi
>
> +CRAB1_LIBS="$LIBS"
> +LIBS="$save_LIBS"
>
> -if test "$ac_cv_search_dlopen" = -ldl; then
> - CRAB1_LIBS="$CRAB1_LIBS -ldl"
> -elif test "$ac_cv_search_dlopen" = no; then
> +if test "$ac_cv_search_dlopen" = no; then
> missing_rust_dynlibs="libdl"
> fi
>
> -if test "$ac_cv_search_pthread_create" = -lpthread; then
> - CRAB1_LIBS="$CRAB1_LIBS -lpthread"
> -elif test "$ac_cv_search_pthread_create" = no; then
> +if test "$ac_cv_search_pthread_create" = no; then
> missing_rust_dynlibs="$missing_rust_dynlibs, libpthread"
> fi
>
> diff --git a/configure.ac b/configure.ac
> index 20457005e29..f61dbe64a94 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -2039,21 +2039,22 @@ AC_SUBST(PICFLAG)
>
> # Rust requires -ldl and -lpthread if you are using an old glibc that does not include them by
> # default, so we check for them here
> -
> +# We are doing the test here and not in the gcc/configure to be able to nicely disable the
> +# build of the Rust frontend in case a dep is missing.
> missing_rust_dynlibs=none
>
> +save_LIBS="$LIBS"
> +LIBS=
> AC_SEARCH_LIBS([dlopen], [dl])
> AC_SEARCH_LIBS([pthread_create], [pthread])
> +CRAB1_LIBS="$LIBS"
> +LIBS="$save_LIBS"
>
> -if test "$ac_cv_search_dlopen" = -ldl; then
> - CRAB1_LIBS="$CRAB1_LIBS -ldl"
> -elif test "$ac_cv_search_dlopen" = no; then
> +if test "$ac_cv_search_dlopen" = no; then
> missing_rust_dynlibs="libdl"
> fi
>
> -if test "$ac_cv_search_pthread_create" = -lpthread; then
> - CRAB1_LIBS="$CRAB1_LIBS -lpthread"
> -elif test "$ac_cv_search_pthread_create" = no; then
> +if test "$ac_cv_search_pthread_create" = no; then
> missing_rust_dynlibs="$missing_rust_dynlibs, libpthread"
> fi
>
August 12, 2024 at 4:09 PM, "Arthur Cohen" <arthur.cohen@embecosm.com> wrote:
>
> Hi Marc,
>
> Patch looks good to me :) Thanks!
>
Hello,
thanks for the Ack :)
I'm still waiting for a maintainer review... I've been told this may qualify as "trivial", but again, I would prefer a formal Ack as I'm not really an expert in autotools...
Marc
Hello,
Gentle reminder for this simple autoconf patch :)
Thanks,
Marc
On Wed, Aug 28, 2024 at 11:10 AM Marc <dkm@kataplop.net> wrote:
>
> Hello,
>
> Gentle reminder for this simple autoconf patch :)
OK.
Note that completely wiping LIBS might remove requirements detected earlier,
like some systems require explicit -lc for example. I would instead not clear
LIBS here and instead allow the possible duplicates through CRAB_LIBS.
YMMV of course.
Richard.
> Thanks,
> Marc
Richard Biener <richard.guenther@gmail.com> writes:
> On Wed, Aug 28, 2024 at 11:10 AM Marc <dkm@kataplop.net> wrote:
>>
>> Hello,
>>
>> Gentle reminder for this simple autoconf patch :)
>
> OK.
>
> Note that completely wiping LIBS might remove requirements detected earlier,
> like some systems require explicit -lc for example. I would instead not clear
> LIBS here and instead allow the possible duplicates through CRAB_LIBS.
> YMMV of course.
Oh, that's a good remark. I've simply followed this suggestion that was
given on #gcc and also took inspiration from gcc/configure.ac that has
many instances of clearing LIBS like that. I think I'll merge it like
that, unless you see any reason this pattern would cause issue here (top
level) and not in gcc/configure.
Thank you,
Marc
On Tue, Sep 3, 2024 at 8:42 PM Marc <dkm@kataplop.net> wrote:
>
> Richard Biener <richard.guenther@gmail.com> writes:
>
> > On Wed, Aug 28, 2024 at 11:10 AM Marc <dkm@kataplop.net> wrote:
> >>
> >> Hello,
> >>
> >> Gentle reminder for this simple autoconf patch :)
> >
> > OK.
> >
> > Note that completely wiping LIBS might remove requirements detected earlier,
> > like some systems require explicit -lc for example. I would instead not clear
> > LIBS here and instead allow the possible duplicates through CRAB_LIBS.
> > YMMV of course.
>
> Oh, that's a good remark. I've simply followed this suggestion that was
> given on #gcc and also took inspiration from gcc/configure.ac that has
> many instances of clearing LIBS like that. I think I'll merge it like
> that, unless you see any reason this pattern would cause issue here (top
> level) and not in gcc/configure.
If it's done like this elsewhere then it's good to follow existing
practice indeed.
Richard.
> Thank you,
> Marc
>
>
@@ -8878,9 +8878,12 @@ fi
# Rust requires -ldl and -lpthread if you are using an old glibc that does not include them by
# default, so we check for them here
-
+# We are doing the test here and not in the gcc/configure to be able to nicely disable the
+# build of the Rust frontend in case a dep is missing.
missing_rust_dynlibs=none
+save_LIBS="$LIBS"
+LIBS=
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5
$as_echo_n "checking for library containing dlopen... " >&6; }
if ${ac_cv_search_dlopen+:} false; then :
@@ -8993,16 +8996,14 @@ if test "$ac_res" != no; then :
fi
+CRAB1_LIBS="$LIBS"
+LIBS="$save_LIBS"
-if test "$ac_cv_search_dlopen" = -ldl; then
- CRAB1_LIBS="$CRAB1_LIBS -ldl"
-elif test "$ac_cv_search_dlopen" = no; then
+if test "$ac_cv_search_dlopen" = no; then
missing_rust_dynlibs="libdl"
fi
-if test "$ac_cv_search_pthread_create" = -lpthread; then
- CRAB1_LIBS="$CRAB1_LIBS -lpthread"
-elif test "$ac_cv_search_pthread_create" = no; then
+if test "$ac_cv_search_pthread_create" = no; then
missing_rust_dynlibs="$missing_rust_dynlibs, libpthread"
fi
@@ -2039,21 +2039,22 @@ AC_SUBST(PICFLAG)
# Rust requires -ldl and -lpthread if you are using an old glibc that does not include them by
# default, so we check for them here
-
+# We are doing the test here and not in the gcc/configure to be able to nicely disable the
+# build of the Rust frontend in case a dep is missing.
missing_rust_dynlibs=none
+save_LIBS="$LIBS"
+LIBS=
AC_SEARCH_LIBS([dlopen], [dl])
AC_SEARCH_LIBS([pthread_create], [pthread])
+CRAB1_LIBS="$LIBS"
+LIBS="$save_LIBS"
-if test "$ac_cv_search_dlopen" = -ldl; then
- CRAB1_LIBS="$CRAB1_LIBS -ldl"
-elif test "$ac_cv_search_dlopen" = no; then
+if test "$ac_cv_search_dlopen" = no; then
missing_rust_dynlibs="libdl"
fi
-if test "$ac_cv_search_pthread_create" = -lpthread; then
- CRAB1_LIBS="$CRAB1_LIBS -lpthread"
-elif test "$ac_cv_search_pthread_create" = no; then
+if test "$ac_cv_search_pthread_create" = no; then
missing_rust_dynlibs="$missing_rust_dynlibs, libpthread"
fi