Enable C++ standard library

pull/19918/head
Esun Kim 5 years ago
parent c458f1cbbc
commit 49b9fb2b3c
  1. 1034
      CMakeLists.txt
  2. 418
      Makefile
  3. 2
      config.m4
  4. 3
      include/grpc/impl/codegen/port_platform.h
  5. 3
      src/php/ext/grpc/config.m4
  6. 22
      src/ruby/ext/grpc/rb_enable_cpp.cc
  7. 20
      templates/CMakeLists.txt.template
  8. 4
      templates/Makefile.template
  9. 2
      templates/config.m4.template

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -24,8 +24,10 @@ if test "$PHP_GRPC" != "no"; then
case $host in
*darwin*)
PHP_ADD_LIBRARY(c++,1,GRPC_SHARED_LIBADD)
;;
*)
PHP_ADD_LIBRARY(stdc++,1,GRPC_SHARED_LIBADD)
PHP_ADD_LIBRARY(rt,,GRPC_SHARED_LIBADD)
PHP_ADD_LIBRARY(rt)
;;

@ -32,8 +32,7 @@
* in-house library if possible. (e.g. std::map)
*/
#ifndef GRPC_USE_CPP_STD_LIB
/* Default value will be 1 once all tests become green. */
#define GRPC_USE_CPP_STD_LIB 0
#define GRPC_USE_CPP_STD_LIB 1
#endif
/* Get windows.h included everywhere (we need it) */

@ -42,7 +42,8 @@ if test "$PHP_GRPC" != "no"; then
dnl PHP_ADD_LIBRARY(pthread,,GRPC_SHARED_LIBADD)
GRPC_SHARED_LIBADD="-lpthread $GRPC_SHARED_LIBADD"
PHP_ADD_LIBRARY(pthread)
PHP_ADD_LIBRARY(stdc++,,GRPC_SHARED_LIBADD)
PHP_ADD_LIBRARY(stdc++)
PHP_ADD_LIBRARY(dl,,GRPC_SHARED_LIBADD)
PHP_ADD_LIBRARY(dl)

@ -0,0 +1,22 @@
/*
*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <ruby/ruby.h>
// This is a dummy C++ source file to trigger ruby extension builder to
// pick C++ rather than C linker to link with c++ library properly.

@ -174,11 +174,6 @@
endif()
if (_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_IOS)
# C core has C++ source code, but should not depend on libstc++ (for better portability).
# We need to use a few tricks to convince cmake to do that.
# https://stackoverflow.com/questions/15058403/how-to-stop-cmake-from-linking-against-libstdc
set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "")
# Exceptions and RTTI must be off to avoid dependency on libstdc++
set(_gRPC_CORE_NOSTDCXX_FLAGS -fno-exceptions -fno-rtti)
else()
set(_gRPC_CORE_NOSTDCXX_FLAGS "")
@ -444,14 +439,6 @@
PRIVATE <%text>${_gRPC_PROTO_GENS_DIR}</%text>
% endif
)
% if lib.language in ['c', 'csharp']:
# avoid dependency on libstdc++
if (_gRPC_CORE_NOSTDCXX_FLAGS)
set_target_properties(${lib.name} PROPERTIES LINKER_LANGUAGE C)
# only use the flags for C++ source files
target_compile_options(${lib.name} PRIVATE <%text>$<$<COMPILE_LANGUAGE:CXX>:${_gRPC_CORE_NOSTDCXX_FLAGS}></%text>)
endif()
% endif
% if len(get_deps(lib)) > 0:
target_link_libraries(${lib.name}
% for dep in get_deps(lib):
@ -550,13 +537,6 @@
% endfor
)
% if tgt.language in ['c', 'csharp']:
# avoid dependency on libstdc++
if (_gRPC_CORE_NOSTDCXX_FLAGS)
set_target_properties(${tgt.name} PROPERTIES LINKER_LANGUAGE C)
target_compile_options(${tgt.name} PRIVATE <%text>$<$<COMPILE_LANGUAGE:CXX>:${_gRPC_CORE_NOSTDCXX_FLAGS}></%text>)
endif()
% endif
% endif
</%def>

@ -1588,7 +1588,7 @@
if lib.language == 'c++':
ld = '$(LDXX)'
else:
ld = '$(LD)'
ld = '$(LDXX)'
out_mingbase = '$(LIBDIR)/$(CONFIG)/' + lib.name + '$(SHARED_VERSION_' + lang_to_var[lib.language] + ')'
out_libbase = '$(LIBDIR)/$(CONFIG)/lib' + lib.name + '$(SHARED_VERSION_' + lang_to_var[lib.language] + ')'
@ -1781,7 +1781,7 @@
## C-only targets specificities.
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) \
$(Q) $(LDXX) $(LDFLAGS) \
% if not has_no_sources:
$(${tgt.name.upper()}_OBJS)\
% endif

@ -26,8 +26,10 @@
case $host in
*darwin*)
PHP_ADD_LIBRARY(c++,1,GRPC_SHARED_LIBADD)
;;
*)
PHP_ADD_LIBRARY(stdc++,1,GRPC_SHARED_LIBADD)
PHP_ADD_LIBRARY(rt,,GRPC_SHARED_LIBADD)
PHP_ADD_LIBRARY(rt)
;;

Loading…
Cancel
Save