Hello Simon, Török, Åke, * Simon Richter wrote on Wed, Mar 24, 2010 at 12:11:13PM CET: > I'm trying to use link time optimization with gcc 4.5, which somewhat > works :), but requires the compiler flags to be passed to the linking > step as well. libtool however removes them from the command line.
Let's address three reports in one go. I'm still working on a patch to support -flto in libtool, it needs changes in several places. > Is there any harm in passing them to the linking step? Yes. Let me answer with a patch to add a FAQ and FAQ entry. OK to commit? Thanks, Ralf Add FAQ, and FAQ entry for flags stripped at library link time. * doc/libtool.texi (FAQ, Stripped link flags): New nodes. (Wrapper executables): Replace bug address with macro. (Compile mode, Link mode): Document `-Wc,' and `-Xcompiler ' semantics better. * libltdl/config/ltmain.m4sh (func_mode_link): Rewrite comment for the flags that are passed through. Prompted by reports from Simon Richter <simon.rich...@...>, Török Edwin <edwinto...@...> and Åke Sandgren <ake.sandg...@...>. diff --git a/doc/libtool.texi b/doc/libtool.texi index f07eaf2..f0dd24b 100644 --- a/doc/libtool.texi +++ b/doc/libtool.texi @@ -95,6 +95,7 @@ version @value{VERSION}. * Dlopened modules:: @code{dlopen}ing libtool-created libraries. * Using libltdl:: Libtool's portable @code{dlopen} wrapper library. * Trace interface:: Libtool's trace interface. +* FAQ:: Frequently Asked Questions * Troubleshooting:: When libtool doesn't work as advertised. * Maintaining:: Information used by the libtool maintainer. * GNU Free Documentation License:: License for this manual. @@ -186,6 +187,10 @@ Using libltdl * Module loaders for libltdl:: Creating user defined module loaders. * Distributing libltdl:: How to distribute libltdl with your package. +Frequently Asked Questions + +* Stripped link flags:: Dropped flags when creating a library + Troubleshooting * Libtool test suite:: Libtool's self-tests. @@ -886,7 +891,7 @@ employ command line options that begin with @code{--lt-}. (In fact, the wrapper executable will detect any command line options that begin with @code{--lt-} and abort with an error message if the option is not recognized). If this presents a problem, please contact the Libtool -team at @email{bug-libtool@@gnu.org}. +team at @value{BUGADDR}. These command line options include: @@ -1414,7 +1419,9 @@ linking. @item -Wc,@var{flag} @itemx -Xcompiler @var{flag} -Pass a flag directly to the compiler. +Pass a flag directly to the compiler. With @code{-Wc,}, multiple flags +may be separated by commas, whereas @code{-Xcompiler } passes through +commas unchanged. @end table @node Link mode @@ -1602,7 +1609,9 @@ supplies the same interface (@pxref{Linking with dlopened modules}). @item -Wc,@var{flag} @itemx -Xcompiler @var{flag} -Pass a linker-specific flag directly to the compiler. +Pass a linker-specific flag directly to the compiler. With @code{-Wc,}, +multiple flags may be separated by commas, whereas @code{-Xcompiler } +passes through commas unchanged. @item -Wl,@var{flag} @itemx -Xlinker @var{flag} @@ -4946,6 +4955,46 @@ autoconf --trace 'LT_SUPPORTED_TAG:$1' @end defmac +...@node FAQ +...@chapter Frequently Asked Questions about libtool + +This chapter covers some questions that often come up on the mailing +lists. + +...@menu +* Stripped link flags:: Dropped flags when creating a library +...@end menu + +...@node Stripped link flags +...@section Why does libtool strip link flags when creating a library? + +When creating a shared library, but not when compiling or creating +a program, @command{libtool} drops some flags from the command line +provided by the user. This is done because flags unknown to +...@command{libtool} may interfere with library creation or require +additional support from @command{libtool}, and because omitting +flags is usually the conservative choice for a successful build. + +If you encounter flags that you think are useful to pass, as a +work-around you can prepend flags with @code{-Wc,} or @code{-Xcompiler } +to allow them to be passed through to the compiler driver +(@pxref{Link mode}). Another possibility is to add flags already +to the compiler command at @command{configure} run time: + +...@example +./configure CC='gcc -m64' +...@end example + +If you think @command{libtool} should let some flag through by default, +here's how you can test such an inclusion: grab the Libtool development +tree, edit the @file{ltmain.m4sh} file in the @file{libltdl/config} +subdirectory to pass through the flag (search for @samp{Flags to be +passed through}), re-bootstrap and build with the flags in question +added to @code{LDFLAGS}, @code{CFLAGS}, @code{CXXFLAGS}, etc. on the +...@command{configure} command line as appropriate. Run the testsuite +as described in the @file{README} file and report results to +...@value{bugaddr}. + @node Troubleshooting @chapter Troubleshooting @cindex troubleshooting diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh index 9790579..b915203 100644 --- a/libltdl/config/ltmain.m4sh +++ b/libltdl/config/ltmain.m4sh @@ -4489,17 +4489,17 @@ func_mode_link () arg="$func_quote_for_eval_result" ;; - # -64, -mips[0-9] enable 64-bit mode on the SGI compiler - # -r[0-9][0-9]* specifies the processor on the SGI compiler - # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler - # +DA*, +DD* enable 64-bit mode on the HP compiler - # -q* pass through compiler args for the IBM compiler - # -m*, -t[45]*, -txscale* pass through architecture-specific - # compiler args for GCC - # -F/path gives path to uninstalled frameworks, gcc on darwin - # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC - # @file GCC response files - # -tp=* Portland pgcc target processor selection + # Flags to be passed through unchanged, with rationale: + # -64, -mips[0-9] enable 64-bit mode for the SGI compiler + # -r[0-9][0-9]* specify processor for the SGI compiler + # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler + # +DA*, +DD* enable 64-bit mode for the HP compiler + # -q* compiler args for the IBM compiler + # -m*, -t[45]*, -txscale* architecture-specific flags for GCC + # -F/path path to uninstalled frameworks, gcc on darwin + # -p, -pg, --coverage, -fprofile-* profiling flag for GCC + # @file GCC response files + # -tp=* Portland pgcc target processor selection -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*) func_quote_for_eval "$arg"