automake
[Top][All Lists]
Advanced

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

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


From: Jeffrey Walton
Subject: Re: Per-Object Flags for Autotool C++ library?
Date: Fri, 3 Nov 2017 09:58:08 -0400

On Thu, Nov 2, 2017 at 8:37 PM, Nick Bowler <address@hidden> wrote:
> 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
>> Automake.am has:
>>
>> lib_LTLIBRARIES = \
>>    libcryptopp.la
>>
>> 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
>> https://www.gnu.org/software/automake/manual/html_node/Per_002dObject-Flags.html,
>> I need to add an additional library:
>>
>> CPU_FLAG = -msse2 -msse3 -mssse3
>> libcpu_a_SOURCES = cpu.cpp
>> libcpu_a_CXXFLAGS = $(CXXFLAGS) $(CPU_FLAG)
>
> 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).

Ack, thanks.

You'll probably see a lot of dumb mistakes as I am carving the rough
shape. I pinged a few of the people who have been pressuring us to
provide Autotools. Hopefully they will cleanup most of my dumb
mistakes.

>> Now that the objects are built we need to add libcpu.a back into
>> libcryptopp.la 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.

Ugh, OK.

There's a better control for this. It is init_priority on Linux and
init_seg on Windows. Unfortunately, they are the only two platforms
that provide it. We still need something [mostly portable] for AIX,
some BSDs, OS X and Solaris support.

I'll have to look at the options available. For the moment, I guess we
will stop and inform Autotools is not supported if init_priority on
Linux or init_seg on Windows is not available.

> Nevertheless for the shared library case you can probably achieve this
> using several dummy libraries.  Something like this should work OK
> (totally untested):
>
> lib_LTLIBRARIES = libfoo.la
> EXTRA_LTLIBRARIES = libdummy1.la libdummy2.la libdummy3.la
>
> 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) \
>                    $(libdummy3_la_OBJECTS)
>
> and then the linking order should be a, b, c, d, e, f -- with c and d
> compiled using your special flags.

Thanks.

Jeff



reply via email to

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