Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FreeBSD] Build failure whenever --enable-sessioncache specified (not related to missing ebtree) #297

Closed
zi0r opened this issue Feb 12, 2019 · 9 comments

Comments

@zi0r
Copy link
Contributor

zi0r commented Feb 12, 2019

The compiler is unhappy with the abs() calls in hitch.c:464. Additionally, the multicast code at hitch.c:584 is referencing ifr_ifindex, which doesn't appear to exist under FreeBSD.

Build log:

=======================<phase: build >============================ ===> Building for hitch-1.5.0_1 /usr/bin/make all-recursive Making all in src/util cc -DHAVE_CONFIG_H -I. -I../.. -I/usr/local/include -O2 -g -Wall -W -I/usr/include -O2 -pipe -fstack-protector -fno-strict-aliasing -MT parse_proxy_v2-parse_proxy_v2.o -MD -MP -MF .deps/parse_proxy_v2-parse_proxy_v2.Tpo -c -o parse_proxy_v2-parse_proxy_v2.o test -f 'parse_proxy_v2.c' || echo './'parse_proxy_v2.c mv -f .deps/parse_proxy_v2-parse_proxy_v2.Tpo .deps/parse_proxy_v2-parse_proxy_v2.Po cc -O2 -g -Wall -W -I/usr/include -O2 -pipe -fstack-protector -fno-strict-aliasing -L/usr/local/lib -lcrypto -lssl -fstack-protector -o parse_proxy_v2 parse_proxy_v2-parse_proxy_v2.o Making all in src /usr/bin/make all-am cc -DHAVE_CONFIG_H -I. -I.. -I/usr/local/include -O2 -g -Wall -W -I/usr/include -O2 -pipe -fstack-protector -fno-strict-aliasing -MT libcfg_a-cfg_lex.o -MD -MP -MF .deps/libcfg_a-cfg_lex.Tpo -c -o libcfg_a-cfg_lex.o test -f 'cfg_lex.c' || echo './'cfg_lex.c cfg_lex.c:1718:3: warning: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Wsign-compare] YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cfg_lex.c:910:18: note: expanded from macro 'YY_INPUT' for ( n = 0; n < max_size && \ ~ ^ ~~~~~~~~ 1 warning generated. mv -f .deps/libcfg_a-cfg_lex.Tpo .deps/libcfg_a-cfg_lex.Po cc -DHAVE_CONFIG_H -I. -I.. -I/usr/local/include -O2 -g -Wall -W -I/usr/include -O2 -pipe -fstack-protector -fno-strict-aliasing -MT libcfg_a-cfg_parser.o -MD -MP -MF .deps/libcfg_a-cfg_parser.Tpo -c -o libcfg_a-cfg_parser.o test -f 'cfg_parser.c' || echo './'cfg_parser.c mv -f .deps/libcfg_a-cfg_parser.Tpo .deps/libcfg_a-cfg_parser.Po rm -f libcfg.a ar cru libcfg.a libcfg_a-cfg_lex.o libcfg_a-cfg_parser.o ranlib libcfg.a depbase=echo foreign/flopen.o | sed 's|[^/]$|.deps/&|;s|.o$||'; cc -DHAVE_CONFIG_H -I. -I.. -I/usr/local/include -O2 -g -Wall -W -O2 -pipe -fstack-protector -fno-strict-aliasing -MT foreign/flopen.o -MD -MP -MF $depbase.Tpo -c -o foreign/flopen.o foreign/flopen.c && mv -f $depbase.Tpo $depbase.Po depbase=echo foreign/vas.o | sed 's|[^/]$|.deps/&amp;|;s|.o$||'; cc -DHAVE_CONFIG_H -I. -I.. -I/usr/local/include -O2 -g -Wall -W -O2 -pipe -fstack-protector -fno-strict-aliasing -MT foreign/vas.o -MD -MP -MF $depbase.Tpo -c -o foreign/vas.o foreign/vas.c && mv -f $depbase.Tpo $depbase.Po depbase=echo foreign/vpf.o | sed 's|[^/]$|.deps/&|;s|.o$||'; cc -DHAVE_CONFIG_H -I. -I.. -I/usr/local/include -O2 -g -Wall -W -O2 -pipe -fstack-protector -fno-strict-aliasing -MT foreign/vpf.o -MD -MP -MF $depbase.Tpo -c -o foreign/vpf.o foreign/vpf.c && mv -f $depbase.Tpo $depbase.Po depbase=echo foreign/vsb.o | sed 's|[^/]$|.deps/&amp;|;s|.o$||'; cc -DHAVE_CONFIG_H -I. -I.. -I/usr/local/include -O2 -g -Wall -W -O2 -pipe -fstack-protector -fno-strict-aliasing -MT foreign/vsb.o -MD -MP -MF $depbase.Tpo -c -o foreign/vsb.o foreign/vsb.c && mv -f $depbase.Tpo $depbase.Po depbase=echo foreign/vsa.o | sed 's|[^/]*$|.deps/&|;s|.o$||'; cc -DHAVE_CONFIG_H -I. -I.. -I/usr/local/include -O2 -g -Wall -W -O2 -pipe -fstack-protector -fno-strict-aliasing -MT foreign/vsa.o -MD -MP -MF $depbase.Tpo -c -o foreign/vsa.o foreign/vsa.c && mv -f $depbase.Tpo $depbase.Po rm -f libforeign.a ar cru libforeign.a foreign/flopen.o foreign/vas.o foreign/vpf.o foreign/vsb.o foreign/vsa.o ranlib libforeign.a cc -DHAVE_CONFIG_H -I. -I.. -I/usr/local/include -O2 -g -Wall -W -I/usr/include -I/usr/include -I/usr/local/include -fno-strict-aliasing -Werror -DUSE_SYSCALL_FUTEX -Iebtree -O2 -pipe -fstack-protector -fno-strict-aliasing -MT hitch-asn_gentm.o -MD -MP -MF .deps/hitch-asn_gentm.Tpo -c -o hitch-asn_gentm.o test -f 'asn_gentm.c' || echo './'asn_gentm.c mv -f .deps/hitch-asn_gentm.Tpo .deps/hitch-asn_gentm.Po cc -DHAVE_CONFIG_H -I. -I.. -I/usr/local/include -O2 -g -Wall -W -I/usr/include -I/usr/include -I/usr/local/include -fno-strict-aliasing -Werror -DUSE_SYSCALL_FUTEX -Iebtree -O2 -pipe -fstack-protector -fno-strict-aliasing -MT hitch-configuration.o -MD -MP -MF .deps/hitch-configuration.Tpo -c -o hitch-configuration.o test -f 'configuration.c' || echo './'configuration.c mv -f .deps/hitch-configuration.Tpo .deps/hitch-configuration.Po cc -DHAVE_CONFIG_H -I. -I.. -I/usr/local/include -O2 -g -Wall -W -I/usr/include -I/usr/include -I/usr/local/include -fno-strict-aliasing -Werror -DUSE_SYSCALL_FUTEX -Iebtree -O2 -pipe -fstack-protector -fno-strict-aliasing -MT hitch-hitch.o -MD -MP -MF .deps/hitch-hitch.Tpo -c -o hitch-hitch.o test -f 'hitch.c' || echo './'`hitch.c
hitch.c:464:9: error: taking the absolute value of unsigned type 'unsigned int' has no effect [-Werror,-Wabsolute-value]
if (!(abs((int)(int32_t)now - ntohl(encdate))
^
hitch.c:464:9: note: remove the call to 'abs' since unsigned values cannot be negative
if (!(abs((int)(int32_t)now - ntohl(encdate))
^~~
hitch.c:584:29: error: no member named 'ifr_ifindex' in 'struct ifreq'
mreqn.imr_ifindex = ifr.ifr_ifindex;
~~~ ^
2 errors generated.
*** Error code 1

Stop.
make[4]: stopped in /wrkdirs/usr/ports/security/hitch/work/hitch-1.5.0/src
*** Error code 1

Stop.
make[3]: stopped in /wrkdirs/usr/ports/security/hitch/work/hitch-1.5.0/src
*** Error code 1

Stop.
make[2]: stopped in /wrkdirs/usr/ports/security/hitch/work/hitch-1.5.0
*** Error code 1

Stop.
make[1]: stopped in /wrkdirs/usr/ports/security/hitch/work/hitch-1.5.0
*** Error code 1

Stop.
make: stopped in /usr/ports/security/hitch`

@zi0r
Copy link
Contributor Author

zi0r commented Feb 13, 2019

Fix for the above has been added in PR #298. However, there's a new issue with the session cache code under FreeBSD, as it is trying to include a linux header for futex support:

shctx.c:12:10: fatal error: 'linux/futex.h' file not found #include <linux/futex.h> ^~~~~~~~~~~~~~~ 1 error generated. *** Error code 1

This is because we unconditionally define USE_SYSCALL_FUTEX in Makefile.am/Makefile.in whenever enabling session cache. A proper fix would be to add autoconf magic to detect it. We must also conditionally link against pthread with USE_SYSCALL_FUTEX disabled.

@zi0r
Copy link
Contributor Author

zi0r commented Feb 13, 2019

You'll also need to add:
-Wno-address-of-packed-member
to the CFLAGS when building ebtree. This was the solution that haproxy adopted.

With the above changes, I was able to get a successful build of hitch with --enable-sessioncache.

@zi0r zi0r changed the title [FreeBSD] Build failure whenever --enable-sessioncache specified (not related to ebtree) [FreeBSD] Build failure whenever --enable-sessioncache specified (not related to missing ebtree) Feb 13, 2019
@l0stman
Copy link
Contributor

l0stman commented Feb 18, 2019

Hi zi0r,

I've encountered the same problem a couple of months back. I tried to
add support for `session cache' to the FreeBSD port. I got it working
by applying basically the same set of patches. But I got distracted
and never submitted them.

I agree with the need to add an option to the config file, something
like --with-pthread-mutex. And USE_SYSCALL_FUTEX would only be
defined depending on its value. Note also that the futex-based lock
would only work on intel architecture, even on Linux.

Of course, the latter could also be implemented under FreeBSD using
_umtx_op. But I'm not familiar enough with it to know if some edge
cases should be considered.

@dridi
Copy link
Member

dridi commented Feb 19, 2019

I tracked this down to a07b7b6, this existed before we forked hitch off stud.

dridi added a commit that referenced this issue Feb 19, 2019
The abs() function may not be needed, and the !reverse condition is
really hard to follow. Bonus point, the way the if statement is broken
doesn't comply with our code style (it came from stud).

Refs #297
Refs #298
dridi pushed a commit that referenced this issue Feb 19, 2019
dridi added a commit that referenced this issue Feb 19, 2019
dridi added a commit that referenced this issue Feb 19, 2019
@dridi
Copy link
Member

dridi commented Feb 19, 2019

The master branch should work now, please close if that's the case for you too or keep yelling at us!

I only tried FreeBSD.

@zi0r
Copy link
Contributor Author

zi0r commented Feb 22, 2019

I needed to add -lpthread to LDDFLAGS (though this could be because auto* stuff wasn't regenerated).

The other odd thing was that I also needed to:
cd hitch-1.5.0/src/ebtree && gmake

before starting the actual build. Otherwise, I got this error:

gmake[4]: *** No rule to make target 'ebtree/libebtree.a', needed by 'hitch'. Stop.
gmake[4]: Leaving directory '/wrkdirs/usr/ports/security/hitch/work/hitch-1.5.0/src'
gmake[3]: *** [Makefile:600: all] Error 2
gmake[3]: Leaving directory '/wrkdirs/usr/ports/security/hitch/work/hitch-1.5.0/src'
gmake[2]: *** [Makefile:527: all-recursive] Error 1
gmake[2]: Leaving directory '/wrkdirs/usr/ports/security/hitch/work/hitch-1.5.0'
gmake[1]: *** [Makefile:361: all] Error 2
gmake[1]: Leaving directory '/wrkdirs/usr/ports/security/hitch/work/hitch-1.5.0'

Otherwise, I've got a successful build. Will try testing today. Thanks!

@dridi
Copy link
Member

dridi commented Feb 22, 2019

Strange, I didn't have any of those problems on FreeBSD, can you please try building again but this time from either a clean checkout, or from a make dist archive?

@zi0r
Copy link
Contributor Author

zi0r commented Feb 22, 2019

Will check it out--I had tried using 1.5.0 with the couple of patches applied on top of it.

@hermunn
Copy link
Contributor

hermunn commented Mar 11, 2019

Any news here? Since it has been more than two weeks I will close this ticket. Please reopen if you are still experiencing problems.

@hermunn hermunn closed this as completed Mar 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants