Skip to content

Commit

Permalink
Merge pull request #1047 from larskanis/win-binary
Browse files Browse the repository at this point in the history
Update fat binary gems for Windows to ruby-3.2 and update libffi
  • Loading branch information
larskanis committed Sep 23, 2023
2 parents 732a559 + 271fdc0 commit 6115dd6
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
6 changes: 4 additions & 2 deletions Rakefile
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion ext/ffi_c/extconf.rb
Expand Up @@ -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']}"
Expand Down
2 changes: 1 addition & 1 deletion ext/ffi_c/libffi.bsd.mk
Expand Up @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions ext/ffi_c/libffi.darwin.mk
Expand Up @@ -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)

Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion ext/ffi_c/libffi.gnu.mk
Expand Up @@ -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)
Expand Down

0 comments on commit 6115dd6

Please sign in to comment.