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>
Sent: Monday, June 3, 2019 11:03 AM
To: Gil Bahat <bahat....@gmail.com>
Cc: Willy Tarreau <w...@1wt.eu>; HAProxy <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