Removed the OpenSSL dependency for building gRPC in Mesos.

When the SSL build feature is disabled, Mesos now builds
`libgrpc_unsecure` and `libgrpc++_unsecure` instead of `libgrpc` and
`libgrpc++`, so the SSL headers and libraries are no longer required.

Review: https://reviews.apache.org/r/66996


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/b74821cd
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b74821cd
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b74821cd

Branch: refs/heads/master
Commit: b74821cd43d3616e69393aa15d1a7cef98979350
Parents: 04313d0
Author: Chun-Hung Hsiao <chhs...@mesosphere.io>
Authored: Tue Apr 24 15:05:37 2018 -0700
Committer: Chun-Hung Hsiao <chhs...@mesosphere.io>
Committed: Wed May 9 12:05:13 2018 -0700

----------------------------------------------------------------------
 3rdparty/Makefile.am                       | 29 ++++++++++++++++++-------
 configure.ac                               | 14 +++++-------
 src/Makefile.am                            | 13 ++++++-----
 src/python/native_common/ext_modules.py.in | 16 ++++++--------
 4 files changed, 41 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/b74821cd/3rdparty/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/Makefile.am b/3rdparty/Makefile.am
index 6740940..062df18 100644
--- a/3rdparty/Makefile.am
+++ b/3rdparty/Makefile.am
@@ -322,26 +322,39 @@ PROTOC = @PROTOCOMPILER@
 endif
 
 if ENABLE_GRPC
+if !ENABLE_SSL
+GRPC_VARIANT = _unsecure
+endif
+
 if WITH_BUNDLED_GRPC
-LIB_GRPC = $(GRPC)/libs/opt/libgrpc++.a                        \
-           $(GRPC)/libs/opt/libgrpc.a                  \
+LIB_GRPC = $(GRPC)/libs/opt/libgrpc++$(GRPC_VARIANT).a \
+           $(GRPC)/libs/opt/libgrpc$(GRPC_VARIANT).a   \
            $(GRPC)/libs/opt/libgpr.a
 
 $(LIB_GRPC): $(GRPC)-build-stamp
 
+# NOTE: We the include flags through the `CPPFLAGS` environment variable rather
+# than the command line because gRPC uses target-specific assignments to append
+# flags to `CPPFLAGS`, which will be overwritten by command line arguments. 
See:
+# https://www.gnu.org/software/make/manual/html_node/Target_002dspecific.html
 $(GRPC)-build-stamp: $(GRPC)-stamp                     \
                      $(PROTOBUF)-build-stamp
        cd $(GRPC) &&                                   \
          CPPFLAGS="$(PROTOBUF_INCLUDE_FLAGS)           \
                    $(SSL_INCLUDE_FLAGS)                \
                    $(ZLIB_INCLUDE_FLAGS)"              \
-         LDFLAGS="$(PROTOBUF_LINKER_FLAGS)             \
-                  $(SSL_LINKER_FLAGS)                  \
-                  $(ZLIB_LINKER_FLAGS)"                \
          $(MAKE) $(AM_MAKEFLAGS)                       \
-                 HAS_PKG_CONFIG=false                  \
-                 NO_PROTOC=false                       \
-                 PROTOC=$(PROTOC)
+           $(LIB_GRPC:%=$(abs_builddir)/%)             \
+           CC="$(CC)"                                  \
+           CXX="$(CXX)"                                \
+           LD="$(CC)"                                  \
+           LDXX="$(CXX)"                               \
+           LDFLAGS="$(PROTOBUF_LINKER_FLAGS)           \
+                    $(SSL_LINKER_FLAGS)                \
+                    $(ZLIB_LINKER_FLAGS)"              \
+           HAS_PKG_CONFIG=false                        \
+           NO_PROTOC=false                             \
+           PROTOC="$(PROTOC)"
        touch $@
 
 ALL_LOCAL += $(LIB_GRPC)

http://git-wip-us.apache.org/repos/asf/mesos/blob/b74821cd/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 429797c..6d9c8ce 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2067,9 +2067,13 @@ if test "x$enable_grpc" = "xyes"; then
       GRPCPREFIX="/usr"
     fi
 
+    if test "x$enable_ssl" = "xno"; then
+      GRPC_VARIANT="_unsecure"
+    fi
+
     # Check if headers and library were located.
     saved_LIBS="$LIBS"
