This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch: Check if -lc is needed.


On Jul 18, 2000, "H . J . Lu" <hjl@valinux.com> wrote:

> Here is the patch I promised.

Thanks.

> +  touch conftest.c

An empty file is not a valid C source file.  Some compilers complain
about that.  Worse yet: some generate object files that are later on
rejected by other pieces of the tool-chain.  You must define at least
one symbol in the object file.

> +    soname=conftest
> +    lib=conftest

I'm not sure this wouldn't be rejected by some tool-chain.  I'd rather
go with regular shared library names.

> +    linkopts=-v

I fear `-v' may do something else with compilers other than GCC.
Maybe we should only run this test when using GCC?

Besides, linkopts is only used in archive_cmds on a few hosts, and I
think it is a bug, since this variable is never set in ltmain or
ltconfig.  I believe the right variables are linker_flags (when LD is
called directly) and compiler_flags (when the compiler driver is
used).

> +    if { (eval echo $progname:@LINENO@: \"$archive_cmds\") 1>&5; (eval $archive_cmds) 2>&1 | grep " -lc " 1>&5 ; }; then

Another problem: in some cases, archive_cmds runs a series of
tilde-separated commands.  Such commands would break.

In other cases, it's only one command, but it is the linker that's
called directly, in which case deduction would fail.


It is my impression that `-lc' needs only be added when LD is used
directly.  Since $compiler_flags and $linker_flags always appear right
after $deplibs, I believe we could address this problem by simply
prepending `-lc ' to linker_flags, instead of appending it to deplibs.

But you had mentioned that `-lc' was needed for older versions of GCC.
Are you sure about that?  Or was it just an attempt to explain why
libtool used `-lc' explicit?

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]