From 71bfcd2afcc3472180843a4d68ce73d9ec51239e Mon Sep 17 00:00:00 2001 From: Jacob Sapoznikow Date: Mon, 30 Jan 2023 22:01:57 +0000 Subject: [PATCH] Fix static linking and dockerfile --- packages/grpc-tools/CMakeLists.txt | 8 ++++---- tools/release/native/Dockerfile | 8 +++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/grpc-tools/CMakeLists.txt b/packages/grpc-tools/CMakeLists.txt index 2b54eac2b..4cb9e14ae 100644 --- a/packages/grpc-tools/CMakeLists.txt +++ b/packages/grpc-tools/CMakeLists.txt @@ -3,12 +3,12 @@ PROJECT("grpc-tools") SET(CMAKE_OSX_DEPLOYMENT_TARGET "11.7" CACHE STRING "Minimum OS X deployment version" FORCE) -if(COMMAND CMAKE_POLICY) +IF(COMMAND CMAKE_POLICY) CMAKE_POLICY(SET CMP0003 NEW) ENDIF(COMMAND CMAKE_POLICY) # MSVC runtime library flags are selected by an abstraction. -if(COMMAND CMAKE_POLICY AND POLICY CMP0091) +IF(COMMAND CMAKE_POLICY AND POLICY CMP0091) CMAKE_POLICY(SET CMP0091 NEW) ENDIF() @@ -22,8 +22,8 @@ SET(PROTOBUF_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/protobuf) ADD_SUBDIRECTORY(${PROTOBUF_ROOT_DIR}/cmake deps/protobuf) -SET(CMAKE_EXE_LINKER_FLAGS "-static-libstdc++") -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-stack-protector") +SET(CMAKE_EXE_LINKER_FLAGS "-static-libstdc++ -static -Wl,-Bstatic") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-stack-protector -static -Wl,-Bstatic") ADD_EXECUTABLE(grpc_node_plugin src/node_generator.cc diff --git a/tools/release/native/Dockerfile b/tools/release/native/Dockerfile index 4d14292fd..18198b8f3 100644 --- a/tools/release/native/Dockerfile +++ b/tools/release/native/Dockerfile @@ -1,3 +1,8 @@ +# NOTE: We don't have to worry about glibc versions +# because we use static linking during the +# compile step. +# (See packages/grpc-tools/CMakeLists.txt#L25) + FROM ubuntu:22.04 RUN apt-get update @@ -9,7 +14,8 @@ RUN apt-get install -y cmake curl build-essential \ gcc-i686-linux-gnu g++-i686-linux-gnu tar file \ gcc-x86-64-linux-gnu g++-x86-64-linux-gnu binutils \ gcc-aarch64-linux-gnu g++-aarch64-linux-gnu make \ - gcc g++ gzip bash + gcc g++ gzip bash libc6-amd64-i386-cross \ + libc6-dev-amd64-i386-cross RUN mkdir /usr/local/nvm ENV NVM_DIR /usr/local/nvm