Skip to content

Commit 01da5ed

Browse files
committed
fix(build): resolve Windows DLL loading and GLIBC compatibility issues
- Add libiconv as static library dependency to fix Windows Error 126 (missing libiconv-2.dll dependency) - Update Linux glibc builds to use ubuntu-22.04 for GLIBC 2.35 compatibility - Fix CMake flag typos (:: to :) for ENABLE_ZLIB, ENABLE_EXPAT, ENABLE_LZO, ENABLE_CPIO - Update inspection steps to fail if no compiled libraries found - Fix workflow library detection to handle multiple file types correctly closes #35, closes #38
1 parent f3c0658 commit 01da5ed

11 files changed

Lines changed: 122 additions & 27 deletions

File tree

.github/platforms.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"linux_x86_64": [
5757
{
5858
"platform": "x86_64-linux",
59-
"os": "ubuntu-latest",
59+
"os": "ubuntu-22.04",
6060
"ruby": "3.4",
6161
"description": "Linux x86_64 (generic)",
6262
"build": true,
@@ -65,7 +65,7 @@
6565
},
6666
{
6767
"platform": "x86_64-linux-gnu",
68-
"os": "ubuntu-latest",
68+
"os": "ubuntu-22.04",
6969
"ruby": "3.4",
7070
"description": "Linux x86_64 GNU libc",
7171
"build": true,
@@ -83,7 +83,7 @@
8383
"linux_aarch64": [
8484
{
8585
"platform": "aarch64-linux",
86-
"os": "ubuntu-latest",
86+
"os": "ubuntu-22.04",
8787
"ruby": "3.4",
8888
"description": "Linux ARM64 (generic)",
8989
"build": true,
@@ -93,7 +93,7 @@
9393
},
9494
{
9595
"platform": "aarch64-linux-gnu",
96-
"os": "ubuntu-latest",
96+
"os": "ubuntu-22.04",
9797
"ruby": "3.4",
9898
"description": "Linux ARM64 GNU libc",
9999
"build": true,

.github/workflows/gem-build.yml

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,32 @@ jobs:
8888
8989
- run: bundle exec rake gem:native:${{ matrix.platform }}
9090

91-
# Display compiled libraries for debugging
91+
# Display compiled libraries for debugging - MUST FAIL if none found
9292
- name: Inspect built libraries
9393
if: matrix.platform != 'any'
9494
shell: bash
9595
run: |
9696
echo "=== Platform: ${{ matrix.platform }} ==="
9797
echo "=== Compiled libraries ==="
98-
ls lib/ffi-libarchive-binary/*.dll lib/ffi-libarchive-binary/*.so lib/ffi-libarchive-binary/*.dylib 2>/dev/null || echo "No compiled libraries found"
98+
FOUND=0
99+
for ext in dll so dylib; do
100+
for f in lib/ffi-libarchive-binary/*.$ext; do
101+
if [ -f "$f" ]; then
102+
echo "$f"
103+
FOUND=1
104+
fi
105+
done
106+
done
107+
if [ "$FOUND" -eq 0 ]; then
108+
echo "ERROR: No compiled libraries found!"
109+
echo "=== Library directory contents ==="
110+
ls -la lib/ffi-libarchive-binary/ 2>/dev/null || echo "Directory not found"
111+
exit 1
112+
fi
99113
echo "=== Library directory contents ==="
100-
ls -la lib/ffi-libarchive-binary/ 2>/dev/null || echo "Directory not found"
114+
ls -la lib/ffi-libarchive-binary/
101115
102-
# Unpack gem and display contents
116+
# Unpack gem and verify it contains compiled libraries - MUST FAIL if none found
103117
- name: Inspect gem contents
104118
shell: bash
105119
run: |
@@ -108,7 +122,17 @@ jobs:
108122
echo "=== Files in gem ==="
109123
ls -R */lib/ 2>/dev/null | head -50
110124
echo "=== Compiled libraries in gem ==="
111-
ls */lib/ffi-libarchive-binary/*.dll */lib/ffi-libarchive-binary/*.so */lib/ffi-libarchive-binary/*.dylib 2>/dev/null || echo "No compiled libraries found in gem"
125+
FOUND=0
126+
for ext in dll so dylib; do
127+
for f in $(find . -name "*.$ext" 2>/dev/null); do
128+
echo "$f"
129+
FOUND=1
130+
done
131+
done
132+
if [ "$FOUND" -eq 0 ] && [ "${{ matrix.platform }}" != "any" ]; then
133+
echo "ERROR: No compiled libraries found in gem!"
134+
exit 1
135+
fi
112136
113137
- uses: actions/upload-artifact@v6
114138
if: failure()

.github/workflows/test.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,29 @@ jobs:
7777
name: ${{ github.run_number }}-${{ matrix.platform }}-pkg
7878
path: pkg
7979

80-
# Unpack gem and display compiled libraries for debugging
80+
# Unpack gem and display compiled libraries for debugging - MUST FAIL if none found
8181
- name: Inspect gem contents
8282
shell: bash
8383
run: |
8484
cd pkg
8585
gem unpack ffi-libarchive-binary-*.gem
8686
echo "=== Platform: ${{ matrix.platform }} ==="
8787
echo "=== Compiled libraries in gem ==="
88-
ls */lib/ffi-libarchive-binary/*.dll */lib/ffi-libarchive-binary/*.so */lib/ffi-libarchive-binary/*.dylib 2>/dev/null || echo "No compiled libraries found in gem"
88+
FOUND=0
89+
for ext in dll so dylib; do
90+
for f in $(find . -name "*.$ext" 2>/dev/null); do
91+
echo "$f"
92+
FOUND=1
93+
done
94+
done
95+
if [ "$FOUND" -eq 0 ]; then
96+
echo "ERROR: No compiled libraries found in gem!"
97+
echo "=== Full lib directory contents ==="
98+
ls -la */lib/ffi-libarchive-binary/ 2>/dev/null || echo "Directory not found"
99+
exit 1
100+
fi
89101
echo "=== Full lib directory contents ==="
90-
ls -la */lib/ffi-libarchive-binary/ 2>/dev/null || echo "Directory not found"
102+
ls -la */lib/ffi-libarchive-binary/
91103
92104
# Install the native gem
93105
- name: Install native gem

ext/configuration.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ libraries:
44
# - OpenSSL uses version 1.1.1w for Windows x64 (more stable for x86_64)
55
# - xz uses version 5.2.4 for all Windows platforms (MinGW compatibility)
66
# - Other libraries use cross-platform versions under 'all'
7+
libiconv:
8+
all:
9+
version: "1.18"
10+
url: "https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.18.tar.gz"
11+
sha256: "3b08f5f4f9b4eb82f151a7040bfd6fe6c6fb922efe4b1659c66ea933276965e8"
712
zlib:
813
all:
914
version: "1.3.2"

lib/ffi-libarchive-binary/configuration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def self.libraries
2020
def self.library_for(libname)
2121
if MiniPortile::windows?
2222
# Detect Windows ARM64
23-
if RUBY_PLATFORM =~ /aarch64|arm64/i
23+
if RUBY_PLATFORM.match?(/aarch64|arm64/i)
2424
libraries[libname]["windows-arm64"] || libraries[libname]["windows"] || libraries[libname]["all"]
2525
else
2626
libraries[libname]["windows-x64"] || libraries[libname]["windows"] || libraries[libname]["all"]

lib/ffi-libarchive-binary/libarchive_recipe.rb

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
require_relative "base_recipe"
88
require_relative "zlib_recipe"
99
require_relative "libexpat_recipe"
10+
require_relative "libiconv_recipe"
1011
require_relative "openssl_recipe"
1112
require_relative "xz_recipe"
1213

@@ -32,6 +33,7 @@ def initialize
3233
def create_dependencies
3334
@zlib_recipe = ZLibRecipe.new
3435
@expat_recipe = LibexpatRecipe.new
36+
@iconv_recipe = LibiconvRecipe.new
3537
@openssl_recipe = OpensslRecipe.new
3638
@xz_recipe = XZRecipe.new
3739
end
@@ -42,18 +44,22 @@ def generator_flags
4244

4345
def default_flags
4446
[
45-
"-DENABLE_OPENSSL:BOOL=ON", "-DENABLE_LIBB2:BOOL=OFF", "-DENABLE_LZ4:BOOL=OFF",
46-
"-DENABLE_LZO::BOOL=OFF", "-DENABLE_LZMA:BOOL=ON", "-DENABLE_ZSTD:BOOL=OFF",
47-
"-DENABLE_ZLIB::BOOL=ON", "-DENABLE_BZip2:BOOL=OFF", "-DENABLE_LIBXML2:BOOL=OFF",
48-
"-DENABLE_EXPAT::BOOL=ON", "-DENABLE_TAR:BOOL=OFF", "-DENABLE_CPIO::BOOL=OFF",
47+
"-DENABLE_OPENSSL:BOOL=ON", "-DENABLE_LIBB2:BOOL=OFF", "-DENABLE_LZ4:BOOL=OFF",
48+
"-DENABLE_LZO:BOOL=OFF", "-DENABLE_LZMA:BOOL=ON", "-DENABLE_ZSTD:BOOL=OFF",
49+
"-DENABLE_ZLIB:BOOL=ON", "-DENABLE_BZip2:BOOL=OFF", "-DENABLE_LIBXML2:BOOL=OFF",
50+
"-DENABLE_EXPAT:BOOL=ON", "-DENABLE_TAR:BOOL=OFF", "-DENABLE_CPIO:BOOL=OFF",
4951
"-DENABLE_CAT:BOOL=OFF", "-DENABLE_ACL:BOOL=OFF", "-DENABLE_TEST:BOOL=OFF",
5052
"-DENABLE_UNZIP:BOOL=OFF", "-DOPENSSL_USE_STATIC_LIBS=ON", "-DENABLE_XAR:BOOL=ON",
5153

5254
# Provide root directories - let CMake find libraries in lib or lib64
5355
"-DOPENSSL_ROOT_DIR:PATH=#{@openssl_recipe.path}",
5456

5557
# Add include paths to C flags so CMake's header detection can find them
56-
"-DCMAKE_C_FLAGS=-I#{@expat_recipe.path}/include -I#{@openssl_recipe.path}/include -I#{@xz_recipe.path}/include -I#{@zlib_recipe.path}/include",
58+
"-DCMAKE_C_FLAGS=-I#{@expat_recipe.path}/include " \
59+
"-I#{@iconv_recipe.path}/include " \
60+
"-I#{@openssl_recipe.path}/include " \
61+
"-I#{@xz_recipe.path}/include " \
62+
"-I#{@zlib_recipe.path}/include",
5763

5864
# Provide search paths for CMake to find libraries
5965
"-DCMAKE_INCLUDE_PATH:STRING=#{include_path}",
@@ -71,18 +77,19 @@ def configure_defaults
7177
end
7278

7379
def include_path
74-
paths = [@zlib_recipe.path, @expat_recipe.path, @openssl_recipe.path, @xz_recipe.path]
80+
paths = [@zlib_recipe.path, @expat_recipe.path, @iconv_recipe.path, @openssl_recipe.path, @xz_recipe.path]
7581
paths.map { |k| "#{k}/include" }.join(";")
7682
end
7783

7884
def library_path
79-
paths = [@zlib_recipe.path, @expat_recipe.path, @openssl_recipe.path, @xz_recipe.path]
85+
paths = [@zlib_recipe.path, @expat_recipe.path, @iconv_recipe.path, @openssl_recipe.path, @xz_recipe.path]
8086
paths.map { |k| "#{k}/lib;#{k}/lib64" }.join(";")
8187
end
8288

8389
def activate
8490
@zlib_recipe.activate
8591
@expat_recipe.activate
92+
@iconv_recipe.activate
8693
@openssl_recipe.activate
8794
@xz_recipe.activate
8895

@@ -100,15 +107,18 @@ def cook
100107
@expat_recipe.host = @host if @host
101108
@expat_recipe.cook_if_not
102109

110+
@iconv_recipe.host = @host if @host
111+
@iconv_recipe.cook_if_not
112+
103113
@openssl_recipe.host = @host if @host
104114
@openssl_recipe.cook_if_not
105115

106116
@xz_recipe.host = @host if @host
107117
@xz_recipe.cook_if_not
108118

109119
# Set explicit LZMA environment variables for libarchive configure
110-
ENV['LIBLZMA_CFLAGS'] = "-I#{@xz_recipe.path}/include"
111-
ENV['LIBLZMA_LIBS'] = "-L#{@xz_recipe.path}/lib -llzma"
120+
ENV["LIBLZMA_CFLAGS"] = "-I#{@xz_recipe.path}/include"
121+
ENV["LIBLZMA_LIBS"] = "-L#{@xz_recipe.path}/lib -llzma"
112122

113123
super
114124

lib/ffi-libarchive-binary/libexpat_recipe.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def configure
2121
# Set cross-compiler environment variables for aarch64
2222
env_vars = cross_compiler_env(host)
2323
cmd = ["env"] + env_vars.map { |k, v| "#{k}=#{v}" } +
24-
[cflags(host), ldflags(host), "./configure"] + computed_options
24+
[cflags(host), ldflags(host), "./configure"] + computed_options
2525
execute("configure", cmd)
2626
end
2727

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# frozen_string_literal: true
2+
3+
require_relative "base_recipe"
4+
5+
module LibarchiveBinary
6+
class LibiconvRecipe < BaseRecipe
7+
def initialize
8+
super("libiconv")
9+
10+
@target = ROOT.join(@target).to_s
11+
end
12+
13+
def configure_defaults
14+
[
15+
"--host=#{@host}",
16+
"--disable-shared",
17+
"--enable-static",
18+
"--disable-nls",
19+
]
20+
end
21+
22+
def configure
23+
# Set cross-compiler environment variables for aarch64
24+
env_vars = cross_compiler_env(host)
25+
cmd = ["env"] + env_vars.map { |k, v| "#{k}=#{v}" } +
26+
[cflags(host), ldflags(host), "./configure"] + computed_options
27+
execute("configure", cmd)
28+
end
29+
30+
def checkpoint
31+
File.join(@target, "#{name}-#{version}-#{host}.installed")
32+
end
33+
34+
def cook_if_not
35+
cook unless File.exist?(checkpoint)
36+
end
37+
38+
def cook
39+
super
40+
41+
FileUtils.touch(checkpoint)
42+
end
43+
end
44+
end

lib/ffi-libarchive-binary/libxml2_recipe.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def configure_defaults
2828
"--without-http",
2929
"--without-ftp",
3030
"--enable-static",
31-
"--disable-shared"
31+
"--disable-shared",
3232
]
3333
end
3434

@@ -52,4 +52,4 @@ def cook
5252
FileUtils.touch(checkpoint)
5353
end
5454
end
55-
end
55+
end

lib/ffi-libarchive-binary/xz_recipe.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def configure
2121
# Set cross-compiler environment variables for aarch64
2222
env_vars = cross_compiler_env(host)
2323
cmd = ["env"] + env_vars.map { |k, v| "#{k}=#{v}" } +
24-
[cflags(host), ldflags(host), "./configure"] + computed_options
24+
[cflags(host), ldflags(host), "./configure"] + computed_options
2525
execute("configure", cmd)
2626
end
2727

0 commit comments

Comments
 (0)