aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--binding.gyp11
-rw-r--r--include/grpc/impl/codegen/port_platform.h2
-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.template11
-rwxr-xr-xtools/run_tests/artifacts/build_artifact_node.sh2
7 files changed, 30 insertions, 9 deletions
diff --git a/binding.gyp b/binding.gyp
index 9794c87343..e3b2a925a3 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'
diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h
index 813e08b86e..a149279b72 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/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 c08c100fd5..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'
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