automake
[Top][All Lists]
Advanced

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

Per-Object Flags for Autotool C++ library?


From: Jeffrey Walton
Subject: Per-Object Flags for Autotool C++ library?
Date: Thu, 2 Nov 2017 18:04:14 -0400

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)

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. Because this is C++, we have
to contend with Static Initialization Order Fiasco
(https://isocpp.org/wiki/faq/ctors#static-init-order). We need the
initializers for cryptlib.o to run first, then the initializers for
cpu.o to run, then the initializers for integer.o to run. The
remaining ones are "don't care".

My question is, how do I add libcpu.a back into libcryptopp.la in that
exact position it would have been in if I could have specified
per-object flags?

Thanks in advance,

Jeff



reply via email to

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