Skip to content

Commit

Permalink
Fix TCP_NODELAY not defined for static builds on Unix
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sagebind committed Mar 6, 2021
1 parent 205117b commit 298c9f9
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions curl-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down Expand Up @@ -288,6 +283,7 @@ fn main() {
}
}

// Configure platform-specific details.
if windows {
cfg.define("WIN32", None)
.define("USE_THREADS_WIN32", None)
Expand All @@ -301,22 +297,14 @@ 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)
.define("HAVE_ERRNO_H", None)
.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)
Expand All @@ -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")
Expand All @@ -345,6 +335,19 @@ 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 target.contains("-linux-") {
cfg.define("HAVE_LINUX_TCP_H", None);
}

if cfg!(feature = "spnego") {
cfg.define("HAVE_GSSAPI", None)
.file("curl/lib/curl_gssapi.c")
Expand Down

0 comments on commit 298c9f9

Please sign in to comment.