forked from digital-asset/daml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade gRPC C library (digital-asset#8693)
We can’t upgrade to the latest version 1.35.0 since it depends on a newer version of Bazel but we can at least go to 1.34.1. We also have to patch absl and grpc itself to fix mingw support and some undeclared inclusions on Windows. Both patches are taken from upstream PRs (the mingw one has not been merged yet). There is also a small patch to grpc-haskell-core. I’ve started working on upstreaming that but the nix build system is a mess and I haven’t quite managed to get it working there. changelog_begin changelog_end
- Loading branch information
1 parent
7cf1914
commit afb2006
Showing
7 changed files
with
509 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
Taken from https://github.com/abseil/abseil-cpp/pull/884 | ||
|
||
From 8ef49c10f419ff8e6e3865c06ea6dfe36be642ff Mon Sep 17 00:00:00 2001 | ||
From: Pascal Muetschard <pmuetschard@google.com> | ||
Date: Mon, 11 Jan 2021 15:17:06 -0800 | ||
Subject: [PATCH] Don't assume Windows means MSVC in the bazel BUILD files. | ||
|
||
When selecting the compiler flags, use the compiler setting, rather than | ||
the platform setting, to detect if MSVC flags are required. | ||
--- | ||
absl/BUILD.bazel | 24 ++++++++++++++++++++++++ | ||
absl/base/BUILD.bazel | 4 ++-- | ||
absl/copts/configure_copts.bzl | 6 +++--- | ||
absl/debugging/BUILD.bazel | 8 ++++---- | ||
absl/random/internal/BUILD.bazel | 6 +++--- | ||
absl/synchronization/BUILD.bazel | 2 +- | ||
6 files changed, 37 insertions(+), 13 deletions(-) | ||
diff --git a/absl/BUILD.bazel b/absl/BUILD.bazel | ||
index 0b772df..651b3f4 100644 | ||
--- a/absl/BUILD.bazel | ||
+++ b/absl/BUILD.bazel | ||
@@ -28,6 +28,30 @@ create_llvm_config( | ||
visibility = [":__subpackages__"], | ||
) | ||
|
||
+config_setting( | ||
+ name = "msvc_compiler", | ||
+ flag_values = { | ||
+ "@bazel_tools//tools/cpp:compiler": "msvc-cl", | ||
+ }, | ||
+ visibility = [":__subpackages__"], | ||
+) | ||
+ | ||
+config_setting( | ||
+ name = "clang_cl_compiler", | ||
+ flag_values = { | ||
+ "@bazel_tools//tools/cpp:compiler": "clang-cl", | ||
+ }, | ||
+ visibility = [":__subpackages__"], | ||
+) | ||
+ | ||
+alias( | ||
+ name = "msvc_compat_compiler", | ||
+ actual = select({ | ||
+ ":clang_cl_compiler": ":clang_cl_compiler", | ||
+ "//conditions:default": ":msvc_compiler", | ||
+ }) | ||
+) | ||
+ | ||
config_setting( | ||
name = "osx", | ||
constraint_values = [ | ||
diff --git a/absl/base/BUILD.bazel b/absl/base/BUILD.bazel | ||
index 9d96abe..817c06a 100644 | ||
--- a/absl/base/BUILD.bazel | ||
+++ b/absl/base/BUILD.bazel | ||
@@ -160,7 +160,7 @@ cc_library( | ||
], | ||
copts = ABSL_DEFAULT_COPTS, | ||
linkopts = select({ | ||
- "//absl:windows": [], | ||
+ "//absl:msvc_compat_compiler": [], | ||
"//absl:wasm": [], | ||
"//conditions:default": ["-pthread"], | ||
}) + ABSL_DEFAULT_LINKOPTS, | ||
@@ -220,7 +220,7 @@ cc_library( | ||
], | ||
copts = ABSL_DEFAULT_COPTS, | ||
linkopts = select({ | ||
- "//absl:windows": [ | ||
+ "//absl:msvc_compat_compiler": [ | ||
"-DEFAULTLIB:advapi32.lib", | ||
], | ||
"//absl:wasm": [], | ||
diff --git a/absl/copts/configure_copts.bzl b/absl/copts/configure_copts.bzl | ||
index ff9a5ea..5d00332 100644 | ||
--- a/absl/copts/configure_copts.bzl | ||
+++ b/absl/copts/configure_copts.bzl | ||
@@ -22,7 +22,7 @@ load( | ||
) | ||
|
||
ABSL_DEFAULT_COPTS = select({ | ||
- "//absl:windows": ABSL_MSVC_FLAGS, | ||
+ "//absl:msvc_compat_compiler": ABSL_MSVC_FLAGS, | ||
"//absl:llvm_compiler": ABSL_LLVM_FLAGS, | ||
"//conditions:default": ABSL_GCC_FLAGS, | ||
}) | ||
@@ -30,13 +30,13 @@ ABSL_DEFAULT_COPTS = select({ | ||
# in absence of modules (--compiler=gcc or -c opt), cc_tests leak their copts | ||
# to their (included header) dependencies and fail to build outside absl | ||
ABSL_TEST_COPTS = ABSL_DEFAULT_COPTS + select({ | ||
- "//absl:windows": ABSL_MSVC_TEST_FLAGS, | ||
+ "//absl:msvc_compat_compiler": ABSL_MSVC_TEST_FLAGS, | ||
"//absl:llvm_compiler": ABSL_LLVM_TEST_FLAGS, | ||
"//conditions:default": ABSL_GCC_TEST_FLAGS, | ||
}) | ||
|
||
ABSL_DEFAULT_LINKOPTS = select({ | ||
- "//absl:windows": ABSL_MSVC_LINKOPTS, | ||
+ "//absl:msvc_compat_compiler": ABSL_MSVC_LINKOPTS, | ||
"//conditions:default": [], | ||
}) | ||
|
||
diff --git a/absl/debugging/BUILD.bazel b/absl/debugging/BUILD.bazel | ||
index 86faac9..d0984b9 100644 | ||
--- a/absl/debugging/BUILD.bazel | ||
+++ b/absl/debugging/BUILD.bazel | ||
@@ -66,7 +66,7 @@ cc_library( | ||
], | ||
copts = ABSL_DEFAULT_COPTS, | ||
linkopts = ABSL_DEFAULT_LINKOPTS + select({ | ||
- "//absl:windows": ["-DEFAULTLIB:dbghelp.lib"], | ||
+ "//absl:msvc_compat_compiler": ["-DEFAULTLIB:dbghelp.lib"], | ||
"//conditions:default": [], | ||
}), | ||
deps = [ | ||
@@ -86,11 +86,11 @@ cc_test( | ||
name = "symbolize_test", | ||
srcs = ["symbolize_test.cc"], | ||
copts = ABSL_TEST_COPTS + select({ | ||
- "//absl:windows": ["/Z7"], | ||
+ "//absl:msvc_compat_compiler": ["/Z7"], | ||
"//conditions:default": [], | ||
}), | ||
linkopts = ABSL_DEFAULT_LINKOPTS + select({ | ||
- "//absl:windows": ["/DEBUG"], | ||
+ "//absl:msvc_compat_compiler": ["/DEBUG"], | ||
"//conditions:default": [], | ||
}), | ||
deps = [ | ||
@@ -148,7 +148,7 @@ cc_test( | ||
srcs = ["failure_signal_handler_test.cc"], | ||
copts = ABSL_TEST_COPTS, | ||
linkopts = select({ | ||
- "//absl:windows": [], | ||
+ "//absl:msvc_compat_compiler": [], | ||
"//absl:wasm": [], | ||
"//conditions:default": ["-pthread"], | ||
}) + ABSL_DEFAULT_LINKOPTS, | ||
diff --git a/absl/random/internal/BUILD.bazel b/absl/random/internal/BUILD.bazel | ||
index 8485e28..944f512 100644 | ||
--- a/absl/random/internal/BUILD.bazel | ||
+++ b/absl/random/internal/BUILD.bazel | ||
@@ -75,7 +75,7 @@ cc_library( | ||
], | ||
copts = ABSL_DEFAULT_COPTS, | ||
linkopts = ABSL_DEFAULT_LINKOPTS + select({ | ||
- "//absl:windows": ["-DEFAULTLIB:bcrypt.lib"], | ||
+ "//absl:msvc_compat_compiler": ["-DEFAULTLIB:bcrypt.lib"], | ||
"//conditions:default": [], | ||
}), | ||
deps = [ | ||
@@ -98,7 +98,7 @@ cc_library( | ||
], | ||
copts = ABSL_DEFAULT_COPTS, | ||
linkopts = select({ | ||
- "//absl:windows": [], | ||
+ "//absl:msvc_compat_compiler": [], | ||
"//absl:wasm": [], | ||
"//conditions:default": ["-pthread"], | ||
}) + ABSL_DEFAULT_LINKOPTS, | ||
@@ -320,7 +320,7 @@ cc_library( | ||
"randen_hwaes.h", | ||
], | ||
copts = ABSL_DEFAULT_COPTS + ABSL_RANDOM_RANDEN_COPTS + select({ | ||
- "//absl:windows": [], | ||
+ "//absl:msvc_compat_compiler": [], | ||
"//conditions:default": ["-Wno-pass-failed"], | ||
}), | ||
linkopts = ABSL_DEFAULT_LINKOPTS, | ||
diff --git a/absl/synchronization/BUILD.bazel b/absl/synchronization/BUILD.bazel | ||
index 4d4d680..b75bb42 100644 | ||
--- a/absl/synchronization/BUILD.bazel | ||
+++ b/absl/synchronization/BUILD.bazel | ||
@@ -89,7 +89,7 @@ cc_library( | ||
], | ||
copts = ABSL_DEFAULT_COPTS, | ||
linkopts = select({ | ||
- "//absl:windows": [], | ||
+ "//absl:msvc_compat_compiler": [], | ||
"//absl:wasm": [], | ||
"//conditions:default": ["-pthread"], | ||
}) + ABSL_DEFAULT_LINKOPTS, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
diff --git a/cbits/grpc_haskell.c b/cbits/grpc_haskell.c | ||
index ebbcbb1..236c73e 100644 | ||
--- a/cbits/grpc_haskell.c | ||
+++ b/cbits/grpc_haskell.c | ||
@@ -504,8 +504,7 @@ grpc_auth_metadata_processor* mk_auth_metadata_processor( | ||
|
||
grpc_call_credentials* grpc_metadata_credentials_create_from_plugin_( | ||
grpc_metadata_credentials_plugin* plugin){ | ||
- | ||
- return grpc_metadata_credentials_create_from_plugin(*plugin, NULL); | ||
+ return grpc_metadata_credentials_create_from_plugin(*plugin, GRPC_PRIVACY_AND_INTEGRITY, NULL); | ||
} | ||
|
||
//This is a hack to work around GHC being unable to deal with raw struct params. | ||
diff --git a/src/Network/GRPC/Unsafe.chs b/src/Network/GRPC/Unsafe.chs | ||
index d11f533..6eb08b8 100644 | ||
--- a/src/Network/GRPC/Unsafe.chs | ||
+++ b/src/Network/GRPC/Unsafe.chs | ||
@@ -219,9 +219,6 @@ castPeek p = do | ||
unTag `Tag'} | ||
-> `()'#} | ||
|
||
-{#fun grpc_channel_ping as ^ | ||
- {`Channel', `CompletionQueue', unTag `Tag',unReserved `Reserved'} -> `()' #} | ||
- | ||
{#fun grpc_channel_destroy as ^ {`Channel'} -> `()'#} | ||
|
||
-- | Starts executing a batch of ops in the given 'OpArray'. Does not block. | ||
diff --git a/tests/LowLevelTests/Op.hs b/tests/LowLevelTests/Op.hs | ||
index 52b6d55..ff0751a 100644 | ||
--- a/tests/LowLevelTests/Op.hs | ||
+++ b/tests/LowLevelTests/Op.hs | ||
@@ -4,6 +4,9 @@ | ||
|
||
module LowLevelTests.Op where | ||
|
||
+import Control.Concurrent | ||
+import Control.Exception | ||
+import Control.Monad | ||
import Data.ByteString (ByteString) | ||
import Test.Tasty | ||
import Test.Tasty.HUnit as HU (testCase, (@?=)) | ||
@@ -47,14 +50,20 @@ withClientServerUnaryCall :: GRPC | ||
withClientServerUnaryCall grpc f = do | ||
withClient grpc clientConf $ \c -> do | ||
crm <- clientRegisterMethodNormal c "/foo" | ||
- withServer grpc serverConf $ \s -> | ||
- withClientCall c crm 10 $ \cc -> do | ||
+ withServer grpc serverConf $ \s -> do | ||
+ ccVar <- newEmptyMVar | ||
+ bracket newEmptyMVar (\v -> putMVar v ()) $ \finished -> do | ||
+ _ <- forkIO $ void $ withClientCall c crm 10 $ \cc -> do | ||
+ putMVar ccVar cc | ||
+ -- NOTE: We need to send client ops here or else `withServerCall` hangs, | ||
+ -- because registered methods try to do recv ops immediately when | ||
+ -- created. If later we want to send payloads or metadata, we'll need | ||
+ -- to tweak this. | ||
+ _clientRes <- runOps (unsafeCC cc) (clientCQ c) clientEmptySendOps | ||
+ takeMVar finished | ||
+ pure (Right ()) | ||
let srm = head (normalMethods s) | ||
- -- NOTE: We need to send client ops here or else `withServerCall` hangs, | ||
- -- because registered methods try to do recv ops immediately when | ||
- -- created. If later we want to send payloads or metadata, we'll need | ||
- -- to tweak this. | ||
- _clientRes <- runOps (unsafeCC cc) (clientCQ c) clientEmptySendOps | ||
+ cc <- takeMVar ccVar | ||
withServerCall s srm $ \sc -> | ||
f (c, s, cc, sc) | ||
|
Oops, something went wrong.