Hello mates,

I would like you to consider having the attached patch committed in
order to fix and improve the build system of pacemaker.

We Gentoo compilation lovers have to apply this patch in order to have a
clean and working process of building pacemaker mostly because we use
LDFLAGS="--as-needed" in our default setup. As you may already know,
this requires the library linking to be strictly ordered and organized
and this patch is meant to do it.

If you remember, we Gentoo cluster team already submitted such kind of a
patch (see attached message) but it seems some features/files slipped
since then.

Thanks in advance for considering.

Ultrabug, Gentoo cluster herd.

PS: sorry, posted this message earlier with wrong mail account
This patch fixes different issues with the autotools build system
in order to make it work properly with LDFLAGS such as --as-needed
which require strict and ordered lib listings.

--- a/configure.ac
+++ b/configure.ac
@@ -1354,6 +1354,7 @@
 if
     $PKGCONFIG --exists $SERVICELOG
 then
+    PKG_CHECK_MODULES([SERVICELOG], [servicelog-1])
     SERVICELOG_EXISTS="yes"
 fi
 AC_MSG_RESULT($SERVICELOG_EXISTS)
@@ -1366,6 +1367,7 @@
 if
     $PKGCONFIG --exists $OPENIPMI $SERVICELOG
 then
+    PKG_CHECK_MODULES([OPENIPMI_SERVICELOG],[OpenIPMI OpenIPMIposix])
     OPENIPMI_SERVICELOG_EXISTS="yes"
 fi
 AC_MSG_RESULT($OPENIPMI_SERVICELOG_EXISTS)
--- a/mcp/Makefile.am
+++ b/mcp/Makefile.am
@@ -34,7 +34,7 @@
 noinst_HEADERS         = 
 
 pacemakerd_SOURCES     = pacemaker.c corosync.c
-pacemakerd_LDADD       = $(CLUSTERLIBS) 
$(top_builddir)/lib/common/libcrmcommon.la -lcfg -lconfdb
+pacemakerd_LDADD       = $(top_builddir)/lib/common/libcrmcommon.la 
$(CLUSTERLIBS) -lcfg -lconfdb
 
 %.8:   %
        echo Creating $@
--- a/crmd/Makefile.am
+++ b/crmd/Makefile.am
@@ -41,14 +41,13 @@
                cib.c pengine.c tengine.c lrm.c                         \
                utils.c misc.c te_events.c te_actions.c te_utils.c 
te_callbacks.c
 
-crmd_LDADD     = $(CLUSTERLIBS) -llrm                                  \
-               $(top_builddir)/lib/fencing/libstonithd.la              \
+crmd_LDADD     = $(top_builddir)/lib/fencing/libstonithd.la            \
                $(top_builddir)/lib/transition/libtransitioner.la       \
                $(top_builddir)/lib/pengine/libpe_rules.la              \
                $(top_builddir)/lib/cib/libcib.la                       \
                $(top_builddir)/lib/common/libcrmcluster.la             \
-               $(top_builddir)/lib/common/libcrmcommon.la
-
+               $(top_builddir)/lib/common/libcrmcommon.la              \
+               $(CLUSTERLIBS) -llrm
 if BUILD_XML_HELP
 man8_MANS =    crmd.8
 
--- a/lib/common/Makefile.am
+++ b/lib/common/Makefile.am
@@ -38,7 +38,7 @@
 endif
 
 libcrmcluster_la_LDFLAGS = -version-info 1:0:0
-libcrmcluster_la_LIBADD  = $(CLUSTERLIBS) libcrmcommon.la
+libcrmcluster_la_LIBADD  = libcrmcommon.la $(CLUSTERLIBS)
 libcrmcluster_la_DEPENDENCIES = libcrmcommon.la
 
 # Can't use -Wcast-qual here because glib insists on pretending things are 
const  
@@ -51,7 +51,8 @@
 
 libcrmcommon_la_SOURCES        = ipc.c utils.c xml.c iso8601.c 
iso8601_fields.c remote.c mainloop.c
 
-libcrmcommon_la_LDFLAGS        = -version-info 2:0:0  $(GNUTLSLIBS)
+libcrmcommon_la_LDFLAGS        = -version-info 2:0:0
+libcrmcommon_la_LIBADD  = $(GNUTLSLIBS)
 
 clean-generic:
        rm -f *.log *.debug *.xml *~
