automake
[Top][All Lists]
Advanced

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

Re: Automake passing CFLAGS or CXXFLAGS when linking


From: Mike Miller
Subject: Re: Automake passing CFLAGS or CXXFLAGS when linking
Date: Thu, 30 Jun 2016 18:13:17 -0700
User-agent: Mutt/1.6.0 (2016-04-01)

On Tue, Jun 28, 2016 at 19:21:45 +0200, Grégory Pakosz wrote:
> Hello,
> 
> What's the rationale behind Automake passing CFLAGS or CXXFLAGS when linking?
> 
> LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
>   $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
>   $(AM_LDFLAGS) $(LDFLAGS) -o $@
> 
> CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
>   $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
>   $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
> 
> In comparison, GNU Make's default linking rule is
> 
> .o:
>   $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
> 
> where LINK.o = $(CC) $(LDFLAGS) $(TARGET_ARCH)

I don't know if I can tell you an offical project rationale, but I can
give a couple examples of options that you really do want to appear in
both places, -pthread and -fopenmp.

If automake did not invoke the link stage this way, building with
CFLAGS=-fopenmp but forgetting to include it in LDFLAGS might cause
serious problems.

OTOH asking the compiler to link some object code and including a few
options that have nothing to do with linking should be harmless.

-- 
mike



reply via email to

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