[Top][All Lists]

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

Re: Per-Object Flags for Autotool C++ library?

From: Nick Bowler
Subject: Re: Per-Object Flags for Autotool C++ library?
Date: Thu, 2 Nov 2017 20:37:44 -0400

Hi Jeffrey,

On 11/2/17, Jeffrey Walton <address@hidden> wrote:
> I'm working on adding Autotools to a C++ library and test program. My
> has:
> libcryptopp_la_SOURCES = \
>    cryptolib.cpp \
>    cpu.cpp \
>    integer.cpp \
>    <remaining files in alphabetical order>
>    ...
> cpu.cpp needs additional flags to enable ISAs on IA-32, Aarch64 and
> Power7/Power8. According to
> I need to add an additional library:
> CPU_FLAG = -msse2 -msse3 -mssse3
> libcpu_a_SOURCES = cpu.cpp

Note that you should not include $(CXXFLAGS) here.  CXXFLAGS is always
included (so with this it will duplicated on the command line, which
might be undesired by the user).

> Now that the objects are built we need to add libcpu.a back into
> in the exact position it would have been in if I could
> have specified per-object flags. The Automake manual gives an example
> of linking a program with disjoint libraries, but not adding the
> extraneous library back to the main (primary?) library at a particular
> position.
> The "in the exact position" is important.

Not too familiar with C++ stuff but I would be a bit concerned that
it might not be possible at all to force a particular link order for
the objects in the static version of the library.

Nevertheless for the shared library case you can probably achieve this
using several dummy libraries.  Something like this should work OK
(totally untested):


libdummy1_la_SOURCES = a.cpp b.cpp

libdummy2_la_SOURCES = c.cpp d.cpp
libdummy2_la_CXXFLAGS = -mstuff

libdummy3_la_SOURCES = e.cpp f.cpp

libfoo_la_SOURCES =
libfoo_la_LIBADD = $(libdummy1_la_OBJECTS) \
                   $(libdummy2_la_OBJECTS) \

and then the linking order should be a, b, c, d, e, f -- with c and d
compiled using your special flags.


reply via email to

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