--- a/lib/plugins/lrm/Makefile.am
+++ b/lib/plugins/lrm/Makefile.am
@@ -29,8 +29,8 @@
 plugin_LTLIBRARIES = stonith.la
 
 stonith_la_SOURCES = raexecstonith.c
-stonith_la_LDFLAGS = -lpils -export-dynamic -module -avoid-version \
-                    $(top_builddir)/lib/fencing/libstonithd.la -llrm
+stonith_la_LDFLAGS = -export-dynamic -module -avoid-version
+stonith_la_LIBADD = $(top_builddir)/lib/fencing/libstonithd.la -lpils -llrm
 
 install-exec-local:
        $(mkinstalldirs) $(DESTDIR)$(lrmdir)
--- a/lib/fencing/Makefile.am
+++ b/lib/fencing/Makefile.am
@@ -25,8 +25,8 @@
 lib_LTLIBRARIES = libstonithd.la
 
 libstonithd_la_SOURCES = st_client.c
-libstonithd_la_LDFLAGS = -version-info 1:0:0                           \
-                       -lplumb -lstonith $(CLUSTERLIBS)                \
-                       $(top_builddir)/lib/common/libcrmcommon.la
+libstonithd_la_LDFLAGS = -version-info 1:0:0
+libstonithd_la_LIBADD = $(top_builddir)/lib/common/libcrmcommon.la     \
+                       -lplumb -lstonith $(CLUSTERLIBS)
 
 AM_CFLAGS = $(INCLUDES)
--- a/cib/Makefile.am
+++ b/cib/Makefile.am
@@ -47,8 +47,8 @@
 cib_SOURCES            = io.c messages.c notify.c      \
                        callbacks.c main.c remote.c common.c
 
-cib_LDADD              = $(COMMONLIBS) $(CRYPTOLIB) $(CLUSTERLIBS)     \
-                       $(top_builddir)/lib/common/libcrmcluster.la
+cib_LDADD              = $(top_builddir)/lib/common/libcrmcluster.la \
+                         $(COMMONLIBS) $(CRYPTOLIB) $(CLUSTERLIBS)
 
 cibmon_SOURCES         = cibmon.c
 cibmon_LDADD           = $(COMMONLIBS) 
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -62,8 +62,8 @@
 noinst_HEADERS         = 
 
 crmadmin_SOURCES       = crmadmin.c
-crmadmin_LDADD         = $(COMMONLIBS) $(CLUSTERLIBS) \
-                       $(top_builddir)/lib/pengine/libpe_status.la
+crmadmin_LDADD         = $(top_builddir)/lib/pengine/libpe_status.la \
+                         $(COMMONLIBS) $(CLUSTERLIBS)
 
 crm_uuid_SOURCES       = crm_uuid.c
 crm_uuid_LDADD         = $(top_builddir)/lib/common/libcrmcluster.la
@@ -75,45 +75,45 @@
 crm_shadow_LDADD       = $(COMMONLIBS) 
 
 crm_node_SOURCES       = ccm_epoche.c
-crm_node_LDADD         = $(COMMONLIBS) $(CLUSTERLIBS) \
-                       $(top_builddir)/lib/common/libcrmcluster.la
+crm_node_LDADD         = $(top_builddir)/lib/common/libcrmcluster.la \
+                         $(COMMONLIBS) $(CLUSTERLIBS)
 
 crm_simulate_SOURCES   = crm_inject.c
 crm_simulate_CFLAGS    = -I$(top_srcdir)/pengine
 
-crm_simulate_LDADD     = $(COMMONLIBS)                                         
\
-                       $(top_builddir)/lib/pengine/libpe_status.la             
\
+crm_simulate_LDADD     = $(top_builddir)/lib/pengine/libpe_status.la           
\
                        $(top_builddir)/pengine/libpengine.la                   
\
                        $(top_builddir)/lib/cib/libcib.la                       
\
-                       $(top_builddir)/lib/transition/libtransitioner.la
+                       $(top_builddir)/lib/transition/libtransitioner.la       
\
+                       $(COMMONLIBS)
 
 crm_diff_SOURCES       = xml_diff.c
 crm_diff_LDADD         = $(COMMONLIBS)
 
 crm_mon_SOURCES                = crm_mon.c
