On Tue, Jun 11, 2024 at 11:21 AM Arthur Cohen wrote:
>
> Thanks Richi!
>
> Tested again and pushed on trunk.
This patch introduced a couple of errors during ./configure:
checking for library containing dlopen... none required
checking for library containing pthread_create... none required
/git/gcc/configure: line 8997: test: too many arguments
/git/gcc/configure: line 8999: test: too many arguments
/git/gcc/configure: line 9003: test: too many arguments
/git/gcc/configure: line 9005: test: =: unary operator expected
You have to wrap arguments of the test with double quotes.
Uros.
> Best,
>
> Arthur
>
> On 5/31/24 15:02, Richard Biener wrote:
> > On Fri, May 31, 2024 at 12:24 PM Arthur Cohen
> > wrote:
> >>
> >> Hi Richard,
> >>
> >> On 4/30/24 09:55, Richard Biener wrote:
> >>> On Fri, Apr 19, 2024 at 11:49 AM Arthur Cohen
> >>> wrote:
>
> Hi everyone,
>
> This patch checks for the presence of dlopen and pthread_create in libc.
> If that is not the
> case, we check for the existence of -ldl and -lpthread, as these
> libraries are required to
> link the Rust runtime to our Rust frontend.
>
> If these libs are not present on the system, then we disable the Rust
> frontend.
>
> This was tested on x86_64, in an environment with a recent GLIBC and in
> a container with GLIBC
> 2.27.
>
> Apologies for sending it in so late.
> >>>
> >>> For example GCC_ENABLE_PLUGINS simply does
> >>>
> >>># Check -ldl
> >>>saved_LIBS="$LIBS"
> >>>AC_SEARCH_LIBS([dlopen], [dl])
> >>>if test x"$ac_cv_search_dlopen" = x"-ldl"; then
> >>> pluginlibs="$pluginlibs -ldl"
> >>>fi
> >>>LIBS="$saved_LIBS"
> >>>
> >>> which I guess would also work for pthread_create? This would simplify
> >>> the code a bit.
> >>
> >> Thanks a lot for the review. I've udpated the patch's content in
> >> configure.ac per your suggestion. Tested similarly on x86_64 and in a
> >> container with libc 2.27
> >
> > LGTM.
> >
> > Thanks,
> > Richard.
> >
> >> From 00669b600a75743523c358ee41ab999b6e9fa0f6 Mon Sep 17 00:00:00 2001
> >> From: Arthur Cohen
> >> Date: Fri, 12 Apr 2024 13:52:18 +0200
> >> Subject: [PATCH] rust: Do not link with libdl and libpthread
> >> unconditionally
> >>
> >> ChangeLog:
> >>
> >> * Makefile.tpl: Add CRAB1_LIBS variable.
> >> * Makefile.in: Regenerate.
> >> * configure: Regenerate.
> >> * configure.ac: Check if -ldl and -lpthread are needed, and if
> >> so, add
> >> them to CRAB1_LIBS.
> >>
> >> gcc/rust/ChangeLog:
> >>
> >> * Make-lang.in: Remove overazealous LIBS = -ldl -lpthread line,
> >> link
> >> crab1 against CRAB1_LIBS.
> >> ---
> >>Makefile.in | 3 +
> >>Makefile.tpl | 3 +
> >>configure | 154 ++
> >>configure.ac | 41 +++
> >>gcc/rust/Make-lang.in | 6 +-
> >>5 files changed, 203 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/Makefile.in b/Makefile.in
> >> index edb0c8a9a42..1753fb6b862 100644
> >> --- a/Makefile.in
> >> +++ b/Makefile.in
> >> @@ -197,6 +197,7 @@ HOST_EXPORTS = \
> >> $(BASE_EXPORTS) \
> >> CC="$(CC)"; export CC; \
> >> ADA_CFLAGS="$(ADA_CFLAGS)"; export ADA_CFLAGS; \
> >> + CRAB1_LIBS="$(CRAB1_LIBS)"; export CRAB1_LIBS; \
> >> CFLAGS="$(CFLAGS)"; export CFLAGS; \
> >> CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
> >> CXX="$(CXX)"; export CXX; \
> >> @@ -450,6 +451,8 @@ GOCFLAGS = $(CFLAGS)
> >>GDCFLAGS = @GDCFLAGS@
> >>GM2FLAGS = $(CFLAGS)
> >>
> >> +CRAB1_LIBS = @CRAB1_LIBS@
> >> +
> >>PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
> >>
> >>GUILE = guile
> >> diff --git a/Makefile.tpl b/Makefile.tpl
> >> index adbcbdd1d57..4aeaad3c1a5 100644
> >> --- a/Makefile.tpl
> >> +++ b/Makefile.tpl
> >> @@ -200,6 +200,7 @@ HOST_EXPORTS = \
> >> $(BASE_EXPORTS) \
> >> CC="$(CC)"; export CC; \
> >> ADA_CFLAGS="$(ADA_CFLAGS)"; export ADA_CFLAGS; \
> >> + CRAB1_LIBS="$(CRAB1_LIBS)"; export CRAB1_LIBS; \
> >> CFLAGS="$(CFLAGS)"; export CFLAGS; \
> >> CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
> >> CXX="$(CXX)"; export CXX; \
> >> @@ -453,6 +454,8 @@ GOCFLAGS = $(CFLAGS)
> >>GDCFLAGS = @GDCFLAGS@
> >>GM2FLAGS = $(CFLAGS)
> >>
> >> +CRAB1_LIBS = @CRAB1_LIBS@
> >> +
> >>PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
> >>
> >>GUILE = guile
> >> diff --git a/configure b/configure
> >> index 02b435c1163..a9ea5258f0f 100755
> >> --- a/configure
> >> +++ b/configure
> >> @@ -690,6 +690,7 @@ extra_host_zlib_configure_flags
> >>extra_host_libiberty_configure_flags
> >>stage1_languages
> >>host_libs_picflag
> >> +CRAB1_LIBS
> >>PICFLAG
> >>host_shared
> >>gcc_host_pie
> >> @@ -8826,6 +8827,139 @@ fi
> >>
> >>
> >>
> >> +# Rust req