This is the mail archive of the gcc-bugs@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]
Other format: [Raw text]

[Bug target/14548] building Ada library incorrectly requires collect2 on mingw


------- Additional Comments From ian at wasabisystems dot com  2004-03-19 01:54 -------
The current situation with USE_COLLECT2 is rather confusing.  USE_COLLECT2 is
used both as a macro define in config.h and tconfig.h and as a Makefile variable.

The macro definition is set based on use_collect2 in config.gcc: if use_collect2
is set to yes, then USE_COLLECT2 is defined in config.h and tconfig.h.  The
macro affects how constructors are output.  It is also checked in collect2.c,
and controls whether collect2 scans the object files for constructor names and
generates a static constructor table.

The Makefile variable USE_COLLECT2 is normally defined as collect2$(exeext),
which causes the collect2 binary to be built.  A few Makefile fragments override
the Makefile variable USE_COLLECT2 to be empty, which causes collect2 to not be
built.  Specifically, this is currently done in these Makefile fragments:
alpha/x-vms, i386/t-mingw32, rs6000/t-beos.

So we can see that USE_COLLECT2 means two different things.  In one case it
controls how constructors are handled.  In the other case it controls whether
the collect2 binary is built at all.

In general, the collect2 binary should always be built these days.  That is
because it handles the C++ -frepo option.  So in general the use of the Makefile
variable USE_COLLECT2 should be discouraged.

However, there are some hosts on which collect2 can not presently be built.  For
those hosts, it might make sense to disable building collect2, and to accept
that it will not be possible to use -frepo, and to accept that certain targets,
those which set use_collect2 to yes in config.gcc, will not support global
constructors and destructors.

Based on this, it is clearly incorrect to set the Makefile variable USE_COLLECT2
in a target makefile fragment.  That would prevent building collect2 when
building a cross-compiler to that target, but there is no reason to prevent
that.  Therefore, the Makefile variable USE_COLLECT2 which is set in
i386/t-mingw32 and rs6000/t-beos should be moved to i386/x-mingw32 and
rs6000/x-beos.  Further, we should add a check somewhere to give an error if the
Makefile variable USE_COLLECT2 is empty and the macro define USE_COLLECT2 is
set, since that scenario can not work.  (Of course, it would be even better to
make collect2 actually build and work on these hosts, if only so that -frepo
will work correctly).

Anyhow, using the host makefile fragment, while correct, won't fix the
particular problem described in this PR.  The problem here is that when a
variable is used as a dependency, GNU make uses the current value in the
dependency calculation, even if the variable is later set to a different value.
 Since the host and target makefile fragments are now included after the
language makefile fragments, the fact that the host or target makefile fragment
overrides USE_COLLECT2 does not affect it's appearance in a dependency in
ada/Make-lang.in.

This problem can be fixed either by changing the Makefile variable USE_COLLECT2
to be an autoconf substitution based on a value set in config.host, much as
host_exeext is today, or by changing ada/Make-lang.in to use a stamp instead of
$(GCC_PARTS), and to make that stamp depend upon $(GCC_PARTS).

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14548


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