[Top][All Lists]

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

Re: Linking with '-L /path/to/lib' (note the space!)

From: Ralf Wildenhues
Subject: Re: Linking with '-L /path/to/lib' (note the space!)
Date: Thu, 21 Aug 2008 19:26:50 +0200
User-agent: Mutt/1.5.18 (2008-05-17)

Hi Olaf,

* Olaf Lenz wrote on Thu, Aug 21, 2008 at 02:56:10PM CEST:
> When I pass the option "-L /path/to/lib" (note the space between -L and
> /path/to/lib) to libtool in linking mode, libtool does not fail nor does
> it give a warning, but instead the option will be interpreted as two
> options, so that the linker command will get the current working
> directory as flag to the linker (from -L), plus /path/to/lib as compiler
> input argument.

Thanks for the bug report.  OK to put you in THANKS?

Others, OK for the patch below, or should we just parse that construct


2008-08-21  Ralf Wildenhues  <address@hidden>

        Disallow `-L path', do not misparse it silently.
        * libltdl/config/ltmain.m4sh (func_mode_link): Diagnose `-L'
        without argument, and `-L path', i.e., with a space.
        * tests/fail.at (Failure tests): Test for these failures.
        * THANKS: Update.
        Report by Olaf Lenz.

diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
index 407e930..9f26deb 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -4035,6 +4035,13 @@ func_mode_link ()
        func_stripname '-L' '' "$arg"
+       if test -z "$dir"; then
+         if test $# -gt 0; then
+           func_fatal_error "require no space between \`-L' and \`$1'"
+         else
+           func_fatal_error "need path for \`-L' option"
+         fi
+       fi
        # We need an absolute path.
        case $dir in
        [\\/]* | [A-Za-z]:[\\/]*) ;;
diff --git a/tests/fail.at b/tests/fail.at
index b12a152..fe38ddc 100644
--- a/tests/fail.at
+++ b/tests/fail.at
@@ -1,6 +1,6 @@
 # fail.at -- test that libtool really fail when it should     -*- Autotest -*-
-#   Copyright (C) 2005 Free Software Foundation, Inc.
+#   Copyright (C) 2005, 2008 Free Software Foundation, Inc.
 #   Written by Ralf Wildenhues, 2005
 #   This file is part of GNU Libtool.
@@ -92,5 +92,13 @@ case $build_libtool_libs in yes)
+# Ensure we diagnose '-L path'.
+echo 'int main () { return 0; }' > d.c
+echo 'int foo () { return 0; }' > space-after-L.c
+$CC $CPPFLAGS $CFLAGS -c space-after-L.c
+FAIL_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -L space-after-L.$OBJEXT 
-o d d.$OBJEXT])

reply via email to

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