From 67b361a4c8ecf396ad18258198480775a0ab2698 Mon Sep 17 00:00:00 2001 From: "Stephen M. Coakley" Date: Sun, 7 Mar 2021 21:37:15 -0600 Subject: [PATCH] Fix TCP_NODELAY not defined for static builds on Unix (#381) * Fix TCP_NODELAY not defined for static builds on Unix The `TCP_NODELAY` macro/constant was not being defined during compilation for the bundled libcurl build on Unix systems because `netinet/tcp.h` was not being included. It is difficult to verify that this is working properly without a debugger or strace. I've confirmed this fix on Linux and macOS. Also rearrange some of the defines to help keep the build script somewhat organized. Fixes #379. * Linux-specific headers are unnecessary --- curl-sys/build.rs | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/curl-sys/build.rs b/curl-sys/build.rs index 7cf401fb6..64df41e99 100644 --- a/curl-sys/build.rs +++ b/curl-sys/build.rs @@ -238,11 +238,6 @@ fn main() { .file("curl/lib/vauth/vauth.c"); } - if !windows { - cfg.define("USE_UNIX_SOCKETS", None) - .define("HAVE_SYS_UN_H", None); - } - // Configure TLS backend. Since Cargo does not support mutually exclusive // features, make sure we only compile one vtls. if cfg!(feature = "mesalink") { @@ -288,6 +283,7 @@ fn main() { } } + // Configure platform-specific details. if windows { cfg.define("WIN32", None) .define("USE_THREADS_WIN32", None) @@ -301,15 +297,6 @@ fn main() { cfg.file("curl/lib/vauth/spnego_sspi.c"); } } else { - if target.contains("-apple-") { - cfg.define("__APPLE__", None) - .define("macintosh", None) - .define("HAVE_MACH_ABSOLUTE_TIME", None); - } else { - cfg.define("HAVE_CLOCK_GETTIME_MONOTONIC", None) - .define("HAVE_GETTIMEOFDAY", None); - } - cfg.define("RECV_TYPE_ARG1", "int") .define("HAVE_PTHREAD_H", None) .define("HAVE_ARPA_INET_H", None) @@ -317,6 +304,7 @@ fn main() { .define("HAVE_FCNTL_H", None) .define("HAVE_NETDB_H", None) .define("HAVE_NETINET_IN_H", None) + .define("HAVE_NETINET_TCP_H", None) .define("HAVE_POLL_FINE", None) .define("HAVE_POLL_H", None) .define("HAVE_FCNTL_O_NONBLOCK", None) @@ -330,7 +318,9 @@ fn main() { .define("HAVE_STERRROR_R", None) .define("HAVE_SOCKETPAIR", None) .define("HAVE_STRUCT_TIMEVAL", None) + .define("HAVE_SYS_UN_H", None) .define("USE_THREADS_POSIX", None) + .define("USE_UNIX_SOCKETS", None) .define("RECV_TYPE_ARG2", "void*") .define("RECV_TYPE_ARG3", "size_t") .define("RECV_TYPE_ARG4", "int") @@ -345,6 +335,15 @@ fn main() { .define("SIZEOF_INT", "4") .define("SIZEOF_SHORT", "2"); + if target.contains("-apple-") { + cfg.define("__APPLE__", None) + .define("macintosh", None) + .define("HAVE_MACH_ABSOLUTE_TIME", None); + } else { + cfg.define("HAVE_CLOCK_GETTIME_MONOTONIC", None) + .define("HAVE_GETTIMEOFDAY", None); + } + if cfg!(feature = "spnego") { cfg.define("HAVE_GSSAPI", None) .file("curl/lib/curl_gssapi.c")