aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rwxr-xr-xRakefile2
-rw-r--r--binding.gyp18
-rw-r--r--build.yaml5
-rw-r--r--include/grpc/impl/codegen/port_platform.h2
-rw-r--r--package.json3
-rw-r--r--setup.py6
-rw-r--r--src/core/lib/iomgr/port.h1
-rw-r--r--src/core/lib/support/cpu_linux.c8
-rw-r--r--src/core/lib/support/wrap_memcpy.c4
-rw-r--r--templates/binding.gyp.template22
-rw-r--r--templates/package.json.template3
-rw-r--r--third_party/cares/ares_build.h10
-rwxr-xr-xtools/run_tests/artifacts/build_artifact_node.sh2
14 files changed, 61 insertions, 29 deletions
diff --git a/Makefile b/Makefile
index dd35d8c435..4580d50a2f 100644
--- a/Makefile
+++ b/Makefile
@@ -8272,8 +8272,8 @@ PUBLIC_HEADERS_C += \
LIBARES_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBARES_SRC))))
-$(LIBARES_OBJS): CPPFLAGS += -Ithird_party/cares -Ithird_party/cares/cares $(if $(subst Linux,,$(SYSTEM)),,-Ithird_party/cares/config_linux) $(if $(subst Darwin,,$(SYSTEM)),,-Ithird_party/cares/config_darwin) -fvisibility=hidden -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX -DHAVE_CONFIG_H
-$(LIBARES_OBJS): CFLAGS += -Wno-sign-conversion -Wno-invalid-source-encoding
+$(LIBARES_OBJS): CPPFLAGS += -Ithird_party/cares -Ithird_party/cares/cares $(if $(subst Linux,,$(SYSTEM)),,-Ithird_party/cares/config_linux) $(if $(subst Darwin,,$(SYSTEM)),,-Ithird_party/cares/config_darwin) -fvisibility=hidden -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX $(if $(subst MINGW32,,$(SYSTEM)),-DHAVE_CONFIG_H,)
+$(LIBARES_OBJS): CFLAGS += -Wno-sign-conversion $(if $(subst MINGW32,,$(SYSTEM)),-Wno-invalid-source-encoding,)
$(LIBDIR)/$(CONFIG)/libares.a: $(ZLIB_DEP) $(LIBARES_OBJS)
$(E) "[AR] Creating $@"
diff --git a/Rakefile b/Rakefile
index cc02aa130a..7f8d3a2f4a 100755
--- a/Rakefile
+++ b/Rakefile
@@ -80,7 +80,7 @@ task 'dlls' do
grpc_config = ENV['GRPC_CONFIG'] || 'opt'
verbose = ENV['V'] || '0'
- env = 'CPPFLAGS="-D_WIN32_WINNT=0x600 -DUNICODE -D_UNICODE -Wno-unused-variable -Wno-unused-result" '
+ env = 'CPPFLAGS="-D_WIN32_WINNT=0x600 -DUNICODE -D_UNICODE -Wno-unused-variable -Wno-unused-result -DCARES_STATICLIB" '
env += 'LDFLAGS=-static '
env += 'SYSTEM=MINGW32 '
env += 'EMBED_ZLIB=true '
diff --git a/binding.gyp b/binding.gyp
index 582c61282f..1032dafe01 100644
--- a/binding.gyp
+++ b/binding.gyp
@@ -47,7 +47,11 @@
# will let users recompile gRPC to work without ALPN.
'grpc_alpn%': 'true',
# Indicates that the library should be built with gcov.
- 'grpc_gcov%': 'false'
+ 'grpc_gcov%': 'false',
+ # Indicates that the library should be built with compatibility for musl
+ # libc, so that it can run on Alpine Linux. This is only necessary if not
+ # building on Alpine Linux
+ 'grpc_alpine%': 'false'
},
'target_defaults': {
'configurations': {
@@ -115,6 +119,11 @@
'-rdynamic',
],
}],
+ ['grpc_alpine=="true"', {
+ 'defines': [
+ 'GPR_MUSL_LIBC_COMPAT'
+ ]
+ }],
['OS!="win" and runtime=="electron"', {
"defines": [
'OPENSSL_NO_THREADS'
@@ -535,6 +544,10 @@
}
]
},
+ ]
+ }],
+ ['OS == "win"', {
+ 'targets': [
# Only want to compile zlib under Windows
{
'cflags': [
@@ -569,7 +582,6 @@
}]
],
'targets': [
-
{
'cflags': [
'-std=c99',
@@ -648,7 +660,6 @@
'type': 'static_library',
'dependencies': [
'gpr',
- 'node_modules/cares/deps/cares/cares.gyp:cares',
],
'sources': [
'src/core/lib/surface/init.c',
@@ -953,7 +964,6 @@
"dependencies": [
"grpc",
"gpr",
- "node_modules/cares/deps/cares/cares.gyp:cares",
]
},
{
diff --git a/build.yaml b/build.yaml
index 7b60612742..4b5d773181 100644
--- a/build.yaml
+++ b/build.yaml
@@ -4498,10 +4498,11 @@ configs:
UBSAN_OPTIONS: halt_on_error=1:print_stacktrace=1:suppressions=tools/ubsan_suppressions.txt
defaults:
ares:
- CFLAGS: -Wno-sign-conversion -Wno-invalid-source-encoding
+ CFLAGS: -Wno-sign-conversion $(if $(subst MINGW32,,$(SYSTEM)),-Wno-invalid-source-encoding,)
CPPFLAGS: -Ithird_party/cares -Ithird_party/cares/cares $(if $(subst Linux,,$(SYSTEM)),,-Ithird_party/cares/config_linux)
$(if $(subst Darwin,,$(SYSTEM)),,-Ithird_party/cares/config_darwin) -fvisibility=hidden
- -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX -DHAVE_CONFIG_H
+ -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX $(if $(subst
+ MINGW32,,$(SYSTEM)),-DHAVE_CONFIG_H,)
benchmark:
CPPFLAGS: -Ithird_party/benchmark/include -DHAVE_POSIX_REGEX
boringssl:
diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h
index e12f6f4e99..14e348fadb 100644
--- a/include/grpc/impl/codegen/port_platform.h
+++ b/include/grpc/impl/codegen/port_platform.h
@@ -189,7 +189,7 @@
#ifdef __GLIBC__
#define GPR_POSIX_CRASH_HANDLER 1
#else /* musl libc */
-#define GRPC_MSG_IOVLEN_TYPE int
+#define GPR_MUSL_LIBC_COMPAT 1
#endif
#elif defined(__APPLE__)
#include <Availability.h>
diff --git a/package.json b/package.json
index 6a01ae2324..e1499a089c 100644
--- a/package.json
+++ b/package.json
@@ -34,8 +34,7 @@
"lodash": "^4.15.0",
"nan": "^2.0.0",
"node-pre-gyp": "^0.6.0",
- "protobufjs": "^6.7.0",
- "cares": "^1.1.5"
+ "protobufjs": "^6.7.0"
},
"devDependencies": {
"async": "^2.0.1",
diff --git a/setup.py b/setup.py
index 4cbd1a45a9..18ba802fb0 100644
--- a/setup.py
+++ b/setup.py
@@ -144,6 +144,8 @@ CYTHON_EXTENSION_MODULE_NAMES = ('grpc._cython.cygrpc',)
CYTHON_HELPER_C_FILES = ()
CORE_C_FILES = tuple(grpc_core_dependencies.CORE_SOURCE_FILES)
+if "win32" in sys.platform and "64bit" in platform.architecture()[0]:
+ CORE_C_FILES = filter(lambda x: 'third_party/cares' not in x, CORE_C_FILES)
EXTENSION_INCLUDE_DIRECTORIES = (
(PYTHON_STEM,) + CORE_INCLUDE + BORINGSSL_INCLUDE + ZLIB_INCLUDE +
@@ -163,7 +165,9 @@ DEFINE_MACROS = (
if "win32" in sys.platform:
DEFINE_MACROS += (('WIN32_LEAN_AND_MEAN', 1), ('CARES_STATICLIB', 1),)
if '64bit' in platform.architecture()[0]:
- DEFINE_MACROS += (('MS_WIN64', 1),)
+ # TODO(zyc): Re-enble c-ares on x64 windows after fixing the
+ # ares_library_init compilation issue
+ DEFINE_MACROS += (('MS_WIN64', 1), ('GRPC_ARES', 0),)
elif sys.version_info >= (3, 5):
# For some reason, this is needed to get access to inet_pton/inet_ntop
# on msvc, but only for 32 bits
diff --git a/src/core/lib/iomgr/port.h b/src/core/lib/iomgr/port.h
index 269dc35003..2a553f4114 100644
--- a/src/core/lib/iomgr/port.h
+++ b/src/core/lib/iomgr/port.h
@@ -88,6 +88,7 @@
#ifndef __GLIBC__
#define GRPC_LINUX_EPOLL 1
#define GRPC_LINUX_EVENTFD 1
+#define GRPC_MSG_IOVLEN_TYPE int
#endif
#ifndef GRPC_LINUX_EVENTFD
#define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1
diff --git a/src/core/lib/support/cpu_linux.c b/src/core/lib/support/cpu_linux.c
index 1e50f59823..b826dde160 100644
--- a/src/core/lib/support/cpu_linux.c
+++ b/src/core/lib/support/cpu_linux.c
@@ -67,16 +67,16 @@ unsigned gpr_cpu_num_cores(void) {
}
unsigned gpr_cpu_current_cpu(void) {
-#ifdef __GLIBC__
+#ifdef GPR_MUSL_LIBC_COMPAT
+ // sched_getcpu() is undefined on musl
+ return 0;
+#else
int cpu = sched_getcpu();
if (cpu < 0) {
gpr_log(GPR_ERROR, "Error determining current CPU: %s\n", strerror(errno));
return 0;
}
return (unsigned)cpu;
-#else
- // sched_getcpu() is undefined on musl
- return 0;
#endif
}
diff --git a/src/core/lib/support/wrap_memcpy.c b/src/core/lib/support/wrap_memcpy.c
index 050cc6db5e..deb8d6b198 100644
--- a/src/core/lib/support/wrap_memcpy.c
+++ b/src/core/lib/support/wrap_memcpy.c
@@ -31,6 +31,8 @@
*
*/
+#include <grpc/support/port_platform.h>
+
#include <string.h>
/* Provide a wrapped memcpy for targets that need to be backwards
@@ -40,7 +42,7 @@
*/
#ifdef __linux__
-#if defined(__x86_64__) && defined(__GNU_LIBRARY__)
+#if defined(__x86_64__) && !defined(GPR_MUSL_LIBC_COMPAT)
__asm__(".symver memcpy,memcpy@GLIBC_2.2.5");
void *__wrap_memcpy(void *destination, const void *source, size_t num) {
return memcpy(destination, source, num);
diff --git a/templates/binding.gyp.template b/templates/binding.gyp.template
index a2e8c58892..bbd62c5512 100644
--- a/templates/binding.gyp.template
+++ b/templates/binding.gyp.template
@@ -49,7 +49,11 @@
# will let users recompile gRPC to work without ALPN.
'grpc_alpn%': 'true',
# Indicates that the library should be built with gcov.
- 'grpc_gcov%': 'false'
+ 'grpc_gcov%': 'false',
+ # Indicates that the library should be built with compatibility for musl
+ # libc, so that it can run on Alpine Linux. This is only necessary if not
+ # building on Alpine Linux
+ 'grpc_alpine%': 'false'
},
'target_defaults': {
'configurations': {
@@ -105,6 +109,11 @@
% endif
% endfor
}],
+ ['grpc_alpine=="true"', {
+ 'defines': [
+ 'GPR_MUSL_LIBC_COMPAT'
+ ]
+ }],
['OS!="win" and runtime=="electron"', {
"defines": [
'OPENSSL_NO_THREADS'
@@ -233,6 +242,10 @@
}
]
},
+ ]
+ }],
+ ['OS == "win"', {
+ 'targets': [
# Only want to compile zlib under Windows
% for module in node_modules:
% for lib in libs:
@@ -264,13 +277,6 @@
}]
],
'targets': [
- <%
- for lib in libs:
- if 'grpc' in lib.transitive_deps or lib.name == 'grpc':
- lib.deps.append('node_modules/cares/deps/cares/cares.gyp:cares')
- for module in node_modules:
- module.deps.append('node_modules/cares/deps/cares/cares.gyp:cares')
- %>
% for module in node_modules:
% for lib in libs:
% if lib.name in module.transitive_deps and lib.name not in ('boringssl', 'z'):
diff --git a/templates/package.json.template b/templates/package.json.template
index b69fd28d2a..3bae8fde43 100644
--- a/templates/package.json.template
+++ b/templates/package.json.template
@@ -36,8 +36,7 @@
"lodash": "^4.15.0",
"nan": "^2.0.0",
"node-pre-gyp": "^0.6.0",
- "protobufjs": "^6.7.0",
- "cares": "^1.1.5"
+ "protobufjs": "^6.7.0"
},
"devDependencies": {
"async": "^2.0.1",
diff --git a/third_party/cares/ares_build.h b/third_party/cares/ares_build.h
index 7d69f1e6ae..d6b3d49f37 100644
--- a/third_party/cares/ares_build.h
+++ b/third_party/cares/ares_build.h
@@ -251,4 +251,14 @@
typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t;
#endif
+/* Undefine UNICODE, as c-ares does not use the ANSI version of functions */
+/* explicitly. */
+#ifdef UNICODE
+# undef UNICODE
+#endif
+
+#ifdef _UNICODE
+# undef _UNICODE
+#endif
+
#endif /* __CARES_BUILD_H */
diff --git a/tools/run_tests/artifacts/build_artifact_node.sh b/tools/run_tests/artifacts/build_artifact_node.sh
index 2da2ac5f91..7a747551e8 100755
--- a/tools/run_tests/artifacts/build_artifact_node.sh
+++ b/tools/run_tests/artifacts/build_artifact_node.sh
@@ -48,7 +48,7 @@ electron_versions=( 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 )
for version in ${node_versions[@]}
do
- ./node_modules/.bin/node-pre-gyp configure rebuild package testpackage --target=$version --target_arch=$NODE_TARGET_ARCH
+ ./node_modules/.bin/node-pre-gyp configure rebuild package testpackage --target=$version --target_arch=$NODE_TARGET_ARCH --grpc_alpine=true
cp -r build/stage/* artifacts/
done