58 lines
1.9 KiB
Diff
58 lines
1.9 KiB
Diff
|
From: Jakub Jirutka <jakub@jirutka.cz>
|
||
|
Date: Wed, 24 Aug 2022 21:20:22 +0200
|
||
|
Subject: [PATCH] Link with shared libraries, don't embed anything
|
||
|
|
||
|
- Don't statically link openssl, zlib and cares.
|
||
|
- Don't build and statically link libgrpc, link shared libgrpc.
|
||
|
- Don't statically link libgcc and libstdc++.
|
||
|
|
||
|
--- a/src/ruby/ext/grpc/extconf.rb
|
||
|
+++ b/src/ruby/ext/grpc/extconf.rb
|
||
|
@@ -45,9 +45,9 @@
|
||
|
ENV['ARFLAGS'] = '-o'
|
||
|
end
|
||
|
|
||
|
-ENV['EMBED_OPENSSL'] = 'true'
|
||
|
-ENV['EMBED_ZLIB'] = 'true'
|
||
|
-ENV['EMBED_CARES'] = 'true'
|
||
|
+ENV['EMBED_OPENSSL'] = 'false'
|
||
|
+ENV['EMBED_ZLIB'] = 'false'
|
||
|
+ENV['EMBED_CARES'] = 'false'
|
||
|
|
||
|
ENV['ARCH_FLAGS'] = RbConfig::CONFIG['ARCH_FLAG']
|
||
|
if darwin && !cross_compiling
|
||
|
@@ -65,23 +65,15 @@
|
||
|
output_dir = File.expand_path(RbConfig::CONFIG['topdir'])
|
||
|
grpc_lib_dir = File.join(output_dir, 'libs', grpc_config)
|
||
|
ENV['BUILDDIR'] = output_dir
|
||
|
+$LDFLAGS << ' -L' + ENV.fetch('TOPDIR', '.')
|
||
|
|
||
|
-unless windows
|
||
|
- puts 'Building internal gRPC into ' + grpc_lib_dir
|
||
|
- nproc = 4
|
||
|
- nproc = Etc.nprocessors * 2 if Etc.respond_to? :nprocessors
|
||
|
- make = bsd ? 'gmake' : 'make'
|
||
|
- system("#{make} -j#{nproc} -C #{grpc_root} #{grpc_lib_dir}/libgrpc.a CONFIG=#{grpc_config} Q=")
|
||
|
- exit 1 unless $? == 0
|
||
|
-end
|
||
|
-
|
||
|
$CFLAGS << ' -I' + File.join(grpc_root, 'include')
|
||
|
|
||
|
ext_export_file = File.join(grpc_root, 'src', 'ruby', 'ext', 'grpc', 'ext-export')
|
||
|
$LDFLAGS << ' -Wl,--version-script="' + ext_export_file + '.gcc"' if linux
|
||
|
$LDFLAGS << ' -Wl,-exported_symbols_list,"' + ext_export_file + '.clang"' if darwin
|
||
|
|
||
|
-$LDFLAGS << ' ' + File.join(grpc_lib_dir, 'libgrpc.a') unless windows
|
||
|
+$LDFLAGS << ' -Wl,-wrap,memcpy -lgrpc' unless windows
|
||
|
if grpc_config == 'gcov'
|
||
|
$CFLAGS << ' -O0 -fprofile-arcs -ftest-coverage'
|
||
|
$LDFLAGS << ' -fprofile-arcs -ftest-coverage -rdynamic'
|
||
|
@@ -92,7 +84,6 @@
|
||
|
end
|
||
|
|
||
|
$LDFLAGS << ' -Wl,-wrap,memcpy' if linux
|
||
|
-$LDFLAGS << ' -static-libgcc -static-libstdc++' if linux
|
||
|
$LDFLAGS << ' -static' if windows
|
||
|
|
||
|
$CFLAGS << ' -std=c99 '
|