nigoroll / libvmod-dynamic

The Varnish dns/named director continued
BSD 2-Clause "Simplified" License
95 stars 34 forks source link

can not build on alpine:3.13 #68

Closed raybog closed 3 years ago

raybog commented 3 years ago

Trying to build varnish docker on latest alpine:

FROM alpine:3.13 AS builder
ENV LIBVMOD_DYNAMIC_VERSION=2.3.0
RUN apk --no-cache add automake autoconf libtool make curl python3 py3-sphinx py-docutils pkgconf \
                     gcc make g++ zlib-dev pcre-dev libedit-dev readline-dev libexecinfo-dev linux-headers \
                     varnish varnish-dev

RUN cd /tmp && curl -sSLO https://github.com/nigoroll/libvmod-dynamic/archive/v${LIBVMOD_DYNAMIC_VERSION}.zip && \
  unzip v${LIBVMOD_DYNAMIC_VERSION}.zip && cd libvmod-dynamic-${LIBVMOD_DYNAMIC_VERSION} && \
  ./autogen.sh && ./configure && make && make install

Getting this error:

/usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: .libs/vmod_dynamic_service.o:/tmp/libvmod-dynamic-2.3.0/src/vmod_dynamic.h:181: multiple definition of `objects'; .libs/vmod_dynamic.o:/tmp/libvmod-dynamic-2.3.0/src/vmod_dynamic.h:181: first defined here
collect2: error: ld returned 1 exit status
make[2]: Leaving directory '/tmp/libvmod-dynamic-2.3.0/src'
nigoroll commented 3 years ago

I think this was already fixed here: https://github.com/nigoroll/libvmod-dynamic/commit/8d3f29b4ac945a3d90bca0bf9049895cc637df57#diff-ec18248580701e113e2ce71ce3b616e19fd9e1ccacfe58f43af515c3a8252032L183

raybog commented 3 years ago

I have tried with: 8d3f29b and getting different errors now:

vmod_dynamic.c:` In function 'dynamic_add': vmod_dynamic.c:332:22: error: storage size of 'ep' isn't known 332 | struct vrt_endpoint ep; | ^~ In file included from /usr/include/varnish/cache/cache.h:51, from vmod_dynamic.c:42: vmod_dynamic.c:399:16: error: 'VRT_ENDPOINT_MAGIC' undeclared (first use in this function) 399 | INIT_OBJ(&ep, VRT_ENDPOINT_MAGIC); | ^~~~~~~~~~~~~~~~~~ /usr/include/varnish/miniobj.h:17:18: note: in definition of macro 'INIT_OBJ' 17 | (to)->magic = (type_magic); \ | ^~~~~~~~~~ vmod_dynamic.c:399:16: note: each undeclared identifier is reported only once for each function it appears in 399 | INIT_OBJ(&ep, VRT_ENDPOINT_MAGIC); | ^~~~~~~~~~~~~~~~~~ /usr/include/varnish/miniobj.h:17:18: note: in definition of macro 'INIT_OBJ' 17 | (to)->magic = (type_magic); \ | ^~~~~~~~~~ vmod_dynamic.c:413:5: error: 'struct vrt_backend' has no member named 'endpoint' 413 | vrt.endpoint = &ep; | ^ vmod_dynamic.c:332:22: error: unused variable 'ep' [-Werror=unused-variable] 332 | struct vrt_endpoint ep; | ^~ cc1: all warnings being treated as errors make[2]: Leaving directory `'/tmp/libvmod-dynamic-8d3f29b4ac945a3d90bca0bf9049895cc637df57/src

nigoroll commented 3 years ago

Yes, this is because the current master head is for varnish-cache master and I presume you are trying to build with 6.5.x. But because there are quite some changes happening at the moment, I am not even sure if it is up-to-date as of today.

We shall bring the 6.5 branch up to date.

huiser commented 3 years ago

This seems to fix it:

root@8a81ad28d485:/src/libvmod-dynamic# git diff 
diff --git a/src/vmod_dynamic.h b/src/vmod_dynamic.h
index c6c5cd5..9b3778f 100644
--- a/src/vmod_dynamic.h
+++ b/src/vmod_dynamic.h
@@ -178,7 +178,7 @@ struct vmod_dynamic_director {
        enum dynamic_ttl_e                      ttl_from;
 };

-VTAILQ_HEAD(vmod_dynamic_head, vmod_dynamic_director) objects;
+extern VTAILQ_HEAD(vmod_dynamic_head, vmod_dynamic_director) objects;

 extern struct vmod_dynamic_head objects;
huiser commented 3 years ago

BTW, I works without the patch on Debian buster (gcc v8)

See https://github.com/Shopify/semian/issues/261#issuecomment-781685569

huiser commented 3 years ago

Workaround for GCC 10:

CFLAGS="-fcommon" ./configure
nigoroll commented 3 years ago

I have updated the 6.5 branch and tagged a v2.3.1 release. Both contain fixes and improvements backported from trunk and also the fix for this issue.