package/grpc: fix build with uclibc on x86_64
PATCH v2 1/1 package/grpc: fix build with uclibc on x86_64
On x86_64 if GPR_MUSL_LIBC_COMPAT is not set, grpc tries to link with memcpy at GLIBC_2.2.5, see:
https://github.com/grpc/grpc/blob/618a3f561d4a93f263cca23abad086ed8f4d5e86/src/core/lib/gpr/wrap_memcpy.cc
Fixes:
- http://autobuild.buildroot.org/results/20d6f2489a4e291a53bd514da66105eb607e1014
---
Changes v1 -> v2:
- Pass TARGET_CXXFLAGS to CMAKE_CXX_FLAGS
package/grpc/grpc.mk | 8 ++++++++ 1 file changed, 8 insertions(+)
package/grpc/grpc.mk +8 -0
@@ -33,6 +33,14 @@ ifeq ($(BR2_TOOLCHAIN_HAS_LIBATOMIC),y) GRPC_CONF_OPTS += -DCMAKE_EXE_LINKER_FLAGS=-latomic endif +# Set GPR_MUSL_LIBC_COMPAT otherwise build will fail on x86_64 with uclibc +# because grpc tries to link with memcpy at GLIBC_2.2.5 +ifeq ($(BR2_x86_64):$(BR2_TOOLCHAIN_USES_GLIBC),y:) +GRPC_CONF_OPTS += \ + -DCMAKE_C_FLAGS="$(TARGET_CFLAGS) -DGPR_MUSL_LIBC_COMPAT" \ + -DCMAKE_CXX_FLAGS="$(TARGET_CXXFLAGS) -DGPR_MUSL_LIBC_COMPAT" +endif + HOST_GRPC_CONF_OPTS = \ -D_gRPC_CARES_LIBRARIES=cares \ -DgRPC_CARES_PROVIDER=none \
Signature · 1 line
2.20.1
PATCH v2 1/1 package/grpc: fix build with uclibc on x86_64
Hello,
Quoted 6 lines · On Thu, 30 May 2019 23:29:06 +0200 Fabrice Fontaine…
On
x86_64ifGPR_MUSL_LIBC_COMPATis not set, grpc tries to link with memcpy at GLIBC_2.2.5, see:
https://github.com/grpc/grpc/blob/618a3f561d4a93f263cca23abad086ed8f4d5e86/src/core/lib/gpr/wrap_memcpy.ccFixes:
- http://autobuild.buildroot.org/results/20d6f2489a4e291a53bd514da66105eb607e1014
The downside of setting GPR_MUSL_LIBC_COMPAT is that it doesn't change just this memcpy() wrapping horror, it also impacts another part of the gRPC code in src/core/lib/gpr/cpu_linux.c:
static void init_num_cpus() {
#ifndef GPR_MUSL_LIBC_COMPAT
if (sched_getcpu() < 0) {
gpr_log(GPR_ERROR, "Error determining current CPU: %s\n", strerror(errno));
ncpus = 1;
return; }
#endif
/* This must be signed. sysconf returns -1 when the number cannot be
determined */
ncpus = static_cast<int>(sysconf(_SC_NPROCESSORS_CONF));
if (ncpus < 1) {
gpr_log(GPR_ERROR, "Cannot determine number of CPUs: assuming 1");
ncpus = 1; }
}
unsigned gpr_cpu_current_cpu(void) {
#ifdef GPR_MUSL_LIBC_COMPAT
// sched_getcpu() is undefined on musl
return 0;
#else
if (gpr_cpu_num_cores() == 1) {
return 0;
}
int cpu = sched_getcpu();
if (cpu < 0) {
gpr_log(GPR_ERROR, "Error determining current CPU: %s\n", strerror(errno));
return 0;
}
if (static_cast<unsigned>(cpu) >= gpr_cpu_num_cores()) {
gpr_log(GPR_ERROR, "Cannot handle hot-plugged CPUs");
return 0; }
return static_cast<unsigned>(cpu);
#endif
}
I don't know how much this matters, but it's worth considering.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH v2 1/1 package/grpc: fix build with uclibc on x86_64
In reply to Fabrice FontaineQuoted 3 lines · Fabrice Fontaine
On
x86_64ifGPR_MUSL_LIBC_COMPATis not set, grpc tries to link with memcpy at GLIBC_2.2.5, see:
https://github.com/grpc/grpc/blob/618a3f561d4a93f263cca23abad086ed8f4d5e86/src/core/lib/gpr/wrap_memcpy.cc
The comment above that memcpy wrapper says:
* Provide a wrapped memcpy for targets that need to be backwards
* compatible with older libc's.
We definitely *don't* want to be backward compatible with older libcs (even on
glibc, we might configure it to not provide the older ABI).
So, isn't there a way to avoid linking with this stuff entirely?
Regards,
Arnout
Quoted 32 lines
Fixes:
- http://autobuild.buildroot.org/results/20d6f2489a4e291a53bd514da66105eb607e1014Signed-off-by Fabrice Fontaine <[email protected]>---
Changes v1 -> v2:
- PassTARGET_CXXFLAGStoCMAKE_CXX_FLAGSpackage/grpc/grpc.mk | 8 ++++++++ 1 file changed, 8 insertions(+)package/grpc/grpc.mk +8
-0@@ -33,6 +33,14 @@ ifeq ($(BR2_TOOLCHAIN_HAS_LIBATOMIC),y) GRPC_CONF_OPTS += -DCMAKE_EXE_LINKER_FLAGS=-latomic endif +# Set GPR_MUSL_LIBC_COMPAT otherwise build will fail on x86_64 with uclibc +# because grpc tries to link with memcpy at GLIBC_2.2.5 +ifeq ($(BR2_x86_64):$(BR2_TOOLCHAIN_USES_GLIBC),y:) +GRPC_CONF_OPTS += \ + -DCMAKE_C_FLAGS="$(TARGET_CFLAGS) -DGPR_MUSL_LIBC_COMPAT" \ + -DCMAKE_CXX_FLAGS="$(TARGET_CXXFLAGS) -DGPR_MUSL_LIBC_COMPAT" +endif + HOST_GRPC_CONF_OPTS = \ -D_gRPC_CARES_LIBRARIES=cares \ -DgRPC_CARES_PROVIDER=none \