microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
23.22k stars 6.4k forks source link

[c-ares] Build error (1.33.0) #40387

Open cd606 opened 3 months ago

cd606 commented 3 months ago

Hello, my c-ares (1.33.0) build (x64-linux, Centos 7, gcc 11) failed with the following error message, could somebody help look into this? Thanks!

/opt/rh/devtoolset-11/root/usr/bin/cc -DCARES_BUILDING_LIBRARY -DHAVE_CONFIG_H=1 -D_GNU_SOURCE -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -I$HOME/vcpkg/buildtrees/c-ares/x64-linux-dbg -I$HOME/vcpkg/buildtrees/c-ares/src/v1.33.0-7b5315fac5.clean -I$HOME/vcpkg/buildtrees/c-ares/src/v1.33.0-7b5315fac5.clean/include -I$HOME/vcpkg/buildtrees/c-ares/src/v1.33.0-7b5315fac5.clean/src/lib -fPIC -Wall -Wextra -Waggregate-return -Wcast-align -Wcast-qual -Wconversion -Wdeclaration-after-statement -Wdouble-promotion -Wfloat-equal -Wformat-security -Winit-self -Wjump-misses-init -Wlogical-op -Wmissing-braces -Wmissing-declarations -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-prototypes -Wnested-externs -Wno-coverage-mismatch -Wold-style-definition -Wpacked -Wpedantic -Wpointer-arith -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow -Wstrict-prototypes -Wtrampolines -Wundef -Wunreachable-code -Wunused -Wvariadic-macros -Wvla -Wwrite-strings -Wimplicit-fallthrough=3 -Werror=implicit-int -Werror=implicit-function-declaration -Wno-long-long -fdiagnostics-color=always -g -fno-omit-frame-pointer -O0 -std=gnu90 -MD -MT src/lib/CMakeFiles/c-ares.dir/aressocket.c.o -MF src/lib/CMakeFiles/c-ares.dir/aressocket.c.o.d -o src/lib/CMakeFiles/c-ares.dir/aressocket.c.o -c $HOME/vcpkg/buildtrees/c-ares/src/v1.33.0-7b5315fac5.clean/src/lib/aressocket.c $HOME/vcpkg/buildtrees/c-ares/src/v1.33.0-7b5315fac5.clean/src/lib/aressocket.c: In function ‘configure_socket’: $HOME/vcpkg/buildtrees/c-ares/src/v1.33.0-7b5315fac5.clean/src/lib/aressocket.c:64:30: error: ‘TCP_FASTOPEN_CONNECT’ undeclared (first use in this function) 64 | # define TFO_CLIENT_SOCKOPT TCP_FASTOPEN_CONNECT | ^~~~~~~~ $HOME/vcpkg/buildtrees/c-ares/src/v1.33.0-7b5315fac5.clean/src/lib/aressocket.c:456:43: note: in expansion of macro ‘TFO_CLIENT_SOCKOPT’ 456 | setsockopt(conn->fd, IPPROTO_TCP, TFO_CLIENT_SOCKOPT, (void *)&opt, | ^~~~~~ $HOME/vcpkg/buildtrees/c-ares/src/v1.33.0-7b5315fac5.clean/src/lib/aressocket.c:64:30: note: each undeclared identifier is reported only once for each function it appears in 64 | # define TFO_CLIENT_SOCKOPT TCP_FASTOPEN_CONNECT | ^~~~~~~~ $HOME/vcpkg/buildtrees/c-ares/src/v1.33.0-7b5315fac5.clean/src/lib/ares__socket.c:456:43: note: in expansion of macro ‘TFO_CLIENT_SOCKOPT’ 456 | setsockopt(conn->fd, IPPROTO_TCP, TFO_CLIENT_SOCKOPT, (void *)&opt,

greenozon commented 3 months ago

Looks like your CentOS is too old and does not have support for TCP_FASTOPEN_CONNECT

I"ve tried on Ubuntu 20.04 LTS and it was successfully built:

./vcpkg install c-ares
Computing installation plan...
The following packages will be built and installed:
    c-ares:x64-linux@1.33.0
Detecting compiler hash for triplet x64-linux...
Compiler found: /bin/c++
Restored 0 package(s) from /home/usr/.cache/vcpkg/archives in 190 us. Use --debug to see more details.
Installing 1/1 [c-ares:x64-linux@1.33.0.](mailto:c-ares%3Ax64-linux@1.33.0.)..
Building [c-ares:x64-linux@1.33.0.](mailto:c-ares%3Ax64-linux@1.33.0.)..
-- Downloading [https://github.com/c-ares/c-ares/archive/v1.33.0.tar.gz](https://www.google.com/url?q=https://github.com/c-ares/c-ares/archive/v1.33.0.tar.gz&sa=D&source=calendar&usd=2&usg=AOvVaw0ubiGUrgoNRy0DmP6UcYY_) -> c-ares-c-ares-v1.33.0.tar.gz...
-- Extracting source /home/usr/vcpkg/downloads/c-ares-c-ares-v1.33.0.tar.gz
-- Applying patch avoid-docs.patch
-- Using source at /home/usr/vcpkg/buildtrees/c-ares/src/v1.33.0-7b5315fac5.clean
-- Configuring x64-linux
-- Building x64-linux-dbg
-- Building x64-linux-rel
-- Fixing pkgconfig file: /home/usr/vcpkg/packages/c-ares_x64-linux/lib/pkgconfig/libcares.pc
-- Fixing pkgconfig file: /home/usr/vcpkg/packages/c-ares_x64-linux/debug/lib/pkgconfig/libcares.pc
-- Installing: /home/usr/vcpkg/packages/c-ares_x64-linux/share/c-ares/usage
-- Installing: /home/usr/vcpkg/packages/c-ares_x64-linux/share/c-ares/copyright
-- Performing post-build validation
Stored binaries in 1 destinations in 141 ms.
Elapsed time to handle c-ares:x64-linux: 18 s
c-ares:x64-linux package ABI: 9ac860c537a79eb946214c4aaccdb1bc2be534cff43b36c1b0a9a9984f31c642
Total install time: 18 s
c-ares provides CMake targets:

  find_package(c-ares CONFIG REQUIRED)
  target_link_libraries(main PRIVATE c-ares::cares)

as a more advanced option - you could try to add missed fucntionality, eg:

https://git.centos.org/rpms/iproute/c/99be8fbcce3c2415d08028a4716229389aca3e3d.patch

cd606 commented 3 months ago

Hello, I have updated my CentOS 7 but this build failure persists. This is preventing me from using other packages dependent upon c-ares (such as grpc). Is there a way I can fallback to the c-ares and grpc versions before this upgrade? Thanks.

greenozon commented 3 months ago

make sure that your updated CentOS7 knows about this feature - TCP_FASTOPEN_CONNECT

what Linux Kernel version do you have?

TCP Fast Open, or TFO for short, is an extension to the TCP protocol that allow a small amount of data to be sent alongside the initial SYN packet, when a TCP connection is being established. This can save round-trips and reduce response time in certain cases.
cd606 commented 3 months ago

The kernel version is 3.10.0-1160.66.1.el7.x86_64, thanks

greenozon commented 3 months ago

The TCP_FASTOPEN_CONNECT socket option was added in Linux kernel version 4.11, which was released in 2017

Regarding its inclusion in CentOS, TCP_FASTOPEN_CONNECT would be available in CentOS versions that include or are based on kernel 4.11 or later. CentOS 7, as you just shown, typically uses an older kernel by default, but you can install a newer kernel from the CentOS Plus repository or use a custom kernel to get this feature. CentOS 8 and later versions are more likely to include this feature by default, as they are based on newer kernels.

PS CentOS 8 includes support for TCP_FASTOPEN_CONNECT by default.

cd606 commented 3 months ago

Thanks, I understand CentOS 7 is an old system, but before I go ahead and upgrade to CentOS 8, is there a way to fallback to older versions of c-ares and grpc? Thanks.

dg0yt commented 3 months ago

@cd606 You can pin port version in manifest mode. In classic mode, you might copy the port directory from an earlier revision, and use that as an overlay port.

And you might check with upstream if it is a known issue, or an issue they would be interested in fixing.

guenterberner commented 2 months ago

@cd606 I encountered the same problem (c-ares 1.33.0 fails to build on an old SLES12 due to missing support for TCP_FASTOPEN_CONNECT). It seems that the people at c-ares added a fix for exactly this problem in version 1.33.1. It would be nice if this version could be included in vcpkg as soon as possible. (see https://c-ares.org/changelog.html)

dg0yt commented 2 months ago

Cf. https://github.com/microsoft/vcpkg/pull/40646