From ad0e4d626a471dff2b98fcbdba1d39b021abf77a Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Thu, 19 Jan 2023 15:40:14 +0100 Subject: [PATCH 1/2] Add more platforms of binary gems (as comment) and ruby-3.2 support --- Rakefile | 6 ++++-- ext/ffi_c/extconf.rb | 8 +++++++- ext/ffi_c/libffi.bsd.mk | 2 +- ext/ffi_c/libffi.darwin.mk | 4 ++-- ext/ffi_c/libffi.gnu.mk | 2 +- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Rakefile b/Rakefile index ce9c46a67..7762d1296 100644 --- a/Rakefile +++ b/Rakefile @@ -86,6 +86,8 @@ task 'gem:java' => 'java:gem' FfiGemHelper.install_tasks # Register windows gems to be pushed to rubygems.org Bundler::GemHelper.instance.cross_platforms = %w[x86-mingw32 x64-mingw-ucrt x64-mingw32] +# These platforms are not yet enabled, since there are issues on musl-based distors (alpine-linux): +# + %w[x86-linux x86_64-linux arm-linux aarch64-linux x86_64-darwin arm64-darwin] if RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx' require 'rake/extensiontask' @@ -120,8 +122,8 @@ namespace "gem" do desc "Build the native gem for #{plat}" task plat => ['prepare', 'build'] do RakeCompilerDock.sh <<-EOT, platform: plat - sudo apt-get update && - sudo apt-get install -y libltdl-dev && bundle --local && + #{ "sudo apt-get update && sudo apt-get install -y libltdl-dev &&" if plat !~ /linux/ } + bundle --local && rake native:#{plat} pkg/#{gem_spec.full_name}-#{plat}.gem MAKE='nice make -j`nproc`' RUBY_CC_VERSION=${RUBY_CC_VERSION/:2.2.2/} EOT end diff --git a/ext/ffi_c/extconf.rb b/ext/ffi_c/extconf.rb index b3eb02017..683a21d65 100755 --- a/ext/ffi_c/extconf.rb +++ b/ext/ffi_c/extconf.rb @@ -75,7 +75,13 @@ def system_libffi_usable? unless system_libffi File.open("Makefile", "a") do |mf| - mf.puts "LIBFFI_HOST=--host=#{RbConfig::CONFIG['host_alias']}" if RbConfig::CONFIG.has_key?("host_alias") + if RbConfig::CONFIG['host_alias'] == "i386-w64-mingw32" + host = "i686-w64-mingw32" # Work around host name without matching compiler name in rake-compiler-dock-1.3.0 on platform x86-mingw32 + elsif RbConfig::CONFIG.has_key?("host_alias") + host = RbConfig::CONFIG['host_alias'] + end + mf.puts "LIBFFI_HOST=--host=#{host}" if host + if RbConfig::CONFIG['host_os'] =~ /darwin/i if RbConfig::CONFIG['host'] =~ /arm|aarch64/i mf.puts "LIBFFI_HOST=--host=aarch64-apple-#{RbConfig::CONFIG['host_os']}" diff --git a/ext/ffi_c/libffi.bsd.mk b/ext/ffi_c/libffi.bsd.mk index ab66256ef..9eaedefe7 100644 --- a/ext/ffi_c/libffi.bsd.mk +++ b/ext/ffi_c/libffi.bsd.mk @@ -18,7 +18,7 @@ INCFLAGS := -I${LIBFFI_BUILD_DIR}/include -I${INCFLAGS} LIBFFI = ${LIBFFI_BUILD_DIR}/.libs/libffi_convenience.a LIBFFI_AUTOGEN = ${LIBFFI_SRC_DIR}/autogen.sh -LIBFFI_CONFIGURE = ${LIBFFI_SRC_DIR}/configure --disable-static \ +LIBFFI_CONFIGURE = ${LIBFFI_SRC_DIR}/configure --disable-shared --enable-static \ --with-pic=yes --disable-dependency-tracking --disable-docs $(OBJS): ${LIBFFI} diff --git a/ext/ffi_c/libffi.darwin.mk b/ext/ffi_c/libffi.darwin.mk index 893a8e17a..a6b28d98e 100644 --- a/ext/ffi_c/libffi.darwin.mk +++ b/ext/ffi_c/libffi.darwin.mk @@ -37,7 +37,7 @@ $(LIBFFI): echo "Configuring libffi"; \ cd "$(LIBFFI_BUILD_DIR)" && \ /usr/bin/env CC="$(CC)" LD="$(LD)" CFLAGS="$(LIBFFI_CFLAGS)" GREP_OPTIONS="" \ - /bin/sh $(LIBFFI_CONFIGURE) $(LIBFFI_HOST) > /dev/null; \ + /bin/sh $(LIBFFI_CONFIGURE) $(LIBFFI_HOST) --disable-shared --enable-static > /dev/null; \ fi cd "$(LIBFFI_BUILD_DIR)" && $(MAKE) @@ -56,7 +56,7 @@ build_ffi = \ echo "Configuring libffi for $(1)"; \ cd "$(BUILD_DIR)"/libffi-$(1) && \ env CC="$(CCACHE) $(CC)" CFLAGS="-arch $(1) $(LIBFFI_CFLAGS)" LDFLAGS="-arch $(1)" \ - $(LIBFFI_CONFIGURE) --host=$(1)-apple-darwin > /dev/null; \ + $(LIBFFI_CONFIGURE) --host=$(1)-apple-darwin --disable-shared --enable-static > /dev/null; \ fi); \ $(MAKE) -C "$(BUILD_DIR)"/libffi-$(1) diff --git a/ext/ffi_c/libffi.gnu.mk b/ext/ffi_c/libffi.gnu.mk index 473b8fb9d..9078bab54 100644 --- a/ext/ffi_c/libffi.gnu.mk +++ b/ext/ffi_c/libffi.gnu.mk @@ -21,7 +21,7 @@ endif LIBFFI = "$(LIBFFI_BUILD_DIR)"/.libs/libffi_convenience.a LIBFFI_AUTOGEN = ${LIBFFI_SRC_DIR}/autogen.sh -LIBFFI_CONFIGURE = "$(LIBFFI_SRC_DIR)"/configure --disable-static \ +LIBFFI_CONFIGURE = "$(LIBFFI_SRC_DIR)"/configure --disable-shared --enable-static \ --with-pic=yes --disable-dependency-tracking --disable-docs $(OBJS): $(LIBFFI) From 271fdc06f02df7fc51e0547aaeddbb8584558705 Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Sat, 23 Sep 2023 22:29:37 +0200 Subject: [PATCH 2/2] Update to latest libffi --- ext/ffi_c/libffi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/ffi_c/libffi b/ext/ffi_c/libffi index ac598b7f5..5c6e53db8 160000 --- a/ext/ffi_c/libffi +++ b/ext/ffi_c/libffi @@ -1 +1 @@ -Subproject commit ac598b7f5272d536b75f4b3833a4610cf4cd9404 +Subproject commit 5c6e53db873767cd2266745cebc62551958f5bee