Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gRPC C core to v1.29.1 #466

Merged
merged 21 commits into from
Jun 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
env:
RUST_BACKTRACE: 1
RUSTFLAGS: "--deny=warnings"
GRPC_VERSION: 1.26.0
GRPC_VERSION: 1.29.1

jobs:
Linux-Format-PKG-Test:
Expand Down Expand Up @@ -51,8 +51,9 @@ jobs:
- uses: actions/checkout@v2
- run: which go && go version && which cargo && cargo version && clang --version && openssl version
- run: scripts/reset-submodule.cmd
- run: cargo test --features "openssl" --all
- run: cargo test --features "openssl-vendored" --all
- run: cargo clean
- run: cargo test --features "openssl" --all

Linux-Nightly:
name: Linux-Nightly
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
arch: arm64
before_script:
- scripts/reset-submodule.cmd
- export GRPC_VERSION=1.26.0
- export GRPC_VERSION=1.29.1
- export PATH="$PATH:$HOME/.cache/bin:$HOME/.cargo/bin"
- GRPC_HEADER="$HOME/.cache/include/grpc/grpc.h"
- if [[ ! -f "$GRPC_HEADER" ]] ; then
Expand All @@ -58,7 +58,7 @@ jobs:
arch: arm64
before_script:
- scripts/reset-submodule.cmd
- export GRPC_VERSION=1.26.0
- export GRPC_VERSION=1.29.1
- export PATH="$PATH:$HOME/.cache/bin:$HOME/.cargo/bin"
- GRPC_HEADER="$HOME/.cache/include/grpc/grpc.h"
- sudo apt-get update && sudo apt-get -y install libssl-dev;
Expand Down
22 changes: 7 additions & 15 deletions grpc-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,25 @@ exclude = [
"grpc/templates/*",
"grpc/src/android/*",
"grpc/src/csharp/*",
"grpc/src/boringssl/crypto_test_data.cc",
"grpc/src/node/*",
"grpc/src/objective-c/*",
"grpc/src/php/*",
"grpc/src/python/*",
"grpc/src/ruby/*",
"grpc/vsprojects/*",
"grpc/test/core/end2end/*",
"grpc/third_party/zlib/*",
"grpc/third_party/abseil-cpp/*",
"grpc/third_party/benchmark/*",
"grpc/third_party/bloaty/*",
"grpc/third_party/boringssl/fuzz/*",
"grpc/third_party/boringssl/crypto/cipher_extra/test/*",
"grpc/third_party/boringssl/third_party/android-cmake/*",
"grpc/third_party/boringssl/third_party/wycheproof_testvectors",
"grpc/third_party/boringssl/third_party/googletest",
"!grpc/third_party/boringssl/third_party/googletest/src/gtest-all.cc",
"grpc/third_party/boringssl-with-bazel/*",
"grpc/third_party/libuv/*",
"grpc/third_party/gflags/*",
"grpc/third_party/googletest/*",
"grpc/third_party/libcxx/*",
"grpc/third_party/libcxxabi/*",
"grpc/third_party/objective_c/*",
"grpc/third_party/protobuf/*",
"grpc/third_party/rake-compiler-dock/*",
"grpc/third_party/toolchan/*",
"grpc/third_party/toolchans/*",
"grpc/third_party/envoy-api/*",
"grpc/third_party/googleapis/*",
"grpc/third_party/protoc-gen-validate/*",
"grpc/third_party/udpa/*",
"grpc/tools/run_tests/generated/*",
"grpc/test/core/",
"!grpc/test/core/security/*.cc",
Expand All @@ -67,7 +59,7 @@ no-omit-frame-pointer = []

[build-dependencies]
cc = "1.0"
cmake = "0.1.40"
cmake = "0.1"
pkg-config = "0.3"
walkdir = "2.2.9"
# Because of rust-lang/cargo#5237, bindgen should not be upgraded util a minor or major release.
Expand Down
182 changes: 143 additions & 39 deletions grpc-sys/bindings/aarch64-unknown-linux-gnu-bindings.rs

Large diffs are not rendered by default.

182 changes: 143 additions & 39 deletions grpc-sys/bindings/x86_64-unknown-linux-gnu-bindings.rs

Large diffs are not rendered by default.

121 changes: 59 additions & 62 deletions grpc-sys/build.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.

extern crate cc;
extern crate cmake;
extern crate pkg_config;

use std::env::VarError;
use std::io::prelude::*;
use std::io::BufReader;
use std::path::{Path, PathBuf};
use std::{env, fs, io};

use cc::Build;
use cmake::Config;
use cmake::Config as CmakeConfig;
use pkg_config::{Config as PkgConfig, Library};
use walkdir::WalkDir;

const GRPC_VERSION: &str = "1.26.0";
const GRPC_VERSION: &str = "1.29.1";

fn probe_library(library: &str, cargo_metadata: bool) -> Library {
match PkgConfig::new()
Expand All @@ -33,10 +28,11 @@ fn prepare_grpc() {
"grpc",
"grpc/third_party/cares/cares",
"grpc/third_party/address_sorting",
"grpc/third_party/abseil-cpp",
];

if cfg!(feature = "secure") {
modules.push("grpc/third_party/boringssl");
if cfg!(feature = "secure") && !cfg!(feature = "openssl") {
modules.push("grpc/third_party/boringssl-with-bazel");
}

for module in modules {
Expand All @@ -63,22 +59,32 @@ fn trim_start<'a>(s: &'a str, prefix: &str) -> Option<&'a str> {
}
}

fn build_grpc(cc: &mut Build, library: &str) {
fn build_grpc(cc: &mut cc::Build, library: &str) {
prepare_grpc();

let mut third_party = vec!["cares/cares/lib"];
let mut third_party = vec![
"cares/cares/lib",
"abseil-cpp/absl/strings",
"abseil-cpp/absl/time",
"abseil-cpp/absl/base",
"abseil-cpp/absl/types",
"abseil-cpp/absl/numeric",
];

let dst = {
let mut config = Config::new("grpc");
if !cfg!(feature = "secure") {
// boringssl's configuration is still included, but targets
// will never be built, hence specify a fake go to get rid of
// the unnecessary dependency.
config.define("GO_EXECUTABLE", "fake-go-nonexist");
}
let mut config = CmakeConfig::new("grpc");

if get_env("CARGO_CFG_TARGET_OS").map_or(false, |s| s == "macos") {
config.cxxflag("-stdlib=libc++");
}

// Ensure CoreFoundation be found in macos or ios
if get_env("CARGO_CFG_TARGET_OS").map_or(false, |s| s == "macos")
|| get_env("CARGO_CFG_TARGET_OS").map_or(false, |s| s == "ios")
{
println!("cargo:rustc-link-lib=framework=CoreFoundation");
}

if env::var("CARGO_CFG_TARGET_ENV").unwrap() == "musl" {
config.define("CMAKE_CXX_COMPILER", "g++");
}
Expand Down Expand Up @@ -129,10 +135,11 @@ fn build_grpc(cc: &mut Build, library: &str) {
config.define("gRPC_BENCHMARK_PROVIDER", "none");
if cfg!(feature = "openssl") {
config.define("gRPC_SSL_PROVIDER", "package");
config.define("EMBED_OPENSSL", "false");
setup_openssl(&mut config)
if cfg!(feature = "openssl-vendored") {
config.register_dep("openssl");
}
} else if cfg!(feature = "secure") {
third_party.extend_from_slice(&["boringssl/ssl", "boringssl/crypto"]);
third_party.extend_from_slice(&["boringssl-with-bazel"]);
}
if cfg!(feature = "no-omit-frame-pointer") {
config
Expand Down Expand Up @@ -167,10 +174,33 @@ fn build_grpc(cc: &mut Build, library: &str) {
}
}

// link libz
println!("cargo:rustc-link-lib=static=z");
// link cares
println!("cargo:rustc-link-lib=static=cares");
println!("cargo:rustc-link-lib=static=gpr");
// link address_sorting
println!("cargo:rustc-link-lib=static=address_sorting");
// link absl/base
println!("cargo:rustc-link-lib=static=absl_base");
println!("cargo:rustc-link-lib=static=absl_raw_logging_internal");
println!("cargo:rustc-link-lib=static=absl_dynamic_annotations");
println!("cargo:rustc-link-lib=static=absl_throw_delegate");
println!("cargo:rustc-link-lib=static=absl_log_severity");
println!("cargo:rustc-link-lib=static=absl_spinlock_wait");
// link absl/strings
println!("cargo:rustc-link-lib=static=absl_strings");
println!("cargo:rustc-link-lib=static=absl_strings_internal");
println!("cargo:rustc-link-lib=static=absl_str_format_internal");
// link absl/time
println!("cargo:rustc-link-lib=static=absl_civil_time");
println!("cargo:rustc-link-lib=static=absl_time_zone");
println!("cargo:rustc-link-lib=static=absl_time");
// link absl/types
println!("cargo:rustc-link-lib=static=absl_bad_optional_access");
// link absl/numeric
println!("cargo:rustc-link-lib=static=absl_int128");
// link grpc related lib
println!("cargo:rustc-link-lib=static=gpr");
println!("cargo:rustc-link-lib=static=upb");
println!("cargo:rustc-link-lib=static={}", library);

Expand Down Expand Up @@ -213,7 +243,7 @@ fn figure_ssl_path(build_dir: &str) {
println!("cargo:rustc-link-lib=crypto");
}

fn setup_libz(config: &mut Config) {
fn setup_libz(config: &mut CmakeConfig) {
config.define("gRPC_ZLIB_PROVIDER", "package");
config.register_dep("Z");
// cmake script expect libz.a being under ${DEP_Z_ROOT}/lib, but libz-sys crate put it
Expand All @@ -230,39 +260,6 @@ fn setup_libz(config: &mut Config) {
env::set_var("CMAKE_PREFIX_PATH", prefix_path);
}

#[cfg(feature = "openssl-vendored")]
fn setup_openssl(config: &mut Config) {
// openssl-sys uses openssl-src to build the library. openssl-src uses
// configure/make to build the library which makes it hard to detect
// what's the actual path of the library. Here assumes the directory
// structure as follow (which is the behavior of 0.9.47):
// install_dir/
// include/
// lib/
// Remove the hack when sfackler/rust-openssl#1117 is resolved.
config.register_dep("openssl");
if env::var("DEP_OPENSSL_ROOT").is_err() {
let include_str = env::var("DEP_OPENSSL_INCLUDE").unwrap();
let include_dir = Path::new(&include_str);
let root_dir = format!("{}", include_dir.parent().unwrap().display());
env::set_var("DEP_OPENSSL_ROOT", &root_dir);
}
}

#[cfg(not(feature = "openssl-vendored"))]
fn setup_openssl(config: &mut Config) {
// check if openssl provided from system support ALPN
if Build::new()
.file("grpc/test/build/openssl-alpn.c")
.cargo_metadata(false)
.cpp(true)
.try_compile("check_alpn")
.is_err()
{
config.cxxflag("-DTSI_OPENSSL_ALPN_SUPPORT=0");
}
}

fn get_env(name: &str) -> Option<String> {
println!("cargo:rerun-if-env-changed={}", name);
match env::var(name) {
Expand Down Expand Up @@ -369,7 +366,9 @@ fn main() {
println!("cargo:rerun-if-changed=grpc");
println!("cargo:rerun-if-env-changed=UPDATE_BIND");

let mut cc = Build::new();
// create a builder to compile grpc_wrap.cc
let mut cc = cc::Build::new();
// create a config to generate binding file
let mut bind_config = bindgen::Builder::default();

let library = if cfg!(feature = "secure") {
Expand All @@ -381,9 +380,9 @@ fn main() {
};

if get_env("CARGO_CFG_TARGET_OS").map_or(false, |s| s == "windows") {
// At lease win7
cc.define("_WIN32_WINNT", Some("0x0700"));
bind_config = bind_config.clang_arg("-D _WIN32_WINNT=0x0700");
// At lease vista
cc.define("_WIN32_WINNT", Some("0x600"));
bind_config = bind_config.clang_arg("-D _WIN32_WINNT=0x600");
}

if get_env("GRPCIO_SYS_USE_PKG_CONFIG").map_or(false, |s| s == "1") {
Expand All @@ -401,9 +400,7 @@ fn main() {
cc.flag("-std=c++11");
}
cc.file("grpc_wrap.cc");

cc.warnings_into_errors(true);

cc.compile("libgrpc_wrap.a");

config_binding_path(bind_config);
Expand Down
2 changes: 1 addition & 1 deletion grpc-sys/grpc
Submodule grpc updated from d6347b to 2808d6
3 changes: 2 additions & 1 deletion scripts/reset-submodule.cmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
git submodule update --init grpc-sys/grpc
cd grpc-sys/grpc
git submodule update --init third_party/boringssl
git submodule update --init third_party/boringssl-with-bazel
git submodule update --init third_party/cares/cares
git submodule update --init third_party/abseil-cpp
cd third_party/zlib
git clean -f
git reset --hard
Loading