Le 04/05/2017 à 07:14, Willy Tarreau a écrit : > Hi, > > On Wed, May 03, 2017 at 06:17:40AM +0000, Akhnin Nikita wrote: >> Greetings! >> >> I have a problem with compiling haproxy with lua support against Solaris 10. >> I'm using gcc v4.9 and making it with command (don't pay attention to the >> odd paths to the gcc and libraries): >> gmake CC=/pub/site/opt/bin/gcc TARGET=solaris USE_OPENSSL=1 >> SSL_INC=/pub/site/opt/include/openssl SSL_LIB=/pub/site/opt/lib USE_PCRE=1 >> PCREDIR=/pub/site/opt PREFIX=/pub/site/opt USE_PCRE_JIT=1 USE_STATIC_PCRE=1 >> USE_ZLIB=1 USE_LUA=1 ADDLIB="-R/pub/site/opt/lib" LUA_LIB=/pub/site/opt/lib >> LUA_INC=/pub/site/opt/include >> >> The error message is: >> >> /pub/site/opt/bin/gcc -Iinclude -Iebtree -Wall -O2 -g -fno-strict-aliasing >> -Wdeclaration-after-statement -fomit-frame-pointer -DFD_SETSIZE=65536 >> -D_REENTRANT -DTPROXY -DCONFIG_HAP_CRYPT -DNEED_CRYPT_H >> -DUSE_GETADDRINFO -DUSE_ZLIB -DENABLE_POLL -DUSE_OPENSSL >> -I/pub/site/opt/include/openssl -DUSE_LUA -DUSE_PCRE >> -I/pub/site/opt/include -DUSE_PCRE_JIT -DCONFIG_HAPROXY_VERSION=\"1.7.4\" >> -DCONFIG_HAPROXY_DATE=\"2017/03/27\" -c -o src/hlua_fcn.o src/hlua_fcn.c >> src/hlua_fcn.c: In function 'hlua_parse_date': >> src/hlua_fcn.c:290:2: warning: implicit declaration of function 'timegm' >> [-Wimplicit-function-declaration] >> time = timegm(&tm); >> ^ >> >> /pub/site/opt/bin/gcc -g -o haproxy src/haproxy.o src/base64.o >> src/protocol.o src/uri_auth.o src/standard.o src/buffer.o src/log.o >> src/task.o src/chunk.o src/channel.o src/listener.o src/lru.o src/xxhash.o >> src/time.o src/fd.o src/pipe.o src/regex.o src/cfgparse.o src/server.o >> src/checks.o src/queue.o src/frontend.o src/proxy.o src/peers.o src/arg.o >> src/stick_table.o src/proto_uxst.o src/connection.o src/proto_http.o >> src/raw_sock.o src/backend.o src/tcp_rules.o src/lb_chash.o src/lb_fwlc.o >> src/lb_fwrr.o src/lb_map.o src/lb_fas.o src/stream_interface.o src/stats.o >> src/proto_tcp.o src/applet.o src/session.o src/stream.o src/hdr_idx.o >> src/ev_select.o src/signal.o src/acl.o src/sample.o src/memory.o >> src/freq_ctr.o src/auth.o src/proto_udp.o src/compression.o src/payload.o >> src/hash.o src/pattern.o src/map.o src/namespace.o src/mailers.o src/dns.o >> src/vars.o src/filters.o src/flt_http_comp.o src/flt_trace.o src/flt_spoe.o >> src/cli.o src/ev_poll.o src/ssl_sock.o src/shctx.o src/hlua.o src/hlua_fcn.o >> ebtree/ebtree.o ebtree/eb32tree.o ebtree/eb64tree.o ebtree/ebmbtree.o >> ebtree/ebsttree.o ebtree/ebimtree.o ebtree/ebistree.o -lnsl -lsocket >> -lcrypt -lz -L/pub/site/opt/lib -lssl -lcrypto -Wl,--export-dynamic -llua >> -lm -L/pub/site/opt/lib -Wl,-Bstatic -lpcreposix -lpcre -Wl,-Bdynamic >> -R/pub/site/opt/lib >> src/hlua_fcn.o: In function `hlua_parse_date': >> /pub/home/appadm/temp/haproxy-1.7.4/src/hlua_fcn.c:290: undefined reference >> to `timegm' >> collect2: error: ld returned 1 exit status >> gmake: *** [haproxy] Error 1 >> >> According to >> http://stackoverflow.com/questions/40904201/alternative-to-timegm-on-solaris, >> there is no timegm function in Solaris, so I can't solve this without power >> of haproxy developers. >> >> Is there any way to make this code compatible with Solaris? > I had never heard about this function. Could you try with mktime() instead ? > It takes the same prototype. If anybody knows what the difference is between > the two, I'll appreciate any enlightment on this. The man pages are not clear > enough for me on the subject.
There are two ways to build a struct tm to break down the time in hour, minute, second and so on: calling localtime, which takes current timezone into account, or calling gmtime to build an UTC time. The reverse operation is done by calling mktime (which will give the original time_t only if the current timezone is the same as when localtime was called, since the timezone is not recorded in struct tm) in the former case or timegm in the latter. If you do the following operation : time_t => localtime() => struct tm => timegm() => time_t, your result will be shift by the timezone time offset (but without any DST applied). Technically, if you live in Great Britain, the operation will succeed during winter (but will offset the result by 1 hour during summer, since DST is applied here). Benoît --- L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast. https://www.avast.com/antivirus

