libstdc++-static missing on RHEL8
shirodkara opened this issue · 8 comments
I am trying to build grpc-java on powerpc ppc64le under RHEL8, however since RHEL8 doesn't contain the libstdc++-static packages the following error is seen :
Task :grpc-compiler:linkJava_pluginExecutable FAILED
/usr/bin/ld: cannot find -libgcc_s
/usr/bin/ld: cannot find -libstdc++
collect2: error: ld returned 1 exit status
any ideas on how we can work around this ?
If you don't need to checkout the latest code, you can build on a released grpc-java tag. Otherwise you must follow COMPILING.md. See the first paragraph of https://github.com/grpc/grpc-java/tree/master/examples#grpc-examples
FWIW, I see a libstdc++.a in /usr/lib/gcc/x86_64-redhat-linux/8/32/ as part of the gcc-c++ package. RHEL does disavow all compatibility when using it in RHEL 8 though. I expect that's because every C++ library would then need to be statically linked, which we do for the protobuf plugin.
Nevermind. The libstdc++.a I saw is just a broken symbolic link.
Is there a reason you are building from source? It seems it doesn't take much to make it compile.
yum install -y autoconf automake diffutils gcc-c++ glibc-devel java-1.8.0-openjdk-devel libstdc++-devel libtool make tar which patch
./buildscripts/make_dependencies.sh
export LDFLAGS=-L/tmp/protobuf/lib
export CXXFLAGS=-I/tmp/protobuf/include
export LD_LIBRARY_PATH=/tmp/protobuf/lib
patch -p1 <<EOF
diff --git a/compiler/build.gradle b/compiler/build.gradle
index 60d3a43..55acee0 100644
--- a/compiler/build.gradle
+++ b/compiler/build.gradle
@@ -105,7 +105,6 @@ model {
// Link other (system) libraries dynamically.
// Clang under OSX doesn't support these options.
linker.args "-Wl,-Bstatic", "-lprotoc", "-lprotobuf", "-static-libgcc",
- "-static-libstdc++",
"-Wl,-Bdynamic", "-lpthread", "-s"
}
addEnvArgs("LDFLAGS", linker.args)
EOF
./gradlew -PskipAndroid=true :grpc-compiler:build
Closing. Unclear why building from source on RHEL8 is necessary. There's also an easy workaround. If we hear back more details we can reopen.
Hi @ejona86 would it make sense to have the changes in /compiler/build.gradle to not link statically , so as to make it work out of the box when building on RHEL8 and higher ?
Regarding building on source , we are building for PowerPC ppc64le
Ah, I see. FWIW, you can gradle build
without static linking. It is only gradle publish
that does the check. The built binary is available at build/exe/java_plugin/protoc-gen-grpc-java
.
The check is there for a reason, to make sure we don't release a "broken" binary. So I don't want to outright disable it. We could maybe disable it just for PPC with an if in compiler/build.gradle
.
We'd be quite happy to add a build of PPC64 if someone contributes it (such that they can test that the result works). We are cross-compiling for aarch64 and it has been working okay:
grpc-java/buildscripts/kokoro/linux_artifacts.sh
Lines 35 to 37 in 8a9aa41
grpc-java/buildscripts/kokoro/upload_artifacts.sh
Lines 31 to 32 in d4fa0ec
We will need to deal with lack of static linking on RHEL8 one day, but we only just recently dropped RHEL6 support so that's still a few years down the line.
Closing since haven't heard back. We'd be fine accepting a PR to add PPC64 cross-compilation support. RHEL8 will be a problem one day, but I think we'll avoid it for now. You can either build in a RHEL 7 container or avoid gradle publish
which does the static linking check.