diff options
author | KJ Tsanaktsidis <kj@kjtsanaktsidis.id.au> | 2023-10-26 20:56:17 +1100 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-10-26 09:56:21 +0000 |
commit | e74ea904ad29931c476b3af493e3ee089f5b4afa (patch) | |
tree | 0eadbe861eb09715b6b0e92da860b457eae1d7c7 /ext | |
parent | 701ca070b4c6fd334543c69e863c40c70178521c (diff) |
[ruby/zlib] Check for z_size_t along with {crc,adler}32_z in
extconf.rb
(https://github.com/ruby/zlib/pull/69)
The android NDK (android-ndk-r21e) does not have crc32_z, adler32_z, nor
z_size_t in its zlib.h header file. However, it _does_ have the crc32_z
and adler32_z symbols in the libz.a static library!
mkmf performs two tests for have_func:
* It sees if a program that includes the header and takes the address of
the symbol can compile
* It sees if a program that defines the symbol as `extern void sym_name()`
and calls it can be linked
If either test works, it considers the function present. The
android-ndk-r21e is passing the second test but not the first for
crc32_z/adler32_z. So, we define HAVE_ZLIB_SIZE_T_FUNCS, but then can't
actually compile the extension (since the prototypes aren't in the
header file).
We can keep this working how it was working before by _also_ checking
for `have_type("z_size_t", "zlib.h")`. The have_type check _only_ looks
in the header file for the type; if a program including the header file
and using the type can't compile, the type is considered absent
regardless of what might be in libz.a.
https://github.com/ruby/zlib/commit/3b9fe962d8
Diffstat (limited to 'ext')
-rw-r--r-- | ext/zlib/extconf.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/ext/zlib/extconf.rb b/ext/zlib/extconf.rb index dd17986d94..2b2dbb1a5b 100644 --- a/ext/zlib/extconf.rb +++ b/ext/zlib/extconf.rb @@ -127,7 +127,9 @@ if have_zlib have_func('crc32_combine', 'zlib.h') have_func('adler32_combine', 'zlib.h') have_type('z_crc_t', 'zlib.h') - if have_func('crc32_z', 'zlib.h') && have_func('adler32_z', 'zlib.h') + if (have_type('z_size_t', 'zlib.h') && + have_func('crc32_z', 'zlib.h') && + have_func('adler32_z', 'zlib.h')) $defs << "-DHAVE_ZLIB_SIZE_T_FUNCS" end end |