Finally got VTest compiling and working as expected (I think) under Cygwin. 
config.h had to be adjusted and vtc_syslog.c needed <netinet/in.h> included, 
but nothing big. However, there’s some weird poll() behavior where it never 
raises POLLHUP or POLLERR and returns immediately with POLLIN flag raised when 
the other side disconnects but read() consistently returns no error and no 
data, so when haproxy gets killed vtc_record() keeps polling its STDOUT until 
the thread itself times out because poll() doesn’t seem to return correct flags.

I hacked vtc_record() to exit the loop when poll() returns with POLLIN raised, 
but read() returns 0 bytes two times in a row. This got most of the reg-tests 
running successfully. Now some of them fail because the expected syslog format 
doesn’t match what HA-Proxy actually logs:

**** Slog_1  0.2 syslog|<6>127.0.0.1:61336 [04/Jun/2019:12:56:28.053] 
ssl-offload-http~ ssl-offload-http/http 0/0/-1/-1/0 503 220 - - SC-- 1/1/0/0/3 
0/0 "POST#20#2F#31#20HTTP#2F#31#2E#31"
**   Slog_1  0.2 === expect ~ "ssl-offload-http/http .* \"POST /[1-8] 
HTTP/(2\\.0...
---- Slog_1  0.2 EXPECT FAILED ~ "ssl-offload-http/http .* "POST /[1-8] 
HTTP/(2\.0|1\.1)""

or

**** S     0.2 syslog|<134>Jun  4 13:40:59 haproxy[49078]: 127.0.0.1:62880 
[04/Jun/2019:13:40:59.348] fe be/srv 0/0/0/34/34 200 17477 - - ---- 1/1/0/0/0 
0/0 {#48#50#68#78#38#6E#35#39#71#6A#6A#4E#42#4C#6A#50} 
{#68#74#62#35#36#71#44#64#43#63#62#52#56#54#66#53} 
"GET#20#2F#20HTTP#2F#31#2E#31"
**   S     0.2 === expect ~ "[^:\\[ ]\\[${h_pid}\\]: .* .* fe be/srv .* 200 
1[0...
---- S     0.2 EXPECT FAILED ~ "[^:\[ ]\[49078\]: .* .* fe be/srv .* 200 
1[0-9]{4} - - ---- .* .* {HPhx8n59qjjNBLjP} {htb56qDdCcbRVTfS} "GET / 
HTTP/1\.1""

I’ve no idea why it logs literals encoded like this and what should be changed 
in log configuration or maybe in build options to get it logging in expected 
format.

Bob

From: Илья Шипицин <chipits...@gmail.com>
Sent: Monday, June 3, 2019 4:21 PM
To: Zakharychev, Bob <bob.zakharyc...@spirent.com>
Cc: HAProxy <haproxy@formilux.org>
Subject: Re: cygwin compilation error

btw, Bob, can you run reg-tests on cygwin ? maybe you can prepare travis-ci 
config for cygwin ?

вт, 4 июн. 2019 г. в 00:57, Zakharychev, Bob 
<bob.zakharyc...@spirent.com<mailto:bob.zakharyc...@spirent.com>>:
Ilya,

FWIW: I tried to build 2.0-dev5 on my working copy of Cygwin-64 3.0.7 with GCC 
toolchain 8.3.0 running just

make TARGET=cygwin

and it compiled successfully, but initially didn’t link due to

src/mux_h2.o: In function `h2s_frt_make_resp_data':
/build/haproxy-2.0-dev5/src/mux_h2.c:4405: undefined reference to `trace'
/build/haproxy-2.0-dev5/src/mux_h2.c:4405:(.text+0xce79): relocation truncated 
to fit: R_X86_64_PC32 against undefined symbol `trace'
collect2: error: ld returned 1 exit status
make: *** [Makefile:821: haproxy] Error 1

I think this is due to lack of support for weak function attribute in the 
Cygwin GCC linker – one comment about USE_OBSOLETE_LINKER in the code seems to 
be mentioning this as well. I added a crude workaround and successfully linked 
the executable with it. Here’s the patch, maybe you folks can improve it or 
just accept it as is. It just uses the TRACE flag and conditionally defines the 
dummy trace() in standard.c if the flag is not present (which is essentially 
the same as having the linker override a weak function).

diff -uw a/src/standard.c b/src/standard.c
--- a/src/standard.c  2019-06-02 06:06:08.000000000 -0400
+++ b/src/standard.c  2019-06-03 14:23:15.437931700 -0400
@@ -4298,10 +4298,12 @@
}
 /* do nothing, just a placeholder for debugging calls, the real one is in 
trace.c */
-__attribute__((weak,format(printf, 1, 2)))
+#ifndef TRACE
+__attribute__((format(printf, 1, 2)))
void trace(char *msg, ...)
{
}
+#endif
 /*
  * Local variables:

I also ran into a linker warning when building with Lua support:

/usr/lib/gcc/x86_64-pc-cygwin/8.3.0/../../../../x86_64-pc-cygwin/bin/ld: 
warning: --export-dynamic is not supported for PE+ targets, did you mean 
--export-all-symbols?

I was able to get rid of it with the following modification to the Makefile 
(what the warning suggested):

diff -uw a/Makefile b/Makefile
--- a/Makefile  2019-06-02 06:06:08.000000000 -0400
+++ b/Makefile  2019-06-03 14:48:47.098917100 -0400
@@ -406,6 +406,8 @@
     USE_POLL USE_TPROXY USE_OBSOLETE_LINKER)
   # Cygwin adds IPv6 support only in version 1.7 (in beta right now).
   TARGET_CFLAGS  = $(if $(filter 1.5.%, $(shell uname -r)), -DUSE_IPV6 
-DAF_INET6=23 -DINET6_ADDRSTRLEN=46, )
+  # --export-dynamic is not the right way to export symbols in Cygwin
+  EXPORT_SYMBOL = --export-all-symbols
endif

# set the default settings according to the target above

Other than these two rather small issues 2.0-dev5 built successfully on my 
Cygwin (and I then also successfully built it with threading support, PCRE, 
ZLib, OpenSSL and Lua 5.3 by enabling corresponding flags though I didn’t run 
any tests), so something must be missing in your build environment. Most system 
headers should be in /usr/include if cygwin-devel is installed, so you might 
want to start with checking if expected header files are there…

Hth,
   Bob

From: Илья Шипицин <chipits...@gmail.com<mailto:chipits...@gmail.com>>
Sent: Monday, June 3, 2019 11:03 AM
To: Gil Bahat <bahat....@gmail.com<mailto:bahat....@gmail.com>>
Cc: Willy Tarreau <w...@1wt.eu<mailto:w...@1wt.eu>>; HAProxy 
<haproxy@formilux.org<mailto:haproxy@formilux.org>>
Subject: Re: cygwin compilation error



пн, 3 июн. 2019 г. в 20:00, Gil Bahat 
<bahat....@gmail.com<mailto:bahat....@gmail.com>>:
poll.h seems to be present at cygwin-devel:
https://cygwin.com/cgi-bin2/package-grep.cgi?grep=poll.h&arch=x86_64

hope that helps.



cygwin-devel is installed

https://travis-ci.com/chipitsine/haproxy/builds/114061737#L165-L172


Regards,

Gil

On Mon, Jun 3, 2019 at 5:53 PM Илья Шипицин 
<chipits...@gmail.com<mailto:chipits...@gmail.com>> wrote:


пн, 3 июн. 2019 г. в 17:56, Willy Tarreau <w...@1wt.eu<mailto:w...@1wt.eu>>:
Hi Ilya,

On Mon, Jun 03, 2019 at 01:57:48PM +0500, ???? ??????? wrote:
> Hello, Gil Bahat!
>
> can you help with troubleshooting?
>
> I created some basic cygwin CI:
>
> https://github.com/chipitsine/haproxy/blob/master/.travis.yml#L25-L30
>
> it fails with
>
> src/ev_poll.c:16:10: fatal error: poll.h: No such file or directory
>  #include <poll.h>
>           ^~~~~~~~
> compilation terminated.
> make: *** [Makefile:830: src/ev_poll.o] Error 1
>
> (full log: https://travis-ci.com/chipitsine/haproxy/builds/114061737 )
>
> do you know which package does "poll.h" belongs to ?

Interesting, maybe poll() should be disabled on cygwin and we'd only
keep select ? (just build with "USE_POLL=" for this).

I'll try that.

Actually, I think that I need to install some missing cygwin package
(I installed very few of them using "choco install bash make openssl-devel 
cygwin-devel --source cygwin")


Willy

Reply via email to