Re: Build fail on alpine linux

2016-08-08 Thread Willy Tarreau
On Mon, Aug 08, 2016 at 02:15:04PM +0200, Baptiste wrote:
> Here you go :)

Applied, thanks!
willy



Re: Build fail on alpine linux

2016-08-08 Thread Baptiste
On Mon, Aug 8, 2016 at 2:09 PM, Willy Tarreau  wrote:

> On Mon, Aug 08, 2016 at 02:05:58PM +0200, Baptiste wrote:
> > It won't, I'm sending you a patch soon to define _GNU_SOURCE in
> proto_tcp.c
> > :)
> > (which seems to "fix" the problem, also I don't know if this is the right
> > way to go)
>
> Perfect, thanks. Please put it before the first include in the file, it
> will avoid some inconsistencies between the files causing some build
> issues.
>
> Thanks,
> Willy
>

Here you go :)

Baptiste
From 2a1c2b20eb514e7b27bc8bf48d3773bfe4b761dd Mon Sep 17 00:00:00 2001
From: Baptiste Assmann 
Date: Mon, 8 Aug 2016 14:12:08 +0200
Subject: [PATCH] BUILD: make proto_tcp.c compatible with musl library

musl library expose tcp_info structure only when _GNU_SOURCE is defined.
This is required to build HAProxy on OSes relying musl such as Alpine
Linux.
---
 src/proto_tcp.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index 4f6b3c3..717ba28 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -10,6 +10,11 @@
  *
  */
 
+/* this is to have tcp_info defined on systems using musl
+ * library, such as Alpine Linux
+ */
+#define _GNU_SOURCE
+
 #include 
 #include 
 #include 
-- 
1.9.1



Re: Build fail on alpine linux

2016-08-08 Thread Willy Tarreau
On Mon, Aug 08, 2016 at 02:05:58PM +0200, Baptiste wrote:
> It won't, I'm sending you a patch soon to define _GNU_SOURCE in proto_tcp.c
> :)
> (which seems to "fix" the problem, also I don't know if this is the right
> way to go)

Perfect, thanks. Please put it before the first include in the file, it
will avoid some inconsistencies between the files causing some build
issues.

Thanks,
Willy



Re: Build fail on alpine linux

2016-08-08 Thread Baptiste
On Mon, Aug 8, 2016 at 1:50 PM, Willy Tarreau  wrote:

> On Mon, Aug 08, 2016 at 01:28:07PM +0200, Baptiste wrote:
> > Here you go:
> >   # fgrep -r tcp_info /usr/include/*
> >   /usr/include/linux/tcp.h:struct tcp_info {
> >   /usr/include/netinet/tcp.h:struct tcp_info
>
> It's strange that your netinet/tcp.h has it and that it doesn't work, maybe
> there's some ifdef around.
>
>
yes :) Just found it!
There is a #ifdef _GNU_SOURCE  a few lines above and nothing is indented...



> > It seems to be exactly the same that on my ubuntu 14.04.
> > alpine linux natively use musl, an alternative libc library. I tried to
> > install a "real" libc instead, with the same error as above (that said, I
> > wonder how much my libc library was used or not, I'm investigating in
> that
> > direction).
>
> Interesting. Thus there's something I don't understand well, you don't
> build
> natively then, do you ? Aren't you using a cross-compiler instead ? If so,
> that may be where we need to dig.
>
>
I first build natively, then I tried using libc (since I don't know well
musl).


> > Note that I don't have any problem compiling HAProxy 1.6-latest on the
> same
> > OS.
>
> I'm not surprized, the tcp_info was added in 1.7 a few weeks ago :-)
>
> Please tell me if the attached patch fixes the issue.
>
> Thanks,
> Willy
>


It won't, I'm sending you a patch soon to define _GNU_SOURCE in proto_tcp.c
:)
(which seems to "fix" the problem, also I don't know if this is the right
way to go)

Baptiste


Re: Build fail on alpine linux