-    LIBS="-lgrpc++ -lgrpc -lgpr $LIBS"
+    LIBS="-lgrpc++$GRPC_VARIANT -lgrpc$GRPC_VARIANT -lgpr $LIBS"
     AC_LANG_PUSH([C++])
     AC_CHECK_HEADERS([grpcpp/grpcpp.h],
                      [AC_LINK_IFELSE(
@@ -2108,14 +2112,6 @@ correct if you are already doing this.
       ])
     fi
   else
-    if test "x$found_ssl" != "xyes"; then
-      AC_MSG_ERROR([cannot find libssl
--------------------------------------------------------------------
-libssl is required for gRPC to build.
--------------------------------------------------------------------
-      ])
-    fi
-
     with_bundled_grpc=yes
   fi
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/b74821cd/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 7e91681..c08ac6e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -171,15 +171,18 @@ LDADD += -lglog
 endif
 
 if ENABLE_GRPC
+if !ENABLE_SSL
+GRPC_VARIANT = _unsecure
+endif
+
 if WITH_BUNDLED_GRPC
 MESOS_CPPFLAGS += -I../$(GRPC)/include
-LIB_GRPC = ../$(GRPC)/libs/opt/libgrpc++.a     \
-           ../$(GRPC)/libs/opt/libgrpc.a       \
-           ../$(GRPC)/libs/opt/libgpr.a                \
-           -lssl -lcrypto
+LIB_GRPC = ../$(GRPC)/libs/opt/libgrpc++$(GRPC_VARIANT).a      \
+           ../$(GRPC)/libs/opt/libgrpc$(GRPC_VARIANT).a                \
+           ../$(GRPC)/libs/opt/libgpr.a
 GRPC_CPP_PLUGIN = ../$(GRPC)/bins/opt/grpc_cpp_plugin
 else
-LIB_GRPC = -lgrpc++ -lgrpc -lgpr -lssl -lcrypto
+LIB_GRPC = -lgrpc++$(GRPC_VARIANT) -lgrpc$(GRPC_VARIANT) -lgpr
 GRPC_CPP_PLUGIN = @GRPC_CXX_PLUGIN@
 endif
 endif

http://git-wip-us.apache.org/repos/asf/mesos/blob/b74821cd/src/python/native_common/ext_modules.py.in
----------------------------------------------------------------------
diff --git a/src/python/native_common/ext_modules.py.in 
b/src/python/native_common/ext_modules.py.in
index 87387fd..dc4d91a 100644
--- a/src/python/native_common/ext_modules.py.in
+++ b/src/python/native_common/ext_modules.py.in
@@ -129,28 +129,26 @@ def _create_module(module_name):
     # only if gRPC is enabled.
     if '@ENABLE_GRPC_FALSE@' == '#':
         grpc = os.path.join('3rdparty', 'grpc-1.10.0')
-        libgrpcxx = os.path.join(abs_top_builddir, grpc, 'libs', 'opt', 
'libgrpc++.a')
-        libgrpc = os.path.join(abs_top_builddir, grpc, 'libs', 'opt', 
'libgrpc.a')
+        grpc_variant = '_unsecure' if '@ENABLE_SSL_TRUE@' == '#' else ''
+        libgrpcpp = os.path.join(abs_top_builddir, grpc, 'libs', 'opt', 
'libgrpc++%s.a' % grpc_variant)
+        libgrpc = os.path.join(abs_top_builddir, grpc, 'libs', 'opt', 
'libgrpc%s.a' % grpc_variant)
         libgpr = os.path.join(abs_top_builddir, grpc, 'libs', 'opt', 
'libgpr.a')
 
-        if os.path.exists(libgrpcxx):
-            EXTRA_OBJECTS.append(libgrpcxx)
+        if os.path.exists(libgrpcpp):
+            EXTRA_OBJECTS.append(libgrpcpp)
         else:
-            EXTRA_OBJECTS.append('-lgrpc++')
+            EXTRA_OBJECTS.append('-lgrpc++%s' % grpc_variant)
 
         if os.path.exists(libgrpc):
             EXTRA_OBJECTS.append(libgrpc)
         else:
-            EXTRA_OBJECTS.append('-lgrpc')
+            EXTRA_OBJECTS.append('-lgrpc%s' % grpc_variant)
 
         if os.path.exists(libgpr):
             EXTRA_OBJECTS.append(libgpr)
         else:
             EXTRA_OBJECTS.append('-lgpr')
 
-        EXTRA_OBJECTS.append('-lssl')
-        EXTRA_OBJECTS.append('-lcrypto')
-
 
     # OSX uses a different linker (llvm-ld) and doesn't support --as-needed
     # TODO(SteveNiemitz): Feature detect --as-needed instead of looking at

Reply via email to