libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: check for GNU ld when configuring for C++


From: Robert Boehne
Subject: Re: check for GNU ld when configuring for C++
Date: Thu, 27 Feb 2003 21:09:06 -0600

Alexandre:

I don't see any problems with this method, so I'll give you my approval
to check this in.  If you've changed your mind about this, let us know,
if not, commit.

Thanks,

Robert

Alexandre Oliva wrote:
> 
> We currently override with_gnu_ld when configuring libtool for C++.
> This doesn't sound right.  At the very least, we should preserve
> with_gnu_ld when we're done.  However, there's a more serious problem:
> we assume the compiler can find a program named ld, which is not the
> case while configuring libstdc++-v3 within a unified tree with GNU
> binutils and GCC.  In this case, the linker name is collect-ld, but
> the correct linker name is passed down as LD to libstdc++-v3's
> configure script.
> 
> I'm not sure how to best address this problem, but my first cut was to
> exactly duplicate the test for GNU ld that we do for the C compiler in
> the context of the C++ compiler, however preserving some settings used
> by the macros used to do so across the entire tag configuration, and
> introducing a new variable LDCXX that can be used to override LD when
> detecting the linker used by the C++ compiler.  I'd like so much to
> require the C and C++ compilers to use the same linker, but I don't
> think we can go that far :-(
> 
> Anyway, here's the patch I'm testing, that is supposed to fix the
> problem.  Since I'm overriding cache variables, I couldn't do without
> unset (it seems that newer autoconfs take variables set to nothing as
> cached values too, which is no good when unset doesn't exist :-(.
> 
> Another solution is to define a new macro AC_PROG_LDCXX, or something
> alike.  Smart uses of m4_define could also do, to get AC_PROG_LD to
> set and use LDCXX variables instead of LD.  I don't have strong
> feelings.  Opinions?
> 
>   ------------------------------------------------------------------------
> Index: ChangeLog
> from  Alexandre Oliva  <address@hidden>
>         * libtool.m4 (AC_PROG_LD): Use $CC instead of GCC.
>         (_LT_AC_LANG_CXX_CONFIG): Preserve variables used by AC_PROG_LD,
>         and reset them for a C++ environment.  Use the with_gnu_ld setting
>         from AC_PROG_LD.
> 
> Index: libtool.m4
> ===================================================================
> RCS file: /cvsroot/libtool/libtool/libtool.m4,v
> retrieving revision 1.302
> diff -u -p -r1.302 libtool.m4
> --- libtool.m4 19 Feb 2003 23:29:40 -0000 1.302
> +++ libtool.m4 20 Feb 2003 02:44:21 -0000
> @@ -1902,7 +1902,7 @@ AC_REQUIRE([AC_CANONICAL_BUILD])dnl
>  ac_prog=ld
>  if test "$GCC" = yes; then
>    # Check if gcc -print-prog-name=ld gives a path.
> -  AC_MSG_CHECKING([for ld used by GCC])
> +  AC_MSG_CHECKING([for ld used by $CC])
>    case $host in
>    *-*-mingw*)
>      # gcc leaves a trailing carriage return which upsets mingw
> @@ -2560,7 +2560,23 @@ lt_simple_link_test_code='int main(int,
>  _LT_AC_SYS_COMPILER
> 
>  # Allow CC to be a program name with arguments.
> -lt_save_CC="$CC"
> +lt_save_CC=$CC
> +lt_save_LD=$LD
> +lt_save_GCC=$GCC
> +GCC=$GXX
> +lt_save_with_gnu_ld=$with_gnu_ld
> +lt_save_path_LD=$lt_cv_path_LD
> +if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
> +  lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
> +else
> +  unset lt_cv_prog_gnu_ld
> +fi
> +if test -n "${lt_cv_path_LDCXX+set}"; then
> +  lt_cv_path_LD=$lt_cv_path_LDCXX
> +else
> +  unset lt_cv_path_LD
> +fi
> +test -z "${LDCXX+set}" || LD=$LDCXX
>  CC=${CXX-"c++"}
>  compiler=$CC
>  _LT_AC_TAGVAR(compiler, $1)=$CC
> @@ -2577,12 +2593,11 @@ fi
>  if test "$GXX" = yes; then
>    # Set up default GNU C++ configuration
> 
> +  AC_PROG_LD
> +
>    # Check if GNU C++ uses GNU ld as the underlying linker, since the
>    # archiving commands below assume that GNU ld is being used.
> -  if eval "`$CC -print-prog-name=ld` --version 2>&1" | \
> -      grep 'GNU ld' > /dev/null; then
> -    with_gnu_ld=yes
> -
> +  if test "$with_gnu_ld" = yes; then
>      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects 
> $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o 
> $lib'
>      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib 
> $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags 
> ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
> 
> @@ -3345,7 +3360,16 @@ AC_LIBTOOL_DLOPEN_SELF($1)
>  AC_LIBTOOL_CONFIG($1)
> 
>  AC_LANG_POP
> -CC="$lt_save_CC"
> +CC=$lt_save_CC
> +LDCXX=$LD
> +LD=$lt_save_LD
> +GCC=$lt_save_GCC
> +with_gnu_ldcxx=$with_gnu_ld
> +with_gnu_ld=$lt_save_with_gnu_ld
> +lt_cv_path_LDCXX=$lt_cv_path_LD
> +lt_cv_path_LD=$lt_save_path_LD
> +lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
> +lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
>  ])# AC_LIBTOOL_LANG_CXX_CONFIG
> 
>  # AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME])
> 
>   ------------------------------------------------------------------------
> 
> --
> Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
> Red Hat GCC Developer                 address@hidden, gcc.gnu.org}
> CS PhD student at IC-Unicamp        address@hidden, gnu.org}
> Free Software Evangelist                Professional serial bug killer
> 
>   ------------------------------------------------------------------------
> _______________________________________________
> Libtool-patches mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/libtool-patches




reply via email to

[Prev in Thread] Current Thread [Next in Thread]