2016-08-08 Thread Willy Tarreau
On Mon, Aug 08, 2016 at 01:28:07PM +0200, Baptiste wrote:
> Here you go:
>   # fgrep -r tcp_info /usr/include/*
>   /usr/include/linux/tcp.h:struct tcp_info {
>   /usr/include/netinet/tcp.h:struct tcp_info

It's strange that your netinet/tcp.h has it and that it doesn't work, maybe
there's some ifdef around.

> It seems to be exactly the same that on my ubuntu 14.04.
> alpine linux natively use musl, an alternative libc library. I tried to
> install a "real" libc instead, with the same error as above (that said, I
> wonder how much my libc library was used or not, I'm investigating in that
> direction).

Interesting. Thus there's something I don't understand well, you don't build
natively then, do you ? Aren't you using a cross-compiler instead ? If so,
that may be where we need to dig.

> Note that I don't have any problem compiling HAProxy 1.6-latest on the same
> OS.

I'm not surprized, the tcp_info was added in 1.7 a few weeks ago :-)

Please tell me if the attached patch fixes the issue.

Thanks,
Willy
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index 4f6b3c3..0e27fdd 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -61,6 +61,11 @@
 #include 
 #include 
 
+/* be sure to include struct tcp_info on some linux distros */
+#if defined(TCP_INFO) && defined(USE_NETFILTER)
+#include 
+#endif
+
 static int tcp_bind_listeners(struct protocol *proto, char *errmsg, int 
errlen);
 static int tcp_bind_listener(struct listener *listener, char *errmsg, int 
errlen);
 


Re: Build fail on alpine linux

2016-08-08 Thread Baptiste
On Mon, Aug 8, 2016 at 12:30 PM, Willy Tarreau  wrote:

> Hi Baptiste,
>
> On Mon, Aug 08, 2016 at 12:21:54PM +0200, Baptiste wrote:
> > Hi All,
> >
> > I test my HAProxy code in docker containers over alpine Linux and I can't
> > build the haproxy -dev branch anymore...
> > I have the following error:
> > gcc -Iinclude -Iebtree -Wall  -O0 -g -fno-strict-aliasing
> > -Wdeclaration-after-statement   -DCONFIG_HAP_LINUX_SPLICE -DTPROXY
> > -DCONFIG_HAP_LINUX_TPROXY -DCONFIG_HAP_CRYPT -DUSE_ZLIB  -DENABLE_POLL
> > -DENABLE_EPOLL -DUSE_CPU_AFFINITY -DASSUME_SPLICE_WORKS -DUSE_ACCEPT4
> > -DNETFILTER -DUSE_GETSOCKNAME -DUSE_OPENSSL  -DUSE_SYSCALL_FUTEX
> -DUSE_PCRE
> > -I/usr/include  -DCONFIG_HAPROXY_VERSION=\"1.7-dev3-aa1ea8-87\"
> > -DCONFIG_HAPROXY_DATE=\"2016/08/07\" -c -o src/proto_tcp.o
> src/proto_tcp.c
> > src/proto_tcp.c: In function 'get_tcp_info':
> > src/proto_tcp.c:2329:18: error: storage size of 'info' isn't known
> >   struct tcp_info info;
> >   ^
> > src/proto_tcp.c:2329:18: warning: unused variable 'info'
> [-Wunused-variable]
> > Makefile:791: recipe for target 'src/proto_tcp.o' failed
> > make: *** [src/proto_tcp.o] Error 1
>
> It's embarrassing because it looks like your libc is missing this
> definition though it properly has TCP_INFO defined. Let's hope it's
> only a matter of adding an extra include. Could you please search
> where it appears below /usr/include ?
>
> Willy
>

Here you go:
  # fgrep -r tcp_info /usr/include/*
  /usr/include/linux/tcp.h:struct tcp_info {
  /usr/include/netinet/tcp.h:struct tcp_info

It seems to be exactly the same that on my ubuntu 14.04.
alpine linux natively use musl, an alternative libc library. I tried to
install a "real" libc instead, with the same error as above (that said, I
wonder how much my libc library was used or not, I'm investigating in that
direction).

Note that I don't have any problem compiling HAProxy 1.6-latest on the same
OS.

Baptiste


Re: Build fail on alpine linux

2016-08-08 Thread Willy Tarreau
Hi Baptiste,

On Mon, Aug 08, 2016 at 12:21:54PM +0200, Baptiste wrote:
> Hi All,
> 
> I test my HAProxy code in docker containers over alpine Linux and I can't
> build the haproxy -dev branch anymore...
> I have the following error:
> gcc -Iinclude -Iebtree -Wall  -O0 -g -fno-strict-aliasing
> -Wdeclaration-after-statement   -DCONFIG_HAP_LINUX_SPLICE -DTPROXY
> -DCONFIG_HAP_LINUX_TPROXY -DCONFIG_HAP_CRYPT -DUSE_ZLIB  -DENABLE_POLL
> -DENABLE_EPOLL -DUSE_CPU_AFFINITY -DASSUME_SPLICE_WORKS -DUSE_ACCEPT4
> -DNETFILTER -DUSE_GETSOCKNAME -DUSE_OPENSSL  -DUSE_SYSCALL_FUTEX -DUSE_PCRE
> -I/usr/include  -DCONFIG_HAPROXY_VERSION=\"1.7-dev3-aa1ea8-87\"
> -DCONFIG_HAPROXY_DATE=\"2016/08/07\" -c -o src/proto_tcp.o src/proto_tcp.c
> src/proto_tcp.c: In function 'get_tcp_info':
> src/proto_tcp.c:2329:18: error: storage size of 'info' isn't known
>   struct tcp_info info;
>   ^
> src/proto_tcp.c:2329:18: warning: unused variable 'info' [-Wunused-variable]
> Makefile:791: recipe for target 'src/proto_tcp.o' failed
> make: *** [src/proto_tcp.o] Error 1

It's embarrassing because it looks like your libc is missing this
definition though it properly has TCP_INFO defined. Let's hope it's
only a matter of adding an extra include. Could you please search
where it appears below /usr/include ?

Willy



Build fail on alpine linux

2016-08-08 Thread Baptiste
Hi All,

I test my HAProxy code in docker containers over alpine Linux and I can't
build the haproxy -dev branch anymore...
I have the following error:
gcc -Iinclude -Iebtree -Wall  -O0 -g -fno-strict-aliasing
-Wdeclaration-after-statement   -DCONFIG_HAP_LINUX_SPLICE -DTPROXY
-DCONFIG_HAP_LINUX_TPROXY -DCONFIG_HAP_CRYPT -DUSE_ZLIB  -DENABLE_POLL
-DENABLE_EPOLL -DUSE_CPU_AFFINITY -DASSUME_SPLICE_WORKS -DUSE_ACCEPT4
-DNETFILTER -DUSE_GETSOCKNAME -DUSE_OPENSSL  -DUSE_SYSCALL_FUTEX -DUSE_PCRE
-I/usr/include  -DCONFIG_HAPROXY_VERSION=\"1.7-dev3-aa1ea8-87\"
-DCONFIG_HAPROXY_DATE=\"2016/08/07\" -c -o src/proto_tcp.o src/proto_tcp.c
src/proto_tcp.c: In function 'get_tcp_info':
src/proto_tcp.c:2329:18: error: storage size of 'info' isn't known
  struct tcp_info info;
  ^
src/proto_tcp.c:2329:18: warning: unused variable 'info' [-Wunused-variable]
Makefile:791: recipe for target 'src/proto_tcp.o' failed
make: *** [src/proto_tcp.o] Error 1


I checked, the struct tcp_info is well defined in files included by haproxy
(/usr/src/netinet/tcp.h and /usr/src/linux/tcp.h)...
The same source code compile properly on my laptop powered (sic) by
Ubuntu...

Any help would be much appreciated since I don't know where to dig anymore
and I don't want to use ubuntu in my containers..

Baptiste