Build Problem - michaelsevilla/mantle-popper GitHub Wiki

Build Problem

Goal: embed Lua in the MDS using the Lua src Sage linked in

Reproduce the problem

Get code, launch container, go inside container:

$ git clone https://github.com/michaelsevilla/ceph.git mantle
$ docker run -d -it \
  --name ceph-dev \
  -v `pwd`/mantle:/ceph\
  --entrypoint=/bin/bash \
  cephbuilder/ceph:jewel
$ docker exec -it ceph-dev /bin/bash

Once inside the container:

$ git checkout -b mantle remotes/origin/mantle
$ git submodule update --init --recursive
$ ./autogen.sh; ./configure; make -j32

Explanation of Code Changes

  1. Include Lua in the balancer module:

diff --git a/src/mds/MDBalancer.cc b/src/mds/MDBalancer.cc index 784263e..ad9dd28 100644 --- a/src/mds/MDBalancer.cc +++ b/src/mds/MDBalancer.cc @@ -32,6 +32,7 @@ #include #include #include +#include <lua.hpp> using std::map; using std::vector; ```

  1. Add headers and libs to MDS library:

diff --git a/src/mds/Makefile-server.am b/src/mds/Makefile-server.am index 36031eb..33ada8f 100644 --- a/src/mds/Makefile-server.am +++ b/src/mds/Makefile-server.am @@ -1,7 +1,8 @@ if WITH_MDS

libmds_la_SOURCES = $(LIBMDS_SOURCES) -libmds_la_LIBADD = $(LIBMDS_DEPS) +libmds_la_LIBADD = $(LIBMDS_DEPS) $(LIBLUA) +libmds_la_CPPFLAGS = $(LIBLUA_CPPFLAGS) noinst_LTLIBRARIES += libmds.la

noinst_HEADERS +=
```

ERROR: Can't compile dencoder client library

[... snip ...]
CXX      mds/ceph_dencoder-MDBalancer.o
mds/MDBalancer.cc:35:19: fatal error: lua.hpp: No such file or directory
 #include <lua.hpp>
                   ^
compilation terminated.
make[3]: *** [mds/ceph_dencoder-MDBalancer.o] Error 1
[... snip ...]

Figure out why it failed

make -n

This gives me the actual g++ command it is trying to do:

[... snip ...]
echo "  CXX     " mds/ceph_dencoder-MDBalancer.o;g++ -DHAVE_CONFIG_H -I.  -D__CEPH__ -D_FILE_OFFSET_BITS=64 -D_THREAD_SAFE -D__STDC_FORMAT_MACROS -D_GNU_SOURCE -DCEPH_LIBDIR=\"/usr/local/lib\" -DCEPH_PKGLIBDIR=\"/usr/local/lib/ceph\" -DGTEST_USE_OWN_TR1_TUPLE=0 -D_REENTRANT     -I/usr/include/nss -I/usr/include/nspr    -Wall -Wtype-limits -Wignored-qualifiers -Winit-self -Wpointer-arith -Werror=format-security -fno-strict-aliasing -fsigned-char -rdynamic -ftemplate-depth-1024 -Wnon-virtual-dtor -Wno-invalid-offsetof -O2 -g -pipe -Wall -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 -fPIE -fstack-protector    -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free  -Wstrict-null-sentinel -fno-var-tracking-assignments -DWITH_RBD -DWITH_RADOSGW -g -O2 -std=gnu++11 -MT mds/ceph_dencoder-MDBalancer.o -MD -MP -MF mds/.deps/ceph_dencoder-MDBalancer.Tpo -c -o mds/ceph_dencoder-MDBalancer.o `test -f 'mds/MDBalancer.cc' || echo './'`mds/MDBalancer.cc
mv -f mds/.deps/ceph_dencoder-MDBalancer.Tpo mds/.deps/ceph_dencoder-MDBalancer.Po
[... snip ...]

That g++ commands works if I include -Ilua/src/.

FAILED Solutions

Try automake keywords to get dencoder to include -Ilua/src:

diff --git a/src/mds/Makefile-client.am b/src/mds/Makefile-client.am
index 0cfd8bf..6e1c476 100644
--- a/src/mds/Makefile-client.am
+++ b/src/mds/Makefile-client.am
@@ -1,4 +1,11 @@
 # There are no libmds_types so use the full mds library for dencoder for now
 DENCODER_SOURCES += $(LIBMDS_SOURCES)
+#DENCODER_CPPFLAGS = $(LIBLUA_CPPFLAGS)
+#DENCODER_CXXFLAGS = $(LIBLUA_CPPFLAGS)
+#DENCODER_HEADERS = -I${top_srcdir}/src/lua/src
+#noinst_CPPFLAGS = $(LIBLUA_CPPFLAGS)
+#noinst_CXXFLAGS = $(LIBLUA_CPPFLAGS)
+#noinst_HEADERS = -I${top_srcdir}/src/lua/src
+#AM_CFLAGS = $(LIBLUA_CPPFLAGS)

 DENCODER_DEPS += $(LIBMDS_DEPS)

Hmmm... it doesn't look like it is picking up the headers in the same way that a compiled library does. I need to figure out how to get the headers into a client module. I also tried adding these variables to a new Makefile-env.am.

I also checked for a high level command that compiles dencoder:

msevilla@pl3:~/mantle/src/mds$ grep -i "dencoder" ../Makefile*.am
../Makefile.am:test/encoding/ceph_dencoder.cc: ./ceph_ver.h
../Makefile-env.am:# This is used by the dencoder test
../Makefile-env.am:DENCODER_SOURCES =
../Makefile-env.am:DENCODER_DEPS =

Nothing looks like it explicitly compiles dencoder.

SUCCESSFUL Solution: include Lua for all compile commands:

diff --git a/src/Makefile-env.am b/src/Makefile-env.am
index 650f936..dccae8d 100644
--- a/src/Makefile-env.am
+++ b/src/Makefile-env.am
@@ -85,7 +85,8 @@ AM_COMMON_CPPFLAGS = \
        -D__STDC_FORMAT_MACROS \
        -D_GNU_SOURCE \
        -DCEPH_LIBDIR=\"${libdir}\" \
-       -DCEPH_PKGLIBDIR=\"${pkglibdir}\"
+       -DCEPH_PKGLIBDIR=\"${pkglibdir}\" \
+       ${LIBLUA_CPPFLAGS}

 if LINUX
 AM_COMMON_CPPFLAGS += \

I hate this solution... what is a better way to do it?

⚠️ **GitHub.com Fallback** ⚠️