-crm_mon_LDADD          = $(COMMONLIBS) $(SNMPLIBS) $(ESMTPLIBS) -llrm \
-                       $(top_builddir)/lib/pengine/libpe_status.la
+crm_mon_LDADD          = $(top_builddir)/lib/pengine/libpe_status.la           
\
+                         $(COMMONLIBS) $(SNMPLIBS) $(ESMTPLIBS) -llrm
 
 # Arguments could be made that this should live in crm/pengine
 crm_verify_SOURCES     = crm_verify.c
-crm_verify_LDADD       = $(COMMONLIBS) \
-                       $(top_builddir)/lib/pengine/libpe_status.la \
-                       $(top_builddir)/pengine/libpengine.la
+crm_verify_LDADD       = $(top_builddir)/lib/pengine/libpe_status.la   \
+                       $(top_builddir)/pengine/libpengine.la           \
+                       $(COMMONLIBS)
 
 crm_attribute_SOURCES  = crm_attribute.c
 crm_attribute_LDADD    = $(COMMONLIBS)
 
 crm_resource_SOURCES   = crm_resource.c
-crm_resource_LDADD     = $(COMMONLIBS) \
-                       $(top_builddir)/lib/pengine/libpe_rules.la  \
+crm_resource_LDADD     = $(top_builddir)/lib/pengine/libpe_rules.la  \
                        $(top_builddir)/lib/pengine/libpe_status.la \
-                       $(top_builddir)/pengine/libpengine.la
+                       $(top_builddir)/pengine/libpengine.la \
+                       $(COMMONLIBS)
 
 iso8601_SOURCES                = test.iso8601.c
 iso8601_LDADD          = $(COMMONLIBS) 
 
 attrd_SOURCES          = attrd.c
-attrd_LDADD            = $(COMMONLIBS) 
$(top_builddir)/lib/common/libcrmcluster.la
+attrd_LDADD            = $(top_builddir)/lib/common/libcrmcluster.la 
$(COMMONLIBS)
 
 #pingd_SOURCES         = pingd.c
 #pingd_LDADD           = $(COMMONLIBS)
@@ -123,14 +123,14 @@
 
 if BUILD_SERVICELOG
 notifyServicelogEvent_SOURCES  = notifyServicelogEvent.c
-notifyServicelogEvent_CFLAGS   = `pkg-config --cflags servicelog-1`
-notifyServicelogEvent_LDFLAGS  = `pkg-config --libs servicelog-1` 
$(top_builddir)/lib/common/libcrmcommon.la
+notifyServicelogEvent_CFLAGS   = $(SERVICELOG_CFLAGS)
+notifyServicelogEvent_LDADD    = $(top_builddir)/lib/common/libcrmcommon.la 
$(SERVICELOG_LIBS)
 endif
 
 if BUILD_OPENIPMI_SERVICELOG
 ipmiservicelogd_SOURCES        = ipmiservicelogd.c
-ipmiservicelogd_CFLAGS = `pkg-config --cflags OpenIPMI OpenIPMIposix 
servicelog-1`
-ipmiservicelogd_LDFLAGS        = `pkg-config --libs OpenIPMI OpenIPMIposix 
servicelog-1` $(top_builddir)/lib/common/libcrmcommon.la
+ipmiservicelogd_CFLAGS = $(OPENIPMI_SERVICELOG_CFLAGS) $(SERVICELOG_CFLAGS) 
+ipmiservicelogd_LDFLAGS        = $(top_builddir)/lib/common/libcrmcommon.la 
$(OPENIPMI_SERVICELOG_LIBS) $(SERVICELOG_LIBS)
 endif
 
 %.8:   % crm_attribute
--- a/extra/Makefile.am
+++ b/extra/Makefile.am
@@ -20,5 +20,5 @@
 
 SUBDIRS                 =  resources
 
-mibdir = $(datadir)/snmp/mibs
+mibdir = $(datadir)/$(PACKAGE)/snmp/mibs
 mib_DATA = PCMK-MIB.txt
--- a/fencing/Makefile.am       2011-02-25 09:58:45.621572915 +0100
+++ b/fencing/Makefile.am       2011-02-25 10:00:39.024820006 +0100
@@ -42,23 +42,23 @@
 
 stonith_test_SOURCES   = test.c
 
