Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update fat binary gems for Windows to ruby-3.2 and update libffi #1047

Merged
merged 2 commits into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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