[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: automake links my C programs with the C++ compiler
From: |
Bruno Haible |
Subject: |
Re: automake links my C programs with the C++ compiler |
Date: |
Mon, 11 Sep 2006 16:53:10 +0200 |
User-agent: |
KMail/1.9.1 |
Hello,
Is someone on this list capable of fixing this bug?
The automake doc says:
`maude_LINK'
You can override the linker on a per-program basis. By default the
linker is chosen according to the languages used by the program.
For instance, a program that includes C++ source code would use
the C++ compiler to link.
But what automake actually does is a worst-case estimation: it links
with the C++ compiler even if C++ source code is included in a FALSE
condition.
The fix should be to generate a libfoo_la_LINK variable. Assuming
libfoo_la_SOURCES was defined as follows:
libfoo_la_SOURCES =
if COND1
libfoo_la_SOURCES += foo1.c
endif
if COND2
libfoo_la_SOURCES += foo2.upc
endif
if COND3
libfoo_la_SOURCES += foo3.m
endif
if COND4
libfoo_la_SOURCES += foo4.f
endif
if COND5
libfoo_la_SOURCES += foo5.cxx
endif
if COND6
libfoo_la_SOURCES += foo6.cc
endif
The libfoo_la_LINK variable should be defined like this:
# First the fallback definition, linking with C:
libfoo_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CCFLAGS) \
$(CCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
# Then conditional overrides in the reverse order of the list in automake
# function resolve_linker.
# Conditional definition for UPCLINK:
@address@hidden = $(LIBTOOL) --tag=UPC $(AM_LIBTOOLFLAGS) \
@COND2_TRUE@ $(LIBTOOLFLAGS) --mode=link $(UPCLD) $(AM_UPCFLAGS) \
@COND2_TRUE@ $(UPCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
# Conditional definition for OBJCLINK:
@address@hidden = $(LIBTOOL) --tag=OBJC $(AM_LIBTOOLFLAGS) \
@COND3_TRUE@ $(LIBTOOLFLAGS) --mode=link $(OBJCLD) $(AM_OBJCFLAGS) \
@COND3_TRUE@ $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
# Conditional definition for F77LINK:
@address@hidden = $(LIBTOOL) --tag=F77 $(AM_LIBTOOLFLAGS) \
@COND4_TRUE@ $(LIBTOOLFLAGS) --mode=link $(F77LD) $(AM_FFLAGS) \
@COND4_TRUE@ $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
# Conditional definition for CXXLINK:
@address@hidden = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
@COND5_TRUE@ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
@COND5_TRUE@ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
@address@hidden = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
@COND6_TRUE@ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
@COND6_TRUE@ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
I think the modifications needed for this output are
- to change the linkers_used variable to contain a list of pairs
(condition, linker variable) instead of just a single linker variable,
- to not call resolve_linker,
- to change the return value of handle_source_transform and the first
argument of define_per_target_linker_variable to be such a list as well,
- to rewrite define_per_target_linker_variable so that it emits definitions
of libfoo_la_LINK in a loop, appropriately conditionalized, in order
of increasing priority.
Bruno
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: automake links my C programs with the C++ compiler,
Bruno Haible <=