-stonith_test_LDADD     = $(CRYPTOLIB) $(CLUSTERLIBS)                   \
-                       $(top_builddir)/lib/common/libcrmcommon.la      \
+stonith_test_LDADD     = $(top_builddir)/lib/common/libcrmcommon.la    \
                        $(top_builddir)/lib/common/libcrmcluster.la     \
-                       $(top_builddir)/lib/fencing/libstonithd.la
+                       $(top_builddir)/lib/fencing/libstonithd.la      \
+                       $(CRYPTOLIB) $(CLUSTERLIBS)
 
 stonith_admin_SOURCES  = admin.c
 
-stonith_admin_LDADD    = $(CRYPTOLIB) $(CLUSTERLIBS)                   \
+stonith_admin_LDADD    = $(top_builddir)/lib/common/libcrmcommon.la    \
                        $(top_builddir)/lib/cib/libcib.la               \
                        $(top_builddir)/lib/pengine/libpe_status.la     \
-                       $(top_builddir)/lib/common/libcrmcommon.la      \
                        $(top_builddir)/lib/common/libcrmcluster.la     \
-                       $(top_builddir)/lib/fencing/libstonithd.la
+                       $(top_builddir)/lib/fencing/libstonithd.la      \
+                       $(CRYPTOLIB) $(CLUSTERLIBS)
 
 stonithd_SOURCES       = main.c commands.c remote.c
 
-stonithd_LDADD         = $(CRYPTOLIB) $(CLUSTERLIBS)                   \
-                       $(top_builddir)/lib/common/libcrmcommon.la      \
+stonithd_LDADD         = $(top_builddir)/lib/common/libcrmcommon.la    \
                        $(top_builddir)/lib/common/libcrmcluster.la     \
-                       $(top_builddir)/lib/fencing/libstonithd.la
+                       $(top_builddir)/lib/fencing/libstonithd.la      \
+                       $(CRYPTOLIB) $(CLUSTERLIBS)
--- a/pengine/Makefile.am
+++ b/pengine/Makefile.am
@@ -71,16 +71,17 @@
 libpengine_la_SOURCES  = pengine.c allocate.c utils.c constraints.c \
                        native.c group.c clone.c master.c graph.c
-libpengine_la_LIBADD    = $(top_builddir)/lib/pengine/libpe_status.la
+libpengine_la_LIBADD    = $(top_builddir)/lib/pengine/libpe_status.la \
+       $(top_builddir)/lib/cib/libcib.la
 
 pengine_SOURCES        = main.c
-pengine_LDADD  = $(COMMONLIBS) $(top_builddir)/lib/cib/libcib.la
+pengine_LDADD  = $(top_builddir)/lib/cib/libcib.la $(COMMONLIBS)
 # libcib for get_object_root()
 #              $(top_builddir)/lib/hbclient/libhbclient.la
 
 ptest_SOURCES  = ptest.c 
-ptest_LDADD    = $(COMMONLIBS)                                         \
-               $(top_builddir)/lib/cib/libcib.la                       \
-               $(top_builddir)/lib/transition/libtransitioner.la
+ptest_LDADD    = $(top_builddir)/lib/cib/libcib.la                     \
+               $(top_builddir)/lib/transition/libtransitioner.la       \
+               $(COMMONLIBS)
 
 install-exec-local:
        $(mkinstalldirs) $(DESTDIR)/$(PE_STATE_DIR)

--- Begin Message ---
On 22/07/2010 01:56, Simon Horman wrote:
On Wed, Jul 21, 2010 at 09:40:10PM +0200, Ultrabug wrote:
On Wednesday 21 July 2010 03:49:42 Simon Horman wrote:
On Tue, Jul 20, 2010 at 05:35:01PM +0200, Ultrabug wrote:
----- Original Message -----
From: Simon Horman<[email protected]>
To: The Pacemaker cluster resource manager
<[email protected]>  Sent: Tue, 20 Jul 2010 05:10:32 +0200
(CEST)
Subject: Re: [Pacemaker] Proposing patch for ld --as-needed

On Sat, Jul 17, 2010 at 01:12:20PM +0200, Ultrabug wrote:
Dear list,

I would like to ask you about a possible upstream modification regarding
the -- as-needed ld flag for which we Gentoo users need to patch the
pacemaker sources to get it compile.

I'm attaching the patch which, as you can see, is relatively small and
simple (looks to me at least). The question is whether or not you think
this could be done upstream ?

Thank you for your interest in this and all you work,

Out of interest, could you explain why this is needed?
Is it because gold is being used as the linker?

[ please don't top-post ]

[ noticed after sending, sorry ]


Thanks for the link.

I guess what is happening without --as-needed is that the curses
library is being dragged in somewhere, somehow - without your proposed
change CURSESLIBS is used exactly nowhere.


Actually the two chunks of the patch have different purposes.

The first one is needed because the linking order has a meaning on a as-needed
system and libpengine uses functions that are defined in libpe_status.

Here is an example of failing build : http://paste.pocoo.org/show/239905/
If you try to compile a program that uses libpengine that doesn't need
libpe_status, e.g. gcc -Wl,--as-needed ptest.c -o ptest -lpe_status -lpengine
(shortened version of actual linking from pacemaker build.log) linking will
fail. Linker evaluates that statement sequentially starting from the inner
most lib:
   1) do I need libpe_status? No, forget about it.
   2) do I need libpengine? Yes, please.
   3) is everything all right? Ups, I don't know what `was_processing_warning'
is, die...


The second one explicitly adds CURSESLIBS dependency to libpe_status.
If pacemaker detects ncurses, you get HAVE_NCURSES_H and e.g.
status_print (used in  lib/pengine/native.c etc.) becomes wrapper
around "printw" (see configure.ac). You need to provide `printw' or any linking
with libpe_status will fail.
Fail build example : http://paste.pocoo.org/show/239916/

So I think that your change is a step in the right direction,
though for completeness I think that you also need to give the same
treatment to libpe_rule as common.c seems to make curses calls.

Could you considering updating your patch to include my proposed
additions below? And could you please include a description that describes
what the patch does? Perhaps something like this:


Sure, if you agree with the explanations above, I'll summarize them and add
them in the patch which I'll resubmit to you for integration.

I think tat you have a better handle on this problem than me.
So yes, please summarise your explanation above and use
it as a preamble to the patch.

[snip]

Sure mate, here it is attached. I hope it's explained well enough.
Thanks for your help and interest.

Kind regards



_______________________________________________
Pacemaker mailing list: [email protected]
http://oss.clusterlabs.org/mailman/listinfo/pacemaker

Project Home: http://www.clusterlabs.org
Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
Bugs: http://developerbugs.linux-foundation.org/enter_bug.cgi?product=Pacemaker

# This patch sets the build processs 'ld --as-needed' compliant
#
# First chunck corrects the linking order so that libpe_status is linked
# after libpengine. This is needed because the linker evaluates statements
# sequentially starting from the inner most lib and libpengine uses functions
# that are defined in libpe_status.
#
# Second chunck explicitly adds CURSESLIBS dependency to libpe_status.
# This is requested from the configure.ac upon ncurses detection so we
# need to provide 'printw' or any linking with libpe_status will fail.
--- pengine/Makefile.am
+++ pengine/Makefile.am
@@ -58,6 +58,7 @@
 # -L$(top_builddir)/lib/pils -lpils -export-dynamic -module -avoid-version
 libpengine_la_SOURCES  = pengine.c allocate.c utils.c constraints.c \
                        native.c group.c clone.c master.c graph.c
+libpengine_la_LIBADD    = $(top_builddir)/lib/pengine/libpe_status.la

 pengine_SOURCES        = main.c
 pengine_LDADD  = $(COMMONLIBS) $(top_builddir)/lib/cib/libcib.la
--- lib/pengine/Makefile.am
+++ lib/pengine/Makefile.am
@@ -34,7 +34,7 @@

 libpe_status_la_LDFLAGS        = -version-info 2:0:0
 libpe_status_la_SOURCES        =  $(rule_files) $(status_files)
-libpe_status_la_LIBADD = -llrm
+libpe_status_la_LIBADD = -llrm @CURSESLIBS@

 clean-generic:
        rm -f *.log *.debug *~
_______________________________________________
Pacemaker mailing list: [email protected]
http://oss.clusterlabs.org/mailman/listinfo/pacemaker

Project Home: http://www.clusterlabs.org
Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
Bugs: http://developerbugs.linux-foundation.org/enter_bug.cgi?product=Pacemaker

--- End Message ---

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/

Reply via email to