From 33ee9cd810a6734b58843a70c240882f99590faa Mon Sep 17 00:00:00 2001 From: Taras Roshko Date: Wed, 4 Sep 2019 17:19:43 -0700 Subject: [PATCH] build: curl with c-ares, nghttp2 and zlib Build curl dependency with async DNS resolver c-ares avoiding potential crashes due to longjmp on modern kernels. Add zlib and nghttp2. Use Envoy's version of all of the above libraries. Signed-off-by: Taras Roshko --- bazel/foreign_cc/BUILD | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/bazel/foreign_cc/BUILD b/bazel/foreign_cc/BUILD index 1a96306c001b..588673187b08 100644 --- a/bazel/foreign_cc/BUILD +++ b/bazel/foreign_cc/BUILD @@ -64,24 +64,47 @@ envoy_cmake_external( envoy_cmake_external( name = "curl", + # Options from https://github.com/curl/curl/blob/master/CMakeLists.txt. cache_entries = { "BUILD_CURL_EXE": "off", - "BUILD_SHARED_LIBS": "off", - "CMAKE_BUILD_TYPE": "RelWithDebInfo", - "HTTP_ONLY": "on", "BUILD_TESTING": "off", - "CMAKE_USE_OPENSSL": "off", - "CURL_CA_PATH": "none", + "BUILD_SHARED_LIBS": "off", "CURL_HIDDEN_SYMBOLS": "off", "CMAKE_USE_LIBSSH2": "off", + "CURL_BROTLI": "off", + "CMAKE_USE_GSSAPI": "off", + "HTTP_ONLY": "on", + "CMAKE_BUILD_TYPE": "RelWithDebInfo", "CMAKE_INSTALL_LIBDIR": "lib", - "INCLUDE_DIRECTORIES": "include/curl", + # C-Ares. + "ENABLE_ARES": "on", + "CARES_LIBRARY": "$EXT_BUILD_DEPS/ares", + "CARES_INCLUDE_DIR": "$EXT_BUILD_DEPS/ares/include", + # SSL (via Envoy's SSL dependency) is disabled, curl's CMake uses FindOpenSSL.cmake which fails at what looks like + # version parsing (the libraries are found ok). + "CURL_CA_PATH": "none", + "CMAKE_USE_OPENSSL": "off", + "OPENSSL_ROOT_DIR": "$EXT_BUILD_DEPS", + # NGHTTP2. + "USE_NGHTTP2": "on", + "NGHTTP2_LIBRARY": "$EXT_BUILD_DEPS/nghttp2", + "NGHTTP2_INCLUDE_DIR": "$EXT_BUILD_DEPS/nghttp2/include", + # ZLIB. + "CURL_ZLIB": "on", + "ZLIB_LIBRARY": "$EXT_BUILD_DEPS/zlib", + "ZLIB_INCLUDE_DIR": "$EXT_BUILD_DEPS/zlib/include", }, lib_source = "@com_github_curl//:all", static_libraries = select({ "//bazel:windows_x86_64": ["curl.lib"], "//conditions:default": ["libcurl.a"], }), + deps = [ + ":ares", + ":nghttp2", + ":zlib", + "//external:ssl", + ], ) envoy_cmake_external(