From 42d107cce5ba3aab80e35a1a8c048819eda4db11 Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith" Date: Tue, 22 Mar 2022 01:32:27 -0700 Subject: [PATCH 01/30] Make zlib required instead of optional. This simplifies code by removing a pile of conditionals and alternative logic. Further simplification could be done in `Modules/binascii.c` to simply have binascii.crc32 be a reference to zlib.crc32. Also the conditional logic around zlib inflaceCopy existing and `HAVE_ZLIB_COPY` can likely be removed as that API was added to zlib in 2003. The Windows build already treats zlib as required. --- Lib/distutils/tests/test_archive_util.py | 44 +------ Lib/distutils/tests/test_bdist_dumb.py | 9 +- Lib/distutils/tests/test_bdist_rpm.py | 4 +- Lib/distutils/tests/test_sdist.py | 16 +-- Lib/encodings/zlib_codec.py | 2 +- Lib/shutil.py | 22 +--- Lib/tarfile.py | 16 +-- Lib/test/pythoninfo.py | 7 +- Lib/test/test_codecs.py | 12 +- Lib/test/test_importlib/fixtures.py | 2 - Lib/test/test_logging.py | 7 +- Lib/test/test_sqlite3/test_types.py | 6 +- Lib/test/test_tarfile.py | 12 +- Lib/test/test_venv.py | 3 +- Lib/test/test_zipapp.py | 2 - Lib/test/test_zipfile.py | 11 +- Lib/test/test_zipfile64.py | 2 - Lib/test/test_zipimport.py | 6 +- Lib/zipfile.py | 15 +-- Lib/zipimport.py | 7 +- Modules/Setup.bootstrap.in | 2 + Modules/Setup.stdlib.in | 3 +- Modules/binascii.c | 160 +---------------------- PCbuild/pythoncore.vcxproj | 4 +- aclocal.m4 | 82 +----------- configure | 50 +++---- configure.ac | 31 ++--- pyconfig.h.in | 3 +- setup.py | 7 +- 29 files changed, 85 insertions(+), 462 deletions(-) diff --git a/Lib/distutils/tests/test_archive_util.py b/Lib/distutils/tests/test_archive_util.py index 8aec84078ed48f..fd8a96906ade65 100644 --- a/Lib/distutils/tests/test_archive_util.py +++ b/Lib/distutils/tests/test_archive_util.py @@ -30,11 +30,7 @@ except ImportError: ZIP_SUPPORT = find_executable('zip') -try: - import zlib - ZLIB_SUPPORT = True -except ImportError: - ZLIB_SUPPORT = False +import zlib try: import bz2 @@ -63,7 +59,6 @@ class ArchiveUtilTestCase(support.TempdirManager, support.LoggingSilencer, unittest.TestCase): - @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run') def test_make_tarball(self, name='archive'): # creating something to tar tmpdir = self._create_files() @@ -71,7 +66,6 @@ def test_make_tarball(self, name='archive'): # trying an uncompressed one self._make_tarball(tmpdir, name, '.tar', compress=None) - @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run') def test_make_tarball_gzip(self): tmpdir = self._create_files() self._make_tarball(tmpdir, 'archive', '.tar.gz', compress='gzip') @@ -144,9 +138,8 @@ def _create_files(self): os.mkdir(os.path.join(dist, 'sub2')) return tmpdir - @unittest.skipUnless(find_executable('tar') and find_executable('gzip') - and ZLIB_SUPPORT, - 'Need the tar, gzip and zlib command to run') + @unittest.skipUnless(find_executable('tar') and find_executable('gzip'), + 'Need the tar and gzip commands to run') def test_tarfile_vs_tar(self): tmpdir = self._create_files() tmpdir2 = self.mkdtemp() @@ -234,8 +227,7 @@ def test_compress_deprecated(self): self.assertFalse(os.path.exists(tarball)) self.assertEqual(len(w.warnings), 1) - @unittest.skipUnless(ZIP_SUPPORT and ZLIB_SUPPORT, - 'Need zip and zlib support to run') + @unittest.skipUnless(ZIP_SUPPORT, 'Need zip support to run') def test_make_zipfile(self): # creating something to tar tmpdir = self._create_files() @@ -249,32 +241,6 @@ def test_make_zipfile(self): with zipfile.ZipFile(tarball) as zf: self.assertEqual(sorted(zf.namelist()), self._zip_created_files) - @unittest.skipUnless(ZIP_SUPPORT, 'Need zip support to run') - def test_make_zipfile_no_zlib(self): - patch(self, archive_util.zipfile, 'zlib', None) # force zlib ImportError - - called = [] - zipfile_class = zipfile.ZipFile - def fake_zipfile(*a, **kw): - if kw.get('compression', None) == zipfile.ZIP_STORED: - called.append((a, kw)) - return zipfile_class(*a, **kw) - - patch(self, archive_util.zipfile, 'ZipFile', fake_zipfile) - - # create something to tar and compress - tmpdir = self._create_files() - base_name = os.path.join(self.mkdtemp(), 'archive') - with change_cwd(tmpdir): - make_zipfile(base_name, 'dist') - - tarball = base_name + '.zip' - self.assertEqual(called, - [((tarball, "w"), {'compression': zipfile.ZIP_STORED})]) - self.assertTrue(os.path.exists(tarball)) - with zipfile.ZipFile(tarball) as zf: - self.assertEqual(sorted(zf.namelist()), self._zip_created_files) - def test_check_archive_formats(self): self.assertEqual(check_archive_formats(['gztar', 'xxx', 'zip']), 'xxx') @@ -308,7 +274,6 @@ def test_make_archive_tar(self): self.assertEqual(os.path.basename(res), 'archive.tar') self.assertEqual(self._tarinfo(res), self._created_files) - @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run') def test_make_archive_gztar(self): base_dir = self._create_files() base_name = os.path.join(self.mkdtemp() , 'archive') @@ -362,7 +327,6 @@ def test_make_archive_owner_group(self): owner='kjhkjhkjg', group='oihohoh') self.assertTrue(os.path.exists(res)) - @unittest.skipUnless(ZLIB_SUPPORT, "Requires zlib") @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support") def test_tarfile_root_owner(self): tmpdir = self._create_files() diff --git a/Lib/distutils/tests/test_bdist_dumb.py b/Lib/distutils/tests/test_bdist_dumb.py index bb860c8ac70345..181ea6fd20256c 100644 --- a/Lib/distutils/tests/test_bdist_dumb.py +++ b/Lib/distutils/tests/test_bdist_dumb.py @@ -2,8 +2,9 @@ import os import sys -import zipfile import unittest +import zipfile +import zlib from test.support import run_unittest from distutils.core import Distribution @@ -19,11 +20,6 @@ """ -try: - import zlib - ZLIB_SUPPORT = True -except ImportError: - ZLIB_SUPPORT = False class BuildDumbTestCase(support.TempdirManager, @@ -42,7 +38,6 @@ def tearDown(self): sys.argv[:] = self.old_sys_argv[1] super(BuildDumbTestCase, self).tearDown() - @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run') def test_simple_built(self): # let's create a simple package diff --git a/Lib/distutils/tests/test_bdist_rpm.py b/Lib/distutils/tests/test_bdist_rpm.py index f1eb9ba4493828..f3743900ae87b6 100644 --- a/Lib/distutils/tests/test_bdist_rpm.py +++ b/Lib/distutils/tests/test_bdist_rpm.py @@ -3,7 +3,7 @@ import unittest import sys import os -from test.support import run_unittest, requires_zlib +from test.support import run_unittest from distutils.core import Distribution from distutils.command.bdist_rpm import bdist_rpm @@ -44,7 +44,6 @@ def tearDown(self): # spurious sdtout/stderr output under Mac OS X @unittest.skipUnless(sys.platform.startswith('linux'), 'spurious sdtout/stderr output under Mac OS X') - @requires_zlib() @unittest.skipIf(find_executable('rpm') is None, 'the rpm command is not found') @unittest.skipIf(find_executable('rpmbuild') is None, @@ -87,7 +86,6 @@ def test_quiet(self): # spurious sdtout/stderr output under Mac OS X @unittest.skipUnless(sys.platform.startswith('linux'), 'spurious sdtout/stderr output under Mac OS X') - @requires_zlib() # http://bugs.python.org/issue1533164 @unittest.skipIf(find_executable('rpm') is None, 'the rpm command is not found') diff --git a/Lib/distutils/tests/test_sdist.py b/Lib/distutils/tests/test_sdist.py index 46b3a13e470c4e..e75916debb4114 100644 --- a/Lib/distutils/tests/test_sdist.py +++ b/Lib/distutils/tests/test_sdist.py @@ -4,17 +4,12 @@ import unittest import warnings import zipfile +import zlib from os.path import join from textwrap import dedent from test.support import captured_stdout, run_unittest from test.support.warnings_helper import check_warnings -try: - import zlib - ZLIB_SUPPORT = True -except ImportError: - ZLIB_SUPPORT = False - try: import grp import pwd @@ -88,7 +83,6 @@ def get_cmd(self, metadata=None): cmd.dist_dir = 'dist' return dist, cmd - @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run') def test_prune_file_list(self): # this test creates a project with some VCS dirs and an NFS rename # file, then launches sdist to check they get pruned on all systems @@ -133,7 +127,6 @@ def test_prune_file_list(self): 'somecode/', 'somecode/__init__.py'] self.assertEqual(sorted(content), ['fake-1.0/' + x for x in expected]) - @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run') @unittest.skipIf(find_executable('tar') is None, "The tar command is not found") @unittest.skipIf(find_executable('gzip') is None, @@ -166,7 +159,6 @@ def test_make_distribution(self): result.sort() self.assertEqual(result, ['fake-1.0.tar', 'fake-1.0.tar.gz']) - @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run') def test_add_defaults(self): # http://bugs.python.org/issue2279 @@ -245,7 +237,6 @@ def test_add_defaults(self): f.close() self.assertEqual(manifest, MANIFEST % {'sep': os.sep}) - @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run') def test_metadata_check_option(self): # testing the `medata-check` option dist, cmd = self.get_cmd(metadata={}) @@ -332,7 +323,6 @@ def test_invalid_template_wrong_path(self): # this used to crash instead of raising a warning: #8286 self._check_template('include examples/') - @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run') def test_get_file_list(self): # make sure MANIFEST is recalculated dist, cmd = self.get_cmd() @@ -374,7 +364,6 @@ def test_get_file_list(self): self.assertEqual(len(manifest2), 6) self.assertIn('doc2.txt', manifest2[-1]) - @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run') def test_manifest_marker(self): # check that autogenerated MANIFESTs have a marker dist, cmd = self.get_cmd() @@ -391,7 +380,6 @@ def test_manifest_marker(self): self.assertEqual(manifest[0], '# file GENERATED by distutils, do NOT edit') - @unittest.skipUnless(ZLIB_SUPPORT, "Need zlib support to run") def test_manifest_comments(self): # make sure comments don't cause exceptions or wrong includes contents = dedent("""\ @@ -408,7 +396,6 @@ def test_manifest_comments(self): cmd.run() self.assertEqual(cmd.filelist.files, ['good.py']) - @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run') def test_manual_manifest(self): # check that a MANIFEST without a marker is left alone dist, cmd = self.get_cmd() @@ -438,7 +425,6 @@ def test_manual_manifest(self): self.assertEqual(sorted(filenames), ['fake-1.0', 'fake-1.0/PKG-INFO', 'fake-1.0/README.manual']) - @unittest.skipUnless(ZLIB_SUPPORT, "requires zlib") @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support") @unittest.skipIf(find_executable('tar') is None, "The tar command is not found") diff --git a/Lib/encodings/zlib_codec.py b/Lib/encodings/zlib_codec.py index 95908a4b4a13a1..25acfba1c01483 100644 --- a/Lib/encodings/zlib_codec.py +++ b/Lib/encodings/zlib_codec.py @@ -6,7 +6,7 @@ """ import codecs -import zlib # this codec needs the optional zlib module ! +import zlib ### Codec APIs diff --git a/Lib/shutil.py b/Lib/shutil.py index 22bd86d569e7ed..1c0945837cd601 100644 --- a/Lib/shutil.py +++ b/Lib/shutil.py @@ -10,13 +10,7 @@ import fnmatch import collections import errno - -try: - import zlib - del zlib - _ZLIB_SUPPORTED = True -except ImportError: - _ZLIB_SUPPORTED = False +import zlib try: import bz2 @@ -911,7 +905,7 @@ def _make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0, """ if compress is None: tar_compression = '' - elif _ZLIB_SUPPORTED and compress == 'gzip': + elif compress == 'gzip': tar_compression = 'gz' elif _BZ2_SUPPORTED and compress == 'bzip2': tar_compression = 'bz2' @@ -1006,10 +1000,9 @@ def _make_zipfile(base_name, base_dir, verbose=0, dry_run=0, logger=None): 'tar': (_make_tarball, [('compress', None)], "uncompressed tar file"), } -if _ZLIB_SUPPORTED: - _ARCHIVE_FORMATS['gztar'] = (_make_tarball, [('compress', 'gzip')], - "gzip'ed tar-file") - _ARCHIVE_FORMATS['zip'] = (_make_zipfile, [], "ZIP file") +_ARCHIVE_FORMATS['gztar'] = (_make_tarball, [('compress', 'gzip')], + "gzip'ed tar-file") +_ARCHIVE_FORMATS['zip'] = (_make_zipfile, [], "ZIP file") if _BZ2_SUPPORTED: _ARCHIVE_FORMATS['bztar'] = (_make_tarball, [('compress', 'bzip2')], @@ -1217,12 +1210,9 @@ def _unpack_tarfile(filename, extract_dir): _UNPACK_FORMATS = { 'tar': (['.tar'], _unpack_tarfile, [], "uncompressed tar file"), 'zip': (['.zip'], _unpack_zipfile, [], "ZIP file"), + 'gztar': (['.tar.gz', '.tgz'], _unpack_tarfile, [], "gzip'ed tar-file"), } -if _ZLIB_SUPPORTED: - _UNPACK_FORMATS['gztar'] = (['.tar.gz', '.tgz'], _unpack_tarfile, [], - "gzip'ed tar-file") - if _BZ2_SUPPORTED: _UNPACK_FORMATS['bztar'] = (['.tar.bz2', '.tbz2'], _unpack_tarfile, [], "bzip2'ed tar-file") diff --git a/Lib/tarfile.py b/Lib/tarfile.py index 8d43d0da7b9880..f96be649fbe5d0 100755 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -361,10 +361,7 @@ def __init__(self, name, mode, comptype, fileobj, bufsize): try: if comptype == "gz": - try: - import zlib - except ImportError: - raise CompressionError("zlib module is not available") from None + import zlib self.zlib = zlib self.crc = zlib.crc32(b"") if mode == "r": @@ -2359,13 +2356,10 @@ def next(self): except SubsequentHeaderError as e: raise ReadError(str(e)) from None except Exception as e: - try: - import zlib - if isinstance(e, zlib.error): - raise ReadError(f'zlib error: {e}') from None - else: - raise e - except ImportError: + import zlib + if isinstance(e, zlib.error): + raise ReadError(f'zlib error: {e}') from None + else: raise e break diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py index d15a11c80b649a..f2d6dd6ce87ebc 100644 --- a/Lib/test/pythoninfo.py +++ b/Lib/test/pythoninfo.py @@ -1,7 +1,6 @@ """ Collect various information about Python to help debugging test failures. """ -from __future__ import print_function import errno import re import sys @@ -558,11 +557,7 @@ def collect_sqlite(info_add): def collect_zlib(info_add): - try: - import zlib - except ImportError: - return - + import zlib attributes = ('ZLIB_VERSION', 'ZLIB_RUNTIME_VERSION') copy_attributes(info_add, zlib, 'zlib.%s', attributes) diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py index 5853e088197153..8b4ec2bbc30a3f 100644 --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -2700,13 +2700,10 @@ def test_seek0(self): "rot_13": ["rot13"], } -try: - import zlib -except ImportError: - zlib = None -else: - bytes_transform_encodings.append("zlib_codec") - transform_aliases["zlib_codec"] = ["zip", "zlib"] +import zlib +bytes_transform_encodings.append("zlib_codec") +transform_aliases["zlib_codec"] = ["zip", "zlib"] + try: import bz2 except ImportError: @@ -2807,7 +2804,6 @@ def test_binary_to_text_denylists_text_transforms(self): bad_input.decode("rot_13") self.assertIsNone(failure.exception.__cause__) - @unittest.skipUnless(zlib, "Requires zlib support") def test_custom_zlib_error_is_wrapped(self): # Check zlib codec gives a good error for malformed input msg = "^decoding with 'zlib_codec' codec failed" diff --git a/Lib/test/test_importlib/fixtures.py b/Lib/test/test_importlib/fixtures.py index 803d3738d263f4..df66ab316272db 100644 --- a/Lib/test/test_importlib/fixtures.py +++ b/Lib/test/test_importlib/fixtures.py @@ -8,7 +8,6 @@ import contextlib from test.support.os_helper import FS_NONASCII -from test.support import requires_zlib from typing import Dict, Union try: @@ -281,7 +280,6 @@ def find_module(self, name): pass -@requires_zlib() class ZipFixtures: root = 'test.test_importlib.data' diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index be193dcdacf4f0..a03262d5b2fb68 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -70,10 +70,8 @@ except ImportError: win32evtlog = win32evtlogutil = pywintypes = None -try: - import zlib -except ImportError: - pass +import zlib + class BaseTest(unittest.TestCase): @@ -5311,7 +5309,6 @@ def rotator(self, source, dest): self.assertFalse(os.path.exists(rh.namer(self.fn + ".1"))) rh.close() - @support.requires_zlib() def test_rotator(self): def namer(name): return name + ".gz" diff --git a/Lib/test/test_sqlite3/test_types.py b/Lib/test/test_sqlite3/test_types.py index 0cfb72c5f0999e..def4dc7fcd64c1 100644 --- a/Lib/test/test_sqlite3/test_types.py +++ b/Lib/test/test_sqlite3/test_types.py @@ -24,10 +24,7 @@ import unittest import sqlite3 as sqlite import sys -try: - import zlib -except ImportError: - zlib = None +import zlib from test import support @@ -466,7 +463,6 @@ def test_adapt_alt(self): self.assertEqual(alt, sqlite.adapt(1., None, alt)) -@unittest.skipUnless(zlib, "requires zlib") class BinaryConverterTests(unittest.TestCase): def convert(s): return zlib.decompress(s) diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py index 12850cd635e995..6980fbf8e7644f 100644 --- a/Lib/test/test_tarfile.py +++ b/Lib/test/test_tarfile.py @@ -15,14 +15,8 @@ from test.support import script_helper # Check for our compression modules. -try: - import gzip -except ImportError: - gzip = None -try: - import zlib -except ImportError: - zlib = None +import gzip +import zlib try: import bz2 except ImportError: @@ -62,7 +56,6 @@ class TarTest: def mode(self): return self.prefix + self.suffix -@support.requires_gzip() class GzipTest: tarname = gzipname suffix = 'gz' @@ -722,7 +715,6 @@ def test_parallel_iteration(self): self.assertEqual(m1.offset, m2.offset) self.assertEqual(m1.get_info(), m2.get_info()) - @unittest.skipIf(zlib is None, "requires zlib") def test_zlib_error_does_not_leak(self): # bpo-39039: tarfile.open allowed zlib exceptions to bubble up when # parsing certain types of invalid data diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py index db812f21dbc562..f1d2467a55fab3 100644 --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -14,7 +14,7 @@ import subprocess import sys import tempfile -from test.support import (captured_stdout, captured_stderr, requires_zlib, +from test.support import (captured_stdout, captured_stderr, skip_if_broken_multiprocessing_synchronize, verbose, requires_subprocess) from test.support.os_helper import (can_symlink, EnvironmentVarGuard, rmtree) @@ -596,7 +596,6 @@ def do_test_with_pip(self, system_site_packages): # Issue #26610: pip/pep425tags.py requires ctypes @unittest.skipUnless(ctypes, 'pip requires ctypes') - @requires_zlib() def test_with_pip(self): self.do_test_with_pip(False) self.do_test_with_pip(True) diff --git a/Lib/test/test_zipapp.py b/Lib/test/test_zipapp.py index 69f2e55d563840..2df254660f402a 100644 --- a/Lib/test/test_zipapp.py +++ b/Lib/test/test_zipapp.py @@ -8,7 +8,6 @@ import unittest import zipapp import zipfile -from test.support import requires_zlib from unittest.mock import patch @@ -101,7 +100,6 @@ def test_create_archive_default_target(self): expected_target = self.tmpdir / 'source.pyz' self.assertTrue(expected_target.is_file()) - @requires_zlib() def test_create_archive_with_compression(self): # Test packing a directory into a compressed archive. source = self.tmpdir / 'source' diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py index 759a4abb9d4d4e..a832b902011a0b 100644 --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -21,7 +21,7 @@ from random import randint, random, randbytes from test.support import script_helper -from test.support import (findfile, requires_zlib, requires_bz2, +from test.support import (findfile, requires_bz2, requires_lzma, captured_stdout, requires_subprocess) from test.support.os_helper import ( TESTFN, unlink, rmtree, temp_dir, temp_cwd, fd_count @@ -645,7 +645,6 @@ def test_add_file_after_2107(self): self.assertEqual(zinfo.date_time, (2107, 12, 31, 23, 59, 59)) -@requires_zlib() class DeflateTestsWithSourceFile(AbstractTestsWithSourceFile, unittest.TestCase): compression = zipfile.ZIP_DEFLATED @@ -1080,7 +1079,6 @@ def test_generated_valid_zip64_extra(self): self.assertEqual(zf.read(zinfo), expected_content) -@requires_zlib() class DeflateTestZip64InSmallFiles(AbstractTestZip64InSmallFiles, unittest.TestCase): compression = zipfile.ZIP_DEFLATED @@ -1133,7 +1131,6 @@ def test_issue44439(self): class StoredWriterTests(AbstractWriterTests, unittest.TestCase): compression = zipfile.ZIP_STORED -@requires_zlib() class DeflateWriterTests(AbstractWriterTests, unittest.TestCase): compression = zipfile.ZIP_DEFLATED @@ -1595,7 +1592,6 @@ def test_unsupported_version(self): self.assertRaises(NotImplementedError, zipfile.ZipFile, io.BytesIO(data), 'r') - @requires_zlib() def test_read_unicode_filenames(self): # bug #10801 fname = findfile('zip_cp437_header.zip') @@ -2097,7 +2093,6 @@ class StoredBadCrcTests(AbstractBadCrcTests, unittest.TestCase): b'lePK\005\006\0\0\0\0\001\0\001\0003\000' b'\0\0/\0\0\0\0\0') -@requires_zlib() class DeflateBadCrcTests(AbstractBadCrcTests, unittest.TestCase): compression = zipfile.ZIP_DEFLATED zip_with_bad_crc = ( @@ -2193,7 +2188,6 @@ def test_bad_password(self): self.zip2.setpassword(b"perl") self.assertRaises(RuntimeError, self.zip2.read, "zero") - @requires_zlib() def test_good_password(self): self.zip.setpassword(b"python") self.assertEqual(self.zip.read("test.txt"), self.plain) @@ -2352,7 +2346,6 @@ class StoredTestsWithRandomBinaryFiles(AbstractTestsWithRandomBinaryFiles, unittest.TestCase): compression = zipfile.ZIP_STORED -@requires_zlib() class DeflateTestsWithRandomBinaryFiles(AbstractTestsWithRandomBinaryFiles, unittest.TestCase): compression = zipfile.ZIP_DEFLATED @@ -2450,7 +2443,6 @@ def test_open_write(self): self.assertEqual(zipf.read('twos'), b'222') -@requires_zlib() class TestsWithMultipleOpens(unittest.TestCase): @classmethod def setUpClass(cls): @@ -2716,7 +2708,6 @@ def test_list_command(self): PYTHONIOENCODING='ascii:backslashreplace') self.assertEqual(out, expected) - @requires_zlib() def test_create_command(self): self.addCleanup(unlink, TESTFN) with open(TESTFN, 'w', encoding='utf-8') as f: diff --git a/Lib/test/test_zipfile64.py b/Lib/test/test_zipfile64.py index 0947013afbc6ed..dd3f460f598d1b 100644 --- a/Lib/test/test_zipfile64.py +++ b/Lib/test/test_zipfile64.py @@ -18,7 +18,6 @@ from tempfile import TemporaryFile from test.support import os_helper -from test.support import requires_zlib TESTFN = os_helper.TESTFN TESTFN2 = TESTFN + "2" @@ -75,7 +74,6 @@ def testStored(self): self.assertFalse(f.closed) self.zipTest(TESTFN2, zipfile.ZIP_STORED) - @requires_zlib() def testDeflated(self): # Try the temp file first. If we do TESTFN2 first, then it hogs # gigabytes of disk space for the duration of the test. diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py index 85dbf4d8f68eb6..2991a58dd75183 100644 --- a/Lib/test/test_zipimport.py +++ b/Lib/test/test_zipimport.py @@ -21,10 +21,7 @@ import inspect import io from traceback import extract_tb, extract_stack, print_tb -try: - import zlib -except ImportError: - zlib = None +import zlib test_src = """\ def get_name(): @@ -774,7 +771,6 @@ def testLargestPossibleComment(self): self.doTest(".py", files, TESTMOD, comment=b"c" * ((1 << 16) - 1)) -@support.requires_zlib() class CompressedZipImportTestCase(UncompressedZipImportTestCase): compression = ZIP_DEFLATED diff --git a/Lib/zipfile.py b/Lib/zipfile.py index 385adc897317fd..3ddfafac43b4cf 100644 --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -17,13 +17,8 @@ import time import contextlib import pathlib - -try: - import zlib # We may need its compression method - crc32 = zlib.crc32 -except ImportError: - zlib = None - crc32 = binascii.crc32 +import zlib +crc32 = zlib.crc32 try: import bz2 # We may need its compression method @@ -687,12 +682,8 @@ def decompress(self, data): } def _check_compression(compression): - if compression == ZIP_STORED: + if compression in (ZIP_STORED, ZIP_DEFLATED): pass - elif compression == ZIP_DEFLATED: - if not zlib: - raise RuntimeError( - "Compression requires the (missing) zlib module") elif compression == ZIP_BZIP2: if not bz2: raise RuntimeError( diff --git a/Lib/zipimport.py b/Lib/zipimport.py index 25eaee9c0f291b..edbf1c6f05369c 100644 --- a/Lib/zipimport.py +++ b/Lib/zipimport.py @@ -554,9 +554,7 @@ def _read_directory(archive): _importing_zlib = False -# Return the zlib.decompress function object, or NULL if zlib couldn't -# be imported. The function is cached when found, so subsequent calls -# don't import zlib again. +# Return the zlib.decompress function object or raise an import error. def _get_decompress_func(): global _importing_zlib if _importing_zlib: @@ -568,9 +566,6 @@ def _get_decompress_func(): _importing_zlib = True try: from zlib import decompress - except Exception: - _bootstrap._verbose_message('zipimport: zlib UNAVAILABLE') - raise ZipImportError("can't decompress data; zlib not available") finally: _importing_zlib = False diff --git a/Modules/Setup.bootstrap.in b/Modules/Setup.bootstrap.in index ec724978f319b4..1bfcb357480be1 100644 --- a/Modules/Setup.bootstrap.in +++ b/Modules/Setup.bootstrap.in @@ -22,6 +22,8 @@ _sre _sre.c _thread _threadmodule.c time timemodule.c _weakref _weakref.c +# used by shutil +zlib zlibmodule.c # commonly used core modules _abc _abc.c diff --git a/Modules/Setup.stdlib.in b/Modules/Setup.stdlib.in index 73f041eb2fba9f..6f0ce1ea079034 100644 --- a/Modules/Setup.stdlib.in +++ b/Modules/Setup.stdlib.in @@ -59,12 +59,11 @@ # with ./configure --with-system-libmpdec @MODULE__DECIMAL_TRUE@_decimal _decimal/_decimal.c -# compression libs and binascii (optional CRC32 from zlib) +# compression libs and binascii (CRC32 from zlib) # bindings need -lbz2, -lz, or -llzma, respectively @MODULE_BINASCII_TRUE@binascii binascii.c @MODULE__BZ2_TRUE@_bz2 _bz2module.c @MODULE__LZMA_TRUE@_lzma _lzmamodule.c -@MODULE_ZLIB_TRUE@zlib zlibmodule.c # dbm/gdbm # dbm needs either libndbm, libgdbm_compat, or libdb 5.x diff --git a/Modules/binascii.c b/Modules/binascii.c index afe49885491714..3f0678d0d97d0e 100644 --- a/Modules/binascii.c +++ b/Modules/binascii.c @@ -62,9 +62,7 @@ #include "Python.h" #include "pycore_long.h" // _PyLong_DigitValue #include "pycore_strhex.h" // _Py_strhex_bytes_with_sep() -#ifdef USE_ZLIB_CRC32 -# include "zlib.h" -#endif +#include "zlib.h" // crc32() typedef struct binascii_state { PyObject *Error; @@ -619,140 +617,6 @@ binascii_crc_hqx_impl(PyObject *module, Py_buffer *data, unsigned int crc) return PyLong_FromUnsignedLong(crc); } -#ifndef USE_ZLIB_CRC32 -/* Crc - 32 BIT ANSI X3.66 CRC checksum files - Also known as: ISO 3307 -**********************************************************************| -* *| -* Demonstration program to compute the 32-bit CRC used as the frame *| -* check sequence in ADCCP (ANSI X3.66, also known as FIPS PUB 71 *| -* and FED-STD-1003, the U.S. versions of CCITT's X.25 link-level *| -* protocol). The 32-bit FCS was added via the Federal Register, *| -* 1 June 1982, p.23798. I presume but don't know for certain that *| -* this polynomial is or will be included in CCITT V.41, which *| -* defines the 16-bit CRC (often called CRC-CCITT) polynomial. FIPS *| -* PUB 78 says that the 32-bit FCS reduces otherwise undetected *| -* errors by a factor of 10^-5 over 16-bit FCS. *| -* *| -**********************************************************************| - - Copyright (C) 1986 Gary S. Brown. You may use this program, or - code or tables extracted from it, as desired without restriction. - - First, the polynomial itself and its table of feedback terms. The - polynomial is - X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 - Note that we take it "backwards" and put the highest-order term in - the lowest-order bit. The X^32 term is "implied"; the LSB is the - X^31 term, etc. The X^0 term (usually shown as "+1") results in - the MSB being 1. - - Note that the usual hardware shift register implementation, which - is what we're using (we're merely optimizing it by doing eight-bit - chunks at a time) shifts bits into the lowest-order term. In our - implementation, that means shifting towards the right. Why do we - do it this way? Because the calculated CRC must be transmitted in - order from highest-order term to lowest-order term. UARTs transmit - characters in order from LSB to MSB. By storing the CRC this way, - we hand it to the UART in the order low-byte to high-byte; the UART - sends each low-bit to hight-bit; and the result is transmission bit - by bit from highest- to lowest-order term without requiring any bit - shuffling on our part. Reception works similarly. - - The feedback terms table consists of 256, 32-bit entries. Notes: - - 1. The table can be generated at runtime if desired; code to do so - is shown later. It might not be obvious, but the feedback - terms simply represent the results of eight shift/xor opera- - tions for all combinations of data and CRC register values. - - 2. The CRC accumulation logic is the same for all CRC polynomials, - be they sixteen or thirty-two bits wide. You simply choose the - appropriate table. Alternatively, because the table can be - generated at runtime, you can start by generating the table for - the polynomial in question and use exactly the same "updcrc", - if your application needn't simultaneously handle two CRC - polynomials. (Note, however, that XMODEM is strange.) - - 3. For 16-bit CRCs, the table entries need be only 16 bits wide; - of course, 32-bit entries work OK if the high 16 bits are zero. - - 4. The values must be right-shifted by eight bits by the "updcrc" - logic; the shift must be unsigned (bring in zeroes). On some - hardware you could probably optimize the shift in assembler by - using byte-swap instructions. -********************************************************************/ - -static const unsigned int crc_32_tab[256] = { -0x00000000U, 0x77073096U, 0xee0e612cU, 0x990951baU, 0x076dc419U, -0x706af48fU, 0xe963a535U, 0x9e6495a3U, 0x0edb8832U, 0x79dcb8a4U, -0xe0d5e91eU, 0x97d2d988U, 0x09b64c2bU, 0x7eb17cbdU, 0xe7b82d07U, -0x90bf1d91U, 0x1db71064U, 0x6ab020f2U, 0xf3b97148U, 0x84be41deU, -0x1adad47dU, 0x6ddde4ebU, 0xf4d4b551U, 0x83d385c7U, 0x136c9856U, -0x646ba8c0U, 0xfd62f97aU, 0x8a65c9ecU, 0x14015c4fU, 0x63066cd9U, -0xfa0f3d63U, 0x8d080df5U, 0x3b6e20c8U, 0x4c69105eU, 0xd56041e4U, -0xa2677172U, 0x3c03e4d1U, 0x4b04d447U, 0xd20d85fdU, 0xa50ab56bU, -0x35b5a8faU, 0x42b2986cU, 0xdbbbc9d6U, 0xacbcf940U, 0x32d86ce3U, -0x45df5c75U, 0xdcd60dcfU, 0xabd13d59U, 0x26d930acU, 0x51de003aU, -0xc8d75180U, 0xbfd06116U, 0x21b4f4b5U, 0x56b3c423U, 0xcfba9599U, -0xb8bda50fU, 0x2802b89eU, 0x5f058808U, 0xc60cd9b2U, 0xb10be924U, -0x2f6f7c87U, 0x58684c11U, 0xc1611dabU, 0xb6662d3dU, 0x76dc4190U, -0x01db7106U, 0x98d220bcU, 0xefd5102aU, 0x71b18589U, 0x06b6b51fU, -0x9fbfe4a5U, 0xe8b8d433U, 0x7807c9a2U, 0x0f00f934U, 0x9609a88eU, -0xe10e9818U, 0x7f6a0dbbU, 0x086d3d2dU, 0x91646c97U, 0xe6635c01U, -0x6b6b51f4U, 0x1c6c6162U, 0x856530d8U, 0xf262004eU, 0x6c0695edU, -0x1b01a57bU, 0x8208f4c1U, 0xf50fc457U, 0x65b0d9c6U, 0x12b7e950U, -0x8bbeb8eaU, 0xfcb9887cU, 0x62dd1ddfU, 0x15da2d49U, 0x8cd37cf3U, -0xfbd44c65U, 0x4db26158U, 0x3ab551ceU, 0xa3bc0074U, 0xd4bb30e2U, -0x4adfa541U, 0x3dd895d7U, 0xa4d1c46dU, 0xd3d6f4fbU, 0x4369e96aU, -0x346ed9fcU, 0xad678846U, 0xda60b8d0U, 0x44042d73U, 0x33031de5U, -0xaa0a4c5fU, 0xdd0d7cc9U, 0x5005713cU, 0x270241aaU, 0xbe0b1010U, -0xc90c2086U, 0x5768b525U, 0x206f85b3U, 0xb966d409U, 0xce61e49fU, -0x5edef90eU, 0x29d9c998U, 0xb0d09822U, 0xc7d7a8b4U, 0x59b33d17U, -0x2eb40d81U, 0xb7bd5c3bU, 0xc0ba6cadU, 0xedb88320U, 0x9abfb3b6U, -0x03b6e20cU, 0x74b1d29aU, 0xead54739U, 0x9dd277afU, 0x04db2615U, -0x73dc1683U, 0xe3630b12U, 0x94643b84U, 0x0d6d6a3eU, 0x7a6a5aa8U, -0xe40ecf0bU, 0x9309ff9dU, 0x0a00ae27U, 0x7d079eb1U, 0xf00f9344U, -0x8708a3d2U, 0x1e01f268U, 0x6906c2feU, 0xf762575dU, 0x806567cbU, -0x196c3671U, 0x6e6b06e7U, 0xfed41b76U, 0x89d32be0U, 0x10da7a5aU, -0x67dd4accU, 0xf9b9df6fU, 0x8ebeeff9U, 0x17b7be43U, 0x60b08ed5U, -0xd6d6a3e8U, 0xa1d1937eU, 0x38d8c2c4U, 0x4fdff252U, 0xd1bb67f1U, -0xa6bc5767U, 0x3fb506ddU, 0x48b2364bU, 0xd80d2bdaU, 0xaf0a1b4cU, -0x36034af6U, 0x41047a60U, 0xdf60efc3U, 0xa867df55U, 0x316e8eefU, -0x4669be79U, 0xcb61b38cU, 0xbc66831aU, 0x256fd2a0U, 0x5268e236U, -0xcc0c7795U, 0xbb0b4703U, 0x220216b9U, 0x5505262fU, 0xc5ba3bbeU, -0xb2bd0b28U, 0x2bb45a92U, 0x5cb36a04U, 0xc2d7ffa7U, 0xb5d0cf31U, -0x2cd99e8bU, 0x5bdeae1dU, 0x9b64c2b0U, 0xec63f226U, 0x756aa39cU, -0x026d930aU, 0x9c0906a9U, 0xeb0e363fU, 0x72076785U, 0x05005713U, -0x95bf4a82U, 0xe2b87a14U, 0x7bb12baeU, 0x0cb61b38U, 0x92d28e9bU, -0xe5d5be0dU, 0x7cdcefb7U, 0x0bdbdf21U, 0x86d3d2d4U, 0xf1d4e242U, -0x68ddb3f8U, 0x1fda836eU, 0x81be16cdU, 0xf6b9265bU, 0x6fb077e1U, -0x18b74777U, 0x88085ae6U, 0xff0f6a70U, 0x66063bcaU, 0x11010b5cU, -0x8f659effU, 0xf862ae69U, 0x616bffd3U, 0x166ccf45U, 0xa00ae278U, -0xd70dd2eeU, 0x4e048354U, 0x3903b3c2U, 0xa7672661U, 0xd06016f7U, -0x4969474dU, 0x3e6e77dbU, 0xaed16a4aU, 0xd9d65adcU, 0x40df0b66U, -0x37d83bf0U, 0xa9bcae53U, 0xdebb9ec5U, 0x47b2cf7fU, 0x30b5ffe9U, -0xbdbdf21cU, 0xcabac28aU, 0x53b39330U, 0x24b4a3a6U, 0xbad03605U, -0xcdd70693U, 0x54de5729U, 0x23d967bfU, 0xb3667a2eU, 0xc4614ab8U, -0x5d681b02U, 0x2a6f2b94U, 0xb40bbe37U, 0xc30c8ea1U, 0x5a05df1bU, -0x2d02ef8dU -}; - -static unsigned int -internal_crc32(const unsigned char *bin_data, Py_ssize_t len, unsigned int crc) -{ /* By Jim Ahlstrom; All rights transferred to CNRI */ - unsigned int result; - - crc = ~ crc; - while (len-- > 0) { - crc = crc_32_tab[(crc ^ *bin_data++) & 0xff] ^ (crc >> 8); - /* Note: (crc >> 8) MUST zero fill on left */ - } - - result = (crc ^ 0xFFFFFFFF); - return result & 0xffffffff; -} -#endif /* USE_ZLIB_CRC32 */ /*[clinic input] binascii.crc32 -> unsigned_int @@ -767,10 +631,8 @@ Compute CRC-32 incrementally. static unsigned int binascii_crc32_impl(PyObject *module, Py_buffer *data, unsigned int crc) /*[clinic end generated code: output=52cf59056a78593b input=bbe340bc99d25aa8]*/ - -#ifdef USE_ZLIB_CRC32 /* This is the same as zlibmodule.c zlib_crc32_impl. It exists in two - * modules for historical reasons. */ + * modules for historical reasons. We should consolidate the two. */ { /* Releasing the GIL for very small buffers is inefficient and may lower performance */ @@ -793,24 +655,6 @@ binascii_crc32_impl(PyObject *module, Py_buffer *data, unsigned int crc) } return crc & 0xffffffff; } -#else /* USE_ZLIB_CRC32 */ -{ - const unsigned char *bin_data = data->buf; - Py_ssize_t len = data->len; - - /* Releasing the GIL for very small buffers is inefficient - and may lower performance */ - if (len > 1024*5) { - unsigned int result; - Py_BEGIN_ALLOW_THREADS - result = internal_crc32(bin_data, len, crc); - Py_END_ALLOW_THREADS - return result; - } else { - return internal_crc32(bin_data, len, crc); - } -} -#endif /* USE_ZLIB_CRC32 */ /*[clinic input] binascii.b2a_hex diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index 5e6e703df9123e..a0a230134290bf 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -366,9 +366,7 @@ - - USE_ZLIB_CRC32;%(PreprocessorDefinitions) - + diff --git a/aclocal.m4 b/aclocal.m4 index 6a33c0cc9d9e8c..adbf0ce01f15f0 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,6 +1,6 @@ -# generated automatically by aclocal 1.16.3 -*- Autoconf -*- +# generated automatically by aclocal 1.16.1 -*- Autoconf -*- -# Copyright (C) 1996-2020 Free Software Foundation, Inc. +# Copyright (C) 1996-2018 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -275,9 +275,9 @@ AC_DEFUN([AX_CHECK_OPENSSL], [ AC_SUBST([OPENSSL_LDFLAGS]) ]) -# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- -# serial 11 (pkg-config-0.29.1) - +dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +dnl serial 11 (pkg-config-0.29.1) +dnl dnl Copyright © 2004 Scott James Remnant . dnl Copyright © 2012-2015 Dan Nicholson dnl @@ -551,77 +551,9 @@ AS_VAR_COPY([$1], [pkg_cv_][$1]) AS_VAR_IF([$1], [""], [$5], [$4])dnl ])dnl PKG_CHECK_VAR -dnl PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES, -dnl [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND], -dnl [DESCRIPTION], [DEFAULT]) -dnl ------------------------------------------ -dnl -dnl Prepare a "--with-" configure option using the lowercase -dnl [VARIABLE-PREFIX] name, merging the behaviour of AC_ARG_WITH and -dnl PKG_CHECK_MODULES in a single macro. -AC_DEFUN([PKG_WITH_MODULES], -[ -m4_pushdef([with_arg], m4_tolower([$1])) - -m4_pushdef([description], - [m4_default([$5], [build with ]with_arg[ support])]) - -m4_pushdef([def_arg], [m4_default([$6], [auto])]) -m4_pushdef([def_action_if_found], [AS_TR_SH([with_]with_arg)=yes]) -m4_pushdef([def_action_if_not_found], [AS_TR_SH([with_]with_arg)=no]) - -m4_case(def_arg, - [yes],[m4_pushdef([with_without], [--without-]with_arg)], - [m4_pushdef([with_without],[--with-]with_arg)]) - -AC_ARG_WITH(with_arg, - AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),, - [AS_TR_SH([with_]with_arg)=def_arg]) - -AS_CASE([$AS_TR_SH([with_]with_arg)], - [yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)], - [auto],[PKG_CHECK_MODULES([$1],[$2], - [m4_n([def_action_if_found]) $3], - [m4_n([def_action_if_not_found]) $4])]) - -m4_popdef([with_arg]) -m4_popdef([description]) -m4_popdef([def_arg]) - -])dnl PKG_WITH_MODULES - -dnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES, -dnl [DESCRIPTION], [DEFAULT]) -dnl ----------------------------------------------- -dnl -dnl Convenience macro to trigger AM_CONDITIONAL after PKG_WITH_MODULES -dnl check._[VARIABLE-PREFIX] is exported as make variable. -AC_DEFUN([PKG_HAVE_WITH_MODULES], -[ -PKG_WITH_MODULES([$1],[$2],,,[$3],[$4]) - -AM_CONDITIONAL([HAVE_][$1], - [test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"]) -])dnl PKG_HAVE_WITH_MODULES - -dnl PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES, -dnl [DESCRIPTION], [DEFAULT]) -dnl ------------------------------------------------------ -dnl -dnl Convenience macro to run AM_CONDITIONAL and AC_DEFINE after -dnl PKG_WITH_MODULES check. HAVE_[VARIABLE-PREFIX] is exported as make -dnl and preprocessor variable. -AC_DEFUN([PKG_HAVE_DEFINE_WITH_MODULES], -[ -PKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4]) - -AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"], - [AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])]) -])dnl PKG_HAVE_DEFINE_WITH_MODULES - # AM_CONDITIONAL -*- Autoconf -*- -# Copyright (C) 1997-2020 Free Software Foundation, Inc. +# Copyright (C) 1997-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -652,7 +584,7 @@ AC_CONFIG_COMMANDS_PRE( Usually this means the macro was only invoked conditionally.]]) fi])]) -# Copyright (C) 2006-2020 Free Software Foundation, Inc. +# Copyright (C) 2006-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, diff --git a/configure b/configure index 5fa6efaab4fb7c..815dc4c0b6a7bb 100755 --- a/configure +++ b/configure @@ -14863,7 +14863,6 @@ fi $as_echo "$ac_cv_lib_z_gzread" >&6; } if test "x$ac_cv_lib_z_gzread" = xyes; then : - have_zlib=yes ZLIB_CFLAGS=${ZLIB_CFLAGS-""} ZLIB_LIBS=${ZLIB_LIBS-"-lz"} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5 @@ -14910,7 +14909,7 @@ fi else - have_zlib=no + as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 fi @@ -14923,7 +14922,9 @@ LIBS=$save_LIBS else - have_zlib=no + + as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 + fi done @@ -14985,7 +14986,6 @@ fi $as_echo "$ac_cv_lib_z_gzread" >&6; } if test "x$ac_cv_lib_z_gzread" = xyes; then : - have_zlib=yes ZLIB_CFLAGS=${ZLIB_CFLAGS-""} ZLIB_LIBS=${ZLIB_LIBS-"-lz"} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5 @@ -15032,7 +15032,7 @@ fi else - have_zlib=no + as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 fi @@ -15045,7 +15045,9 @@ LIBS=$save_LIBS else - have_zlib=no + + as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 + fi done @@ -15057,19 +15059,11 @@ else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } - have_zlib=yes $as_echo "#define HAVE_ZLIB_COPY 1" >>confdefs.h fi -if test "x$have_zlib" = xyes; then : - - BINASCII_CFLAGS="-DUSE_ZLIB_CRC32 $ZLIB_CFLAGS" - BINASCII_LIBS="$ZLIB_LIBS" - -fi - pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BZIP2" >&5 @@ -23054,21 +23048,17 @@ $as_echo "$py_cv_module__uuid" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module zlib" >&5 -$as_echo_n "checking for stdlib extension module zlib... " >&6; } if test "$py_cv_module_zlib" != "n/a"; then : - - if true; then : - if test "$have_zlib" = yes; then : py_cv_module_zlib=yes -else - py_cv_module_zlib=missing fi + if test "$py_cv_module_zlib" = yes; then + MODULE_ZLIB_TRUE= + MODULE_ZLIB_FALSE='#' else - py_cv_module_zlib=disabled + MODULE_ZLIB_TRUE='#' + MODULE_ZLIB_FALSE= fi -fi as_fn_append MODULE_BLOCK "MODULE_ZLIB=$py_cv_module_zlib$as_nl" if test "x$py_cv_module_zlib" = xyes; then : @@ -23076,16 +23066,6 @@ fi as_fn_append MODULE_BLOCK "MODULE_ZLIB_LDFLAGS=$ZLIB_LIBS$as_nl" fi - if test "$py_cv_module_zlib" = yes; then - MODULE_ZLIB_TRUE= - MODULE_ZLIB_FALSE='#' -else - MODULE_ZLIB_TRUE='#' - MODULE_ZLIB_FALSE= -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $py_cv_module_zlib" >&5 -$as_echo "$py_cv_module_zlib" >&6; } if test "$py_cv_module_binascii" != "n/a"; then : @@ -23102,8 +23082,8 @@ fi as_fn_append MODULE_BLOCK "MODULE_BINASCII=$py_cv_module_binascii$as_nl" if test "x$py_cv_module_binascii" = xyes; then : - as_fn_append MODULE_BLOCK "MODULE_BINASCII_CFLAGS=$BINASCII_CFLAGS$as_nl" - as_fn_append MODULE_BLOCK "MODULE_BINASCII_LDFLAGS=$BINASCII_LIBS$as_nl" + as_fn_append MODULE_BLOCK "MODULE_BINASCII_CFLAGS=$ZLIB_CFLAGS$as_nl" + as_fn_append MODULE_BLOCK "MODULE_BINASCII_LDFLAGS=$ZLIB_LIBS$as_nl" fi diff --git a/configure.ac b/configure.ac index 7a37ad279d0fcb..2d4836e08b9c91 100644 --- a/configure.ac +++ b/configure.ac @@ -4333,31 +4333,33 @@ if test "$ac_cv_have_lchflags" = yes ; then fi dnl Check for compression libraries -AH_TEMPLATE([HAVE_ZLIB_COPY], [Define if the zlib library has inflateCopy]) +AH_TEMPLATE([HAVE_ZLIB_COPY], [Define if the zlib library has inflateCopy; zlib 1.2.0 (2003) added inflateCopy.]) +dnl 2022-03: Until we know if third party zlib modules people use (for hardware +dnl accelerators, parallelism, etc.) all support copy, lets not assume. PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [ - have_zlib=yes dnl zlib 1.2.0 (2003) added inflateCopy AC_DEFINE([HAVE_ZLIB_COPY], [1]) ], [ AC_CHECK_HEADERS([zlib.h], [ WITH_SAVE_ENV([ AC_CHECK_LIB([z], [gzread], [ - have_zlib=yes ZLIB_CFLAGS=${ZLIB_CFLAGS-""} ZLIB_LIBS=${ZLIB_LIBS-"-lz"} AC_CHECK_LIB([z], [inflateCopy], [AC_DEFINE([HAVE_ZLIB_COPY], [1])]) ], [ - have_zlib=no + AC_MSG_ERROR([m4_normalize([ + zlib.h and libz are required. Install your OS's zlib-devel or + zlib1g-dev equivalent library or get it from https://zlib.net/. + ])]) ]) ]) - ], [have_zlib=no]) -]) - -dnl binascii can use zlib for optimized crc32. -AS_VAR_IF([have_zlib], [yes], [ - BINASCII_CFLAGS="-DUSE_ZLIB_CRC32 $ZLIB_CFLAGS" - BINASCII_LIBS="$ZLIB_LIBS" + ], [ + AC_MSG_ERROR([m4_normalize([ + zlib.h and libz are required. Install your OS's zlib-devel or + zlib1g-dev equivalent library or get it from https://zlib.net/. + ])]) + ]) ]) PKG_CHECK_MODULES([BZIP2], [bzip2], [have_bzip2=yes], [ @@ -6619,10 +6621,9 @@ PY_STDLIB_MOD([_uuid], [$LIBUUID_CFLAGS], [$LIBUUID_LIBS]) dnl compression libs -PY_STDLIB_MOD([zlib], [], [test "$have_zlib" = yes], - [$ZLIB_CFLAGS], [$ZLIB_LIBS]) -dnl binascii can use zlib for optimized crc32. -PY_STDLIB_MOD_SIMPLE([binascii], [$BINASCII_CFLAGS], [$BINASCII_LIBS]) +PY_STDLIB_MOD_SIMPLE([zlib], [$ZLIB_CFLAGS], [$ZLIB_LIBS]) +dnl binascii uses zlib for optimized crc32. +PY_STDLIB_MOD_SIMPLE([binascii], [$ZLIB_CFLAGS], [$ZLIB_LIBS]) PY_STDLIB_MOD([_bz2], [], [test "$have_bzip2" = yes], [$BZIP2_CFLAGS], [$BZIP2_LIBS]) PY_STDLIB_MOD([_lzma], [], [test "$have_liblzma" = yes], diff --git a/pyconfig.h.in b/pyconfig.h.in index 40952883853e32..afafd860e396a6 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -1441,7 +1441,8 @@ /* Define to 1 if you have the `writev' function. */ #undef HAVE_WRITEV -/* Define if the zlib library has inflateCopy */ +/* Define if the zlib library has inflateCopy; zlib 1.2.0 (2003) added + inflateCopy. */ #undef HAVE_ZLIB_COPY /* Define to 1 if you have the header file. */ diff --git a/setup.py b/setup.py index c3cf2417bc429d..b1fae7b9d5adcf 100644 --- a/setup.py +++ b/setup.py @@ -1350,11 +1350,8 @@ def detect_platform_specific_exts(self): self.addext(Extension('_scproxy', ['_scproxy.c'])) def detect_compress_exts(self): - # Andrew Kuchling's zlib module. - self.addext(Extension('zlib', ['zlibmodule.c'])) - - # Helper module for various ascii-encoders. Uses zlib for an optimized - # crc32 if we have it. Otherwise binascii uses its own. + # The zlib module is built by our Makefile + # Helper module for various ascii-encoders. Uses zlib for crc32. self.addext(Extension('binascii', ['binascii.c'])) # Gustavo Niemeyer's bz2 module. From 33d9a3fb5bc12fc1f5ada58be2ef9a8abb3a3761 Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith" Date: Tue, 22 Mar 2022 01:46:01 -0700 Subject: [PATCH 02/30] Undo aclocal.m4 changes. --- aclocal.m4 | 126 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 72 insertions(+), 54 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index adbf0ce01f15f0..2f1bd37528c85d 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,6 +1,6 @@ -# generated automatically by aclocal 1.16.1 -*- Autoconf -*- +# generated automatically by aclocal 1.16.3 -*- Autoconf -*- -# Copyright (C) 1996-2018 Free Software Foundation, Inc. +# Copyright (C) 1996-2020 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -275,9 +275,9 @@ AC_DEFUN([AX_CHECK_OPENSSL], [ AC_SUBST([OPENSSL_LDFLAGS]) ]) -dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- -dnl serial 11 (pkg-config-0.29.1) -dnl +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# serial 11 (pkg-config-0.29.1) + dnl Copyright © 2004 Scott James Remnant . dnl Copyright © 2012-2015 Dan Nicholson dnl @@ -551,53 +551,71 @@ AS_VAR_COPY([$1], [pkg_cv_][$1]) AS_VAR_IF([$1], [""], [$5], [$4])dnl ])dnl PKG_CHECK_VAR -# AM_CONDITIONAL -*- Autoconf -*- - -# Copyright (C) 1997-2018 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_CONDITIONAL(NAME, SHELL-CONDITION) -# ------------------------------------- -# Define a conditional. -AC_DEFUN([AM_CONDITIONAL], -[AC_PREREQ([2.52])dnl - m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], - [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl -AC_SUBST([$1_TRUE])dnl -AC_SUBST([$1_FALSE])dnl -_AM_SUBST_NOTMAKE([$1_TRUE])dnl -_AM_SUBST_NOTMAKE([$1_FALSE])dnl -m4_define([_AM_COND_VALUE_$1], [$2])dnl -if $2; then - $1_TRUE= - $1_FALSE='#' -else - $1_TRUE='#' - $1_FALSE= -fi -AC_CONFIG_COMMANDS_PRE( -[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then - AC_MSG_ERROR([[conditional "$1" was never defined. -Usually this means the macro was only invoked conditionally.]]) -fi])]) - -# Copyright (C) 2006-2018 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# _AM_SUBST_NOTMAKE(VARIABLE) -# --------------------------- -# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. -# This macro is traced by Automake. -AC_DEFUN([_AM_SUBST_NOTMAKE]) - -# AM_SUBST_NOTMAKE(VARIABLE) -# -------------------------- -# Public sister of _AM_SUBST_NOTMAKE. -AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) +dnl PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES, +dnl [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND], +dnl [DESCRIPTION], [DEFAULT]) +dnl ------------------------------------------ +dnl +dnl Prepare a "--with-" configure option using the lowercase +dnl [VARIABLE-PREFIX] name, merging the behaviour of AC_ARG_WITH and +dnl PKG_CHECK_MODULES in a single macro. +AC_DEFUN([PKG_WITH_MODULES], +[ +m4_pushdef([with_arg], m4_tolower([$1])) + +m4_pushdef([description], + [m4_default([$5], [build with ]with_arg[ support])]) + +m4_pushdef([def_arg], [m4_default([$6], [auto])]) +m4_pushdef([def_action_if_found], [AS_TR_SH([with_]with_arg)=yes]) +m4_pushdef([def_action_if_not_found], [AS_TR_SH([with_]with_arg)=no]) + +m4_case(def_arg, + [yes],[m4_pushdef([with_without], [--without-]with_arg)], + [m4_pushdef([with_without],[--with-]with_arg)]) + +AC_ARG_WITH(with_arg, + AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),, + [AS_TR_SH([with_]with_arg)=def_arg]) + +AS_CASE([$AS_TR_SH([with_]with_arg)], + [yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)], + [auto],[PKG_CHECK_MODULES([$1],[$2], + [m4_n([def_action_if_found]) $3], + [m4_n([def_action_if_not_found]) $4])]) + +m4_popdef([with_arg]) +m4_popdef([description]) +m4_popdef([def_arg]) + +])dnl PKG_WITH_MODULES + +dnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES, +dnl [DESCRIPTION], [DEFAULT]) +dnl ----------------------------------------------- +dnl +dnl Convenience macro to trigger AM_CONDITIONAL after PKG_WITH_MODULES +dnl check._[VARIABLE-PREFIX] is exported as make variable. +AC_DEFUN([PKG_HAVE_WITH_MODULES], +[ +PKG_WITH_MODULES([$1],[$2],,,[$3],[$4]) + +AM_CONDITIONAL([HAVE_][$1], + [test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"]) +])dnl PKG_HAVE_WITH_MODULES + +dnl PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES, +dnl [DESCRIPTION], [DEFAULT]) +dnl ------------------------------------------------------ +dnl +dnl Convenience macro to run AM_CONDITIONAL and AC_DEFINE after +dnl PKG_WITH_MODULES check. HAVE_[VARIABLE-PREFIX] is exported as make +dnl and preprocessor variable. +AC_DEFUN([PKG_HAVE_DEFINE_WITH_MODULES], +[ +PKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4]) + +AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"], + [AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])]) +])dnl PKG_HAVE_DEFINE_WITH_MODULES From 9cd7a065b7f72d5e1e0c3ce86b41626479a15229 Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith" Date: Tue, 22 Mar 2022 02:38:43 -0700 Subject: [PATCH 03/30] restore aclocal.m4 the right way? (ugh git) --- aclocal.m4 | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/aclocal.m4 b/aclocal.m4 index 2f1bd37528c85d..6a33c0cc9d9e8c 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -619,3 +619,53 @@ AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"], [AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])]) ])dnl PKG_HAVE_DEFINE_WITH_MODULES +# AM_CONDITIONAL -*- Autoconf -*- + +# Copyright (C) 1997-2020 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +AC_DEFUN([AM_CONDITIONAL], +[AC_PREREQ([2.52])dnl + m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +AC_SUBST([$1_TRUE])dnl +AC_SUBST([$1_FALSE])dnl +_AM_SUBST_NOTMAKE([$1_TRUE])dnl +_AM_SUBST_NOTMAKE([$1_FALSE])dnl +m4_define([_AM_COND_VALUE_$1], [$2])dnl +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi +AC_CONFIG_COMMANDS_PRE( +[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then + AC_MSG_ERROR([[conditional "$1" was never defined. +Usually this means the macro was only invoked conditionally.]]) +fi])]) + +# Copyright (C) 2006-2020 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# _AM_SUBST_NOTMAKE(VARIABLE) +# --------------------------- +# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. +# This macro is traced by Automake. +AC_DEFUN([_AM_SUBST_NOTMAKE]) + +# AM_SUBST_NOTMAKE(VARIABLE) +# -------------------------- +# Public sister of _AM_SUBST_NOTMAKE. +AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) + From 309cc684641f6a0742bf8dddbcb5a9a3beffa0c2 Mon Sep 17 00:00:00 2001 From: stan Date: Mon, 17 Feb 2025 16:49:57 +0000 Subject: [PATCH 04/30] Paperwork --- Doc/whatsnew/3.14.rst | 6 ++++++ .../Build/2025-02-17-16-43-00.gh-issue-91246.3z8l7i3b.rst | 2 ++ 2 files changed, 8 insertions(+) create mode 100644 Misc/NEWS.d/next/Build/2025-02-17-16-43-00.gh-issue-91246.3z8l7i3b.rst diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index ac0ae8cf0133e6..54298014655ab6 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -1285,6 +1285,12 @@ Build changes * GNU Autoconf 2.72 is now required to generate :file:`configure`. (Contributed by Erlend Aasland in :gh:`115765`.) +* zlib is now officially required to build CPython. + It is still technically possible to build CPython without it for special needs, like bootstrapping. + Such builds are not supported, but we can accept pull requests to keep them working. + As an exception, zlib is not required on WASI. + (Contributed by Stan Ulbrych & Gregory P. Smith in :gh:`130234`.) + .. _whatsnew314-pep761: PEP 761: Discontinuation of PGP signatures diff --git a/Misc/NEWS.d/next/Build/2025-02-17-16-43-00.gh-issue-91246.3z8l7i3b.rst b/Misc/NEWS.d/next/Build/2025-02-17-16-43-00.gh-issue-91246.3z8l7i3b.rst new file mode 100644 index 00000000000000..488d4a024c1c55 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2025-02-17-16-43-00.gh-issue-91246.3z8l7i3b.rst @@ -0,0 +1,2 @@ +Make zlib required to build CPython with the exception of WASI. +(Contributed by Stan Ulbrych & Gregory P. Smith in :gh:`130234`.) From a6328eed1df9f05ec5e9fb27caf0cac757f4f6ba Mon Sep 17 00:00:00 2001 From: stan Date: Mon, 17 Feb 2025 17:31:23 +0000 Subject: [PATCH 05/30] test_zlib stuff --- Lib/test/test_zlib.py | 10 +++++++++- pyconfig.h.in | 3 +-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py index 4d97fe56f3a094..aa85199ac04f66 100644 --- a/Lib/test/test_zlib.py +++ b/Lib/test/test_zlib.py @@ -8,8 +8,16 @@ import sys from test.support import bigmemtest, _1G, _4G, is_s390x +zlib = import_helper.import_module('zlib', required_on=('linux', 'darwin', 'win32', 'cygwin')) + +# Building CPython without zlib is not supported except WASI. +# +# Anyone who wants build CPython this way should be prepared to patch it, +# but the core team may help getting those patches to the main branch +# (as that’s the place where multiple third parties can cooperate). +# +# For tests to pass without zlib, this file needs to be removed. -zlib = import_helper.import_module('zlib') requires_Compress_copy = unittest.skipUnless( hasattr(zlib.compressobj(), "copy"), diff --git a/pyconfig.h.in b/pyconfig.h.in index ee4cac2ce8472a..4295b4f5ea5fbd 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -1609,8 +1609,7 @@ /* Define to 1 if you have the 'writev' function. */ #undef HAVE_WRITEV -/* Define if the zlib library has inflateCopy; zlib 1.2.0 (2003) added - inflateCopy. */ +/* Define if the zlib library has inflateCopy */ #undef HAVE_ZLIB_COPY /* Define to 1 if you have the header file. */ From d56571371ef780dbf353475a9373fca9828bc3ce Mon Sep 17 00:00:00 2001 From: stan Date: Mon, 17 Feb 2025 17:32:44 +0000 Subject: [PATCH 06/30] add android/ios --- Lib/test/test_zlib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py index aa85199ac04f66..f75fbd1a71ac6b 100644 --- a/Lib/test/test_zlib.py +++ b/Lib/test/test_zlib.py @@ -8,7 +8,7 @@ import sys from test.support import bigmemtest, _1G, _4G, is_s390x -zlib = import_helper.import_module('zlib', required_on=('linux', 'darwin', 'win32', 'cygwin')) +zlib = import_helper.import_module('zlib', required_on=('linux', 'android', 'ios', 'darwin', 'win32', 'cygwin')) # Building CPython without zlib is not supported except WASI. # From aec582beefeb10a8334bcee70266a7990463ca4d Mon Sep 17 00:00:00 2001 From: stan Date: Mon, 17 Feb 2025 18:00:55 +0000 Subject: [PATCH 07/30] Config changes --- configure | 177 +++++++++++++++++--------------------------------- configure.ac | 48 +++++++------- pyconfig.h.in | 3 +- 3 files changed, 85 insertions(+), 143 deletions(-) diff --git a/configure b/configure index 453b0123ded0a4..7b4d4eba9d298a 100755 --- a/configure +++ b/configure @@ -21450,20 +21450,6 @@ fi - - - if test "$ac_sys_system" = "Emscripten" -a -z "$ZLIB_CFLAGS" -a -z "$ZLIB_LIBS" -then : - - ZLIB_CFLAGS="-sUSE_ZLIB" - ZLIB_LIBS="-sUSE_ZLIB" - -fi - - - - - pkg_failed=no { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for zlib >= 1.2.0" >&5 printf %s "checking for zlib >= 1.2.0... " >&6; } @@ -21523,23 +21509,20 @@ fi echo "$ZLIB_PKG_ERRORS" >&5 - save_CFLAGS=$CFLAGS -save_CPPFLAGS=$CPPFLAGS -save_LDFLAGS=$LDFLAGS -save_LIBS=$LIBS - - - CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS" - LIBS="$LIBS $ZLIB_LIBS" - for ac_header in zlib.h + for ac_header in zlib.h do : ac_fn_c_check_header_compile "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" if test "x$ac_cv_header_zlib_h" = xyes then : printf "%s\n" "#define HAVE_ZLIB_H 1" >>confdefs.h - py_check_lib_save_LIBS=$LIBS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzread in -lz" >&5 + save_CFLAGS=$CFLAGS +save_CPPFLAGS=$CPPFLAGS +save_LDFLAGS=$LDFLAGS +save_LIBS=$LIBS + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzread in -lz" >&5 printf %s "checking for gzread in -lz... " >&6; } if test ${ac_cv_lib_z_gzread+y} then : @@ -21583,29 +21566,11 @@ fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_gzread" >&5 printf "%s\n" "$ac_cv_lib_z_gzread" >&6; } if test "x$ac_cv_lib_z_gzread" = xyes -then : - have_zlib=yes -else case e in #( - e) have_zlib=no ;; -esac -fi - -LIBS=$py_check_lib_save_LIBS - - -else case e in #( - e) have_zlib=no ;; -esac -fi - -done - if test "x$have_zlib" = xyes then : - ZLIB_CFLAGS=${ZLIB_CFLAGS-""} - ZLIB_LIBS=${ZLIB_LIBS-"-lz"} - py_check_lib_save_LIBS=$LIBS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5 + ZLIB_CFLAGS=${ZLIB_CFLAGS-""} + ZLIB_LIBS=${ZLIB_LIBS-"-lz"} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5 printf %s "checking for inflateCopy in -lz... " >&6; } if test ${ac_cv_lib_z_inflateCopy+y} then : @@ -21654,11 +21619,15 @@ then : fi -LIBS=$py_check_lib_save_LIBS - +else case e in #( + e) + as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 + ;; +esac fi + CFLAGS=$save_CFLAGS CPPFLAGS=$save_CPPFLAGS LDFLAGS=$save_LDFLAGS @@ -21666,27 +21635,33 @@ LIBS=$save_LIBS +else case e in #( + e) + as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 + ;; +esac +fi + +done + elif test $pkg_failed = untried; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } - save_CFLAGS=$CFLAGS -save_CPPFLAGS=$CPPFLAGS -save_LDFLAGS=$LDFLAGS -save_LIBS=$LIBS - - - CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS" - LIBS="$LIBS $ZLIB_LIBS" - for ac_header in zlib.h + for ac_header in zlib.h do : ac_fn_c_check_header_compile "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" if test "x$ac_cv_header_zlib_h" = xyes then : printf "%s\n" "#define HAVE_ZLIB_H 1" >>confdefs.h - py_check_lib_save_LIBS=$LIBS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzread in -lz" >&5 + save_CFLAGS=$CFLAGS +save_CPPFLAGS=$CPPFLAGS +save_LDFLAGS=$LDFLAGS +save_LIBS=$LIBS + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzread in -lz" >&5 printf %s "checking for gzread in -lz... " >&6; } if test ${ac_cv_lib_z_gzread+y} then : @@ -21730,29 +21705,11 @@ fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_gzread" >&5 printf "%s\n" "$ac_cv_lib_z_gzread" >&6; } if test "x$ac_cv_lib_z_gzread" = xyes -then : - have_zlib=yes -else case e in #( - e) have_zlib=no ;; -esac -fi - -LIBS=$py_check_lib_save_LIBS - - -else case e in #( - e) have_zlib=no ;; -esac -fi - -done - if test "x$have_zlib" = xyes then : - ZLIB_CFLAGS=${ZLIB_CFLAGS-""} - ZLIB_LIBS=${ZLIB_LIBS-"-lz"} - py_check_lib_save_LIBS=$LIBS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5 + ZLIB_CFLAGS=${ZLIB_CFLAGS-""} + ZLIB_LIBS=${ZLIB_LIBS-"-lz"} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5 printf %s "checking for inflateCopy in -lz... " >&6; } if test ${ac_cv_lib_z_inflateCopy+y} then : @@ -21801,11 +21758,15 @@ then : fi -LIBS=$py_check_lib_save_LIBS - +else case e in #( + e) + as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 + ;; +esac fi + CFLAGS=$save_CFLAGS CPPFLAGS=$save_CPPFLAGS LDFLAGS=$save_LDFLAGS @@ -21813,26 +21774,26 @@ LIBS=$save_LIBS +else case e in #( + e) + as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 + ;; +esac +fi + +done + else ZLIB_CFLAGS=$pkg_cv_ZLIB_CFLAGS ZLIB_LIBS=$pkg_cv_ZLIB_LIBS { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } - have_zlib=yes printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h fi -if test "x$have_zlib" = xyes -then : - - BINASCII_CFLAGS="-DUSE_ZLIB_CRC32 $ZLIB_CFLAGS" - BINASCII_LIBS="$ZLIB_LIBS" - -fi - @@ -32621,26 +32582,18 @@ printf "%s\n" "$py_cv_module__uuid" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module zlib" >&5 -printf %s "checking for stdlib extension module zlib... " >&6; } if test "$py_cv_module_zlib" != "n/a" then : - - if true -then : - if test "$have_zlib" = yes -then : py_cv_module_zlib=yes -else case e in #( - e) py_cv_module_zlib=missing ;; -esac fi -else case e in #( - e) py_cv_module_zlib=disabled ;; -esac + if test "$py_cv_module_zlib" = yes; then + MODULE_ZLIB_TRUE= + MODULE_ZLIB_FALSE='#' +else + MODULE_ZLIB_TRUE='#' + MODULE_ZLIB_FALSE= fi -fi as_fn_append MODULE_BLOCK "MODULE_ZLIB_STATE=$py_cv_module_zlib$as_nl" if test "x$py_cv_module_zlib" = xyes then : @@ -32649,16 +32602,6 @@ then : as_fn_append MODULE_BLOCK "MODULE_ZLIB_LDFLAGS=$ZLIB_LIBS$as_nl" fi - if test "$py_cv_module_zlib" = yes; then - MODULE_ZLIB_TRUE= - MODULE_ZLIB_FALSE='#' -else - MODULE_ZLIB_TRUE='#' - MODULE_ZLIB_FALSE= -fi - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $py_cv_module_zlib" >&5 -printf "%s\n" "$py_cv_module_zlib" >&6; } if test "$py_cv_module_binascii" != "n/a" @@ -32677,8 +32620,8 @@ fi if test "x$py_cv_module_binascii" = xyes then : - as_fn_append MODULE_BLOCK "MODULE_BINASCII_CFLAGS=$BINASCII_CFLAGS$as_nl" - as_fn_append MODULE_BLOCK "MODULE_BINASCII_LDFLAGS=$BINASCII_LIBS$as_nl" + as_fn_append MODULE_BLOCK "MODULE_BINASCII_CFLAGS=$ZLIB_CFLAGS$as_nl" + as_fn_append MODULE_BLOCK "MODULE_BINASCII_LDFLAGS=$ZLIB_LIBS$as_nl" fi diff --git a/configure.ac b/configure.ac index 234ae90616af62..badc0aa3bf5986 100644 --- a/configure.ac +++ b/configure.ac @@ -5323,36 +5323,35 @@ if test "$ac_cv_have_lchflags" = yes ; then fi dnl Check for compression libraries -AH_TEMPLATE([HAVE_ZLIB_COPY], [Define if the zlib library has inflateCopy]) - -dnl detect zlib from Emscripten emport -PY_CHECK_EMSCRIPTEN_PORT([ZLIB], [-sUSE_ZLIB]) +AH_TEMPLATE([HAVE_ZLIB_COPY], [Define if the zlib library has inflateCopy; zlib 1.2.0 (2003) added inflateCopy.]) +dnl 2022-03: Until we know if third party zlib modules people use (for hardware +dnl accelerators, parallelism, etc.) all support copy, lets not assume. PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [ - have_zlib=yes dnl zlib 1.2.0 (2003) added inflateCopy AC_DEFINE([HAVE_ZLIB_COPY], [1]) ], [ - WITH_SAVE_ENV([ - CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS" - LIBS="$LIBS $ZLIB_LIBS" - AC_CHECK_HEADERS([zlib.h], [ - PY_CHECK_LIB([z], [gzread], [have_zlib=yes], [have_zlib=no]) - ], [have_zlib=no]) - AS_VAR_IF([have_zlib], [yes], [ - ZLIB_CFLAGS=${ZLIB_CFLAGS-""} - ZLIB_LIBS=${ZLIB_LIBS-"-lz"} - PY_CHECK_LIB([z], [inflateCopy], [AC_DEFINE([HAVE_ZLIB_COPY], [1])]) + AC_CHECK_HEADERS([zlib.h], [ + WITH_SAVE_ENV([ + AC_CHECK_LIB([z], [gzread], [ + ZLIB_CFLAGS=${ZLIB_CFLAGS-""} + ZLIB_LIBS=${ZLIB_LIBS-"-lz"} + AC_CHECK_LIB([z], [inflateCopy], [AC_DEFINE([HAVE_ZLIB_COPY], [1])]) + ], [ + AC_MSG_ERROR([m4_normalize([ + zlib.h and libz are required. Install your OS's zlib-devel or + zlib1g-dev equivalent library or get it from https://zlib.net/. + ])]) + ]) ]) + ], [ + AC_MSG_ERROR([m4_normalize([ + zlib.h and libz are required. Install your OS's zlib-devel or + zlib1g-dev equivalent library or get it from https://zlib.net/. + ])]) ]) ]) -dnl binascii can use zlib for optimized crc32. -AS_VAR_IF([have_zlib], [yes], [ - BINASCII_CFLAGS="-DUSE_ZLIB_CRC32 $ZLIB_CFLAGS" - BINASCII_LIBS="$ZLIB_LIBS" -]) - dnl detect bzip2 from Emscripten emport PY_CHECK_EMSCRIPTEN_PORT([BZIP2], [-sUSE_BZIP2]) @@ -7933,10 +7932,9 @@ PY_STDLIB_MOD([_uuid], [$LIBUUID_CFLAGS], [$LIBUUID_LIBS]) dnl compression libs -PY_STDLIB_MOD([zlib], [], [test "$have_zlib" = yes], - [$ZLIB_CFLAGS], [$ZLIB_LIBS]) -dnl binascii can use zlib for optimized crc32. -PY_STDLIB_MOD_SIMPLE([binascii], [$BINASCII_CFLAGS], [$BINASCII_LIBS]) +PY_STDLIB_MOD_SIMPLE([zlib], [$ZLIB_CFLAGS], [$ZLIB_LIBS]) +dnl binascii uses zlib for optimized crc32. +PY_STDLIB_MOD_SIMPLE([binascii], [$ZLIB_CFLAGS], [$ZLIB_LIBS]) PY_STDLIB_MOD([_bz2], [], [test "$have_bzip2" = yes], [$BZIP2_CFLAGS], [$BZIP2_LIBS]) PY_STDLIB_MOD([_lzma], [], [test "$have_liblzma" = yes], diff --git a/pyconfig.h.in b/pyconfig.h.in index 4295b4f5ea5fbd..ee4cac2ce8472a 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -1609,7 +1609,8 @@ /* Define to 1 if you have the 'writev' function. */ #undef HAVE_WRITEV -/* Define if the zlib library has inflateCopy */ +/* Define if the zlib library has inflateCopy; zlib 1.2.0 (2003) added + inflateCopy. */ #undef HAVE_ZLIB_COPY /* Define to 1 if you have the header file. */ From 937a8358afe65b05414bbe380773342e513a37b5 Mon Sep 17 00:00:00 2001 From: stan Date: Mon, 17 Feb 2025 21:21:53 +0000 Subject: [PATCH 08/30] Revert binascii changes and add exception for WASM in configure --- Modules/binascii.c | 162 +++- configure | 2113 ++++++++++++++++++++++++++++++++++++++++---- configure.ac | 52 +- 3 files changed, 2133 insertions(+), 194 deletions(-) diff --git a/Modules/binascii.c b/Modules/binascii.c index 27096c1010d8d1..e97a69a8a42cb7 100644 --- a/Modules/binascii.c +++ b/Modules/binascii.c @@ -60,7 +60,9 @@ #include "Python.h" #include "pycore_long.h" // _PyLong_DigitValue #include "pycore_strhex.h" // _Py_strhex_bytes_with_sep() -#include "zlib.h" // crc32() +#ifndef NO_ZLIB_CRC32 + #include "zlib.h" +#endif typedef struct binascii_state { PyObject *Error; @@ -614,6 +616,140 @@ binascii_crc_hqx_impl(PyObject *module, Py_buffer *data, unsigned int crc) return PyLong_FromUnsignedLong(crc); } +#ifdef NO_ZLIB_CRC32 +/* Crc - 32 BIT ANSI X3.66 CRC checksum files + Also known as: ISO 3307 +**********************************************************************| +* *| +* Demonstration program to compute the 32-bit CRC used as the frame *| +* check sequence in ADCCP (ANSI X3.66, also known as FIPS PUB 71 *| +* and FED-STD-1003, the U.S. versions of CCITT's X.25 link-level *| +* protocol). The 32-bit FCS was added via the Federal Register, *| +* 1 June 1982, p.23798. I presume but don't know for certain that *| +* this polynomial is or will be included in CCITT V.41, which *| +* defines the 16-bit CRC (often called CRC-CCITT) polynomial. FIPS *| +* PUB 78 says that the 32-bit FCS reduces otherwise undetected *| +* errors by a factor of 10^-5 over 16-bit FCS. *| +* *| +**********************************************************************| + + Copyright (C) 1986 Gary S. Brown. You may use this program, or + code or tables extracted from it, as desired without restriction. + + First, the polynomial itself and its table of feedback terms. The + polynomial is + X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 + Note that we take it "backwards" and put the highest-order term in + the lowest-order bit. The X^32 term is "implied"; the LSB is the + X^31 term, etc. The X^0 term (usually shown as "+1") results in + the MSB being 1. + + Note that the usual hardware shift register implementation, which + is what we're using (we're merely optimizing it by doing eight-bit + chunks at a time) shifts bits into the lowest-order term. In our + implementation, that means shifting towards the right. Why do we + do it this way? Because the calculated CRC must be transmitted in + order from highest-order term to lowest-order term. UARTs transmit + characters in order from LSB to MSB. By storing the CRC this way, + we hand it to the UART in the order low-byte to high-byte; the UART + sends each low-bit to hight-bit; and the result is transmission bit + by bit from highest- to lowest-order term without requiring any bit + shuffling on our part. Reception works similarly. + + The feedback terms table consists of 256, 32-bit entries. Notes: + + 1. The table can be generated at runtime if desired; code to do so + is shown later. It might not be obvious, but the feedback + terms simply represent the results of eight shift/xor opera- + tions for all combinations of data and CRC register values. + + 2. The CRC accumulation logic is the same for all CRC polynomials, + be they sixteen or thirty-two bits wide. You simply choose the + appropriate table. Alternatively, because the table can be + generated at runtime, you can start by generating the table for + the polynomial in question and use exactly the same "updcrc", + if your application needn't simultaneously handle two CRC + polynomials. (Note, however, that XMODEM is strange.) + + 3. For 16-bit CRCs, the table entries need be only 16 bits wide; + of course, 32-bit entries work OK if the high 16 bits are zero. + + 4. The values must be right-shifted by eight bits by the "updcrc" + logic; the shift must be unsigned (bring in zeroes). On some + hardware you could probably optimize the shift in assembler by + using byte-swap instructions. +********************************************************************/ + +static const unsigned int crc_32_tab[256] = { +0x00000000U, 0x77073096U, 0xee0e612cU, 0x990951baU, 0x076dc419U, +0x706af48fU, 0xe963a535U, 0x9e6495a3U, 0x0edb8832U, 0x79dcb8a4U, +0xe0d5e91eU, 0x97d2d988U, 0x09b64c2bU, 0x7eb17cbdU, 0xe7b82d07U, +0x90bf1d91U, 0x1db71064U, 0x6ab020f2U, 0xf3b97148U, 0x84be41deU, +0x1adad47dU, 0x6ddde4ebU, 0xf4d4b551U, 0x83d385c7U, 0x136c9856U, +0x646ba8c0U, 0xfd62f97aU, 0x8a65c9ecU, 0x14015c4fU, 0x63066cd9U, +0xfa0f3d63U, 0x8d080df5U, 0x3b6e20c8U, 0x4c69105eU, 0xd56041e4U, +0xa2677172U, 0x3c03e4d1U, 0x4b04d447U, 0xd20d85fdU, 0xa50ab56bU, +0x35b5a8faU, 0x42b2986cU, 0xdbbbc9d6U, 0xacbcf940U, 0x32d86ce3U, +0x45df5c75U, 0xdcd60dcfU, 0xabd13d59U, 0x26d930acU, 0x51de003aU, +0xc8d75180U, 0xbfd06116U, 0x21b4f4b5U, 0x56b3c423U, 0xcfba9599U, +0xb8bda50fU, 0x2802b89eU, 0x5f058808U, 0xc60cd9b2U, 0xb10be924U, +0x2f6f7c87U, 0x58684c11U, 0xc1611dabU, 0xb6662d3dU, 0x76dc4190U, +0x01db7106U, 0x98d220bcU, 0xefd5102aU, 0x71b18589U, 0x06b6b51fU, +0x9fbfe4a5U, 0xe8b8d433U, 0x7807c9a2U, 0x0f00f934U, 0x9609a88eU, +0xe10e9818U, 0x7f6a0dbbU, 0x086d3d2dU, 0x91646c97U, 0xe6635c01U, +0x6b6b51f4U, 0x1c6c6162U, 0x856530d8U, 0xf262004eU, 0x6c0695edU, +0x1b01a57bU, 0x8208f4c1U, 0xf50fc457U, 0x65b0d9c6U, 0x12b7e950U, +0x8bbeb8eaU, 0xfcb9887cU, 0x62dd1ddfU, 0x15da2d49U, 0x8cd37cf3U, +0xfbd44c65U, 0x4db26158U, 0x3ab551ceU, 0xa3bc0074U, 0xd4bb30e2U, +0x4adfa541U, 0x3dd895d7U, 0xa4d1c46dU, 0xd3d6f4fbU, 0x4369e96aU, +0x346ed9fcU, 0xad678846U, 0xda60b8d0U, 0x44042d73U, 0x33031de5U, +0xaa0a4c5fU, 0xdd0d7cc9U, 0x5005713cU, 0x270241aaU, 0xbe0b1010U, +0xc90c2086U, 0x5768b525U, 0x206f85b3U, 0xb966d409U, 0xce61e49fU, +0x5edef90eU, 0x29d9c998U, 0xb0d09822U, 0xc7d7a8b4U, 0x59b33d17U, +0x2eb40d81U, 0xb7bd5c3bU, 0xc0ba6cadU, 0xedb88320U, 0x9abfb3b6U, +0x03b6e20cU, 0x74b1d29aU, 0xead54739U, 0x9dd277afU, 0x04db2615U, +0x73dc1683U, 0xe3630b12U, 0x94643b84U, 0x0d6d6a3eU, 0x7a6a5aa8U, +0xe40ecf0bU, 0x9309ff9dU, 0x0a00ae27U, 0x7d079eb1U, 0xf00f9344U, +0x8708a3d2U, 0x1e01f268U, 0x6906c2feU, 0xf762575dU, 0x806567cbU, +0x196c3671U, 0x6e6b06e7U, 0xfed41b76U, 0x89d32be0U, 0x10da7a5aU, +0x67dd4accU, 0xf9b9df6fU, 0x8ebeeff9U, 0x17b7be43U, 0x60b08ed5U, +0xd6d6a3e8U, 0xa1d1937eU, 0x38d8c2c4U, 0x4fdff252U, 0xd1bb67f1U, +0xa6bc5767U, 0x3fb506ddU, 0x48b2364bU, 0xd80d2bdaU, 0xaf0a1b4cU, +0x36034af6U, 0x41047a60U, 0xdf60efc3U, 0xa867df55U, 0x316e8eefU, +0x4669be79U, 0xcb61b38cU, 0xbc66831aU, 0x256fd2a0U, 0x5268e236U, +0xcc0c7795U, 0xbb0b4703U, 0x220216b9U, 0x5505262fU, 0xc5ba3bbeU, +0xb2bd0b28U, 0x2bb45a92U, 0x5cb36a04U, 0xc2d7ffa7U, 0xb5d0cf31U, +0x2cd99e8bU, 0x5bdeae1dU, 0x9b64c2b0U, 0xec63f226U, 0x756aa39cU, +0x026d930aU, 0x9c0906a9U, 0xeb0e363fU, 0x72076785U, 0x05005713U, +0x95bf4a82U, 0xe2b87a14U, 0x7bb12baeU, 0x0cb61b38U, 0x92d28e9bU, +0xe5d5be0dU, 0x7cdcefb7U, 0x0bdbdf21U, 0x86d3d2d4U, 0xf1d4e242U, +0x68ddb3f8U, 0x1fda836eU, 0x81be16cdU, 0xf6b9265bU, 0x6fb077e1U, +0x18b74777U, 0x88085ae6U, 0xff0f6a70U, 0x66063bcaU, 0x11010b5cU, +0x8f659effU, 0xf862ae69U, 0x616bffd3U, 0x166ccf45U, 0xa00ae278U, +0xd70dd2eeU, 0x4e048354U, 0x3903b3c2U, 0xa7672661U, 0xd06016f7U, +0x4969474dU, 0x3e6e77dbU, 0xaed16a4aU, 0xd9d65adcU, 0x40df0b66U, +0x37d83bf0U, 0xa9bcae53U, 0xdebb9ec5U, 0x47b2cf7fU, 0x30b5ffe9U, +0xbdbdf21cU, 0xcabac28aU, 0x53b39330U, 0x24b4a3a6U, 0xbad03605U, +0xcdd70693U, 0x54de5729U, 0x23d967bfU, 0xb3667a2eU, 0xc4614ab8U, +0x5d681b02U, 0x2a6f2b94U, 0xb40bbe37U, 0xc30c8ea1U, 0x5a05df1bU, +0x2d02ef8dU +}; + +static unsigned int +internal_crc32(const unsigned char *bin_data, Py_ssize_t len, unsigned int crc) +{ /* By Jim Ahlstrom; All rights transferred to CNRI */ + unsigned int result; + + crc = ~ crc; + while (len-- > 0) { + crc = crc_32_tab[(crc ^ *bin_data++) & 0xff] ^ (crc >> 8); + /* Note: (crc >> 8) MUST zero fill on left */ + } + + result = (crc ^ 0xFFFFFFFF); + return result & 0xffffffff; +} +#endif /* NO_ZLIB_CRC32 */ /*[clinic input] binascii.crc32 -> unsigned_int @@ -628,8 +764,12 @@ Compute CRC-32 incrementally. static unsigned int binascii_crc32_impl(PyObject *module, Py_buffer *data, unsigned int crc) /*[clinic end generated code: output=52cf59056a78593b input=bbe340bc99d25aa8]*/ + +#ifndef NO_ZLIB_CRC32 /* This is the same as zlibmodule.c zlib_crc32_impl. It exists in two - * modules for historical reasons. We should consolidate the two. */ + modules for historical reasons. We should consolidate the two however + currently builds without zlib making this not possible. + */ { /* Releasing the GIL for very small buffers is inefficient and may lower performance */ @@ -660,6 +800,24 @@ binascii_crc32_impl(PyObject *module, Py_buffer *data, unsigned int crc) } return crc & 0xffffffff; } +#else /* NO_ZLIB_CRC32 */ +{ + const unsigned char *bin_data = data->buf; + Py_ssize_t len = data->len; + + /* Releasing the GIL for very small buffers is inefficient + and may lower performance */ + if (len > 1024*5) { + unsigned int result; + Py_BEGIN_ALLOW_THREADS + result = internal_crc32(bin_data, len, crc); + Py_END_ALLOW_THREADS + return result; + } else { + return internal_crc32(bin_data, len, crc); + } +} +#endif /* NO_ZLIB_CRC32 */ /*[clinic input] binascii.b2a_hex diff --git a/configure b/configure index 7b4d4eba9d298a..82d4106a37289a 100755 --- a/configure +++ b/configure @@ -848,12 +848,12 @@ HAVE_GETHOSTBYNAME_R_3_ARG HAVE_GETHOSTBYNAME_R_5_ARG HAVE_GETHOSTBYNAME_R_6_ARG LIBOBJS +ZLIB_LIBS +ZLIB_CFLAGS LIBLZMA_LIBS LIBLZMA_CFLAGS BZIP2_LIBS BZIP2_CFLAGS -ZLIB_LIBS -ZLIB_CFLAGS TRUE MACHDEP_OBJS DYNLOADFILE @@ -1161,12 +1161,12 @@ X11_CFLAGS X11_LIBS GDBM_CFLAGS GDBM_LIBS -ZLIB_CFLAGS -ZLIB_LIBS BZIP2_CFLAGS BZIP2_LIBS LIBLZMA_CFLAGS LIBLZMA_LIBS +ZLIB_CFLAGS +ZLIB_LIBS LIBREADLINE_CFLAGS LIBREADLINE_LIBS LIBEDIT_CFLAGS @@ -1998,13 +1998,6 @@ Some influential environment variables: GDBM_LIBS additional linker flags for gdbm ZLIB_CFLAGS C compiler flags for ZLIB, overriding pkg-config ZLIB_LIBS linker flags for ZLIB, overriding pkg-config - BZIP2_CFLAGS - C compiler flags for BZIP2, overriding pkg-config - BZIP2_LIBS linker flags for BZIP2, overriding pkg-config - LIBLZMA_CFLAGS - C compiler flags for LIBLZMA, overriding pkg-config - LIBLZMA_LIBS - linker flags for LIBLZMA, overriding pkg-config LIBREADLINE_CFLAGS C compiler flags for LIBREADLINE, overriding pkg-config LIBREADLINE_LIBS @@ -21449,6 +21442,13 @@ fi +case $ac_sys_system in #( + WASI) : + + BINASCII_CFLAGS="-DNO_ZLIB_CRC32" + ;; #( + *) : + pkg_failed=no { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for zlib >= 1.2.0" >&5 @@ -21509,20 +21509,20 @@ fi echo "$ZLIB_PKG_ERRORS" >&5 - for ac_header in zlib.h + for ac_header in zlib.h do : ac_fn_c_check_header_compile "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" if test "x$ac_cv_header_zlib_h" = xyes then : printf "%s\n" "#define HAVE_ZLIB_H 1" >>confdefs.h - save_CFLAGS=$CFLAGS + save_CFLAGS=$CFLAGS save_CPPFLAGS=$CPPFLAGS save_LDFLAGS=$LDFLAGS save_LIBS=$LIBS - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzread in -lz" >&5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzread in -lz" >&5 printf %s "checking for gzread in -lz... " >&6; } if test ${ac_cv_lib_z_gzread+y} then : @@ -21568,9 +21568,9 @@ printf "%s\n" "$ac_cv_lib_z_gzread" >&6; } if test "x$ac_cv_lib_z_gzread" = xyes then : - ZLIB_CFLAGS=${ZLIB_CFLAGS-""} - ZLIB_LIBS=${ZLIB_LIBS-"-lz"} - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5 + ZLIB_CFLAGS=${ZLIB_CFLAGS-""} + ZLIB_LIBS=${ZLIB_LIBS-"-lz"} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5 printf %s "checking for inflateCopy in -lz... " >&6; } if test ${ac_cv_lib_z_inflateCopy+y} then : @@ -21622,8 +21622,8 @@ fi else case e in #( e) - as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 - ;; + as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 + ;; esac fi @@ -21637,162 +21637,15 @@ LIBS=$save_LIBS else case e in #( e) - as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 - ;; + as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 + ;; esac fi done -elif test $pkg_failed = untried; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } - - for ac_header in zlib.h -do : - ac_fn_c_check_header_compile "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" -if test "x$ac_cv_header_zlib_h" = xyes -then : - printf "%s\n" "#define HAVE_ZLIB_H 1" >>confdefs.h - - save_CFLAGS=$CFLAGS -save_CPPFLAGS=$CPPFLAGS -save_LDFLAGS=$LDFLAGS -save_LIBS=$LIBS - - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzread in -lz" >&5 -printf %s "checking for gzread in -lz... " >&6; } -if test ${ac_cv_lib_z_gzread+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) ac_check_lib_save_LIBS=$LIBS -LIBS="-lz $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. - The 'extern "C"' is for builds by C++ compilers; - although this is not generally supported in C code supporting it here - has little cost and some practical benefit (sr 110532). */ -#ifdef __cplusplus -extern "C" -#endif -char gzread (void); -int -main (void) -{ -return gzread (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_lib_z_gzread=yes -else case e in #( - e) ac_cv_lib_z_gzread=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_gzread" >&5 -printf "%s\n" "$ac_cv_lib_z_gzread" >&6; } -if test "x$ac_cv_lib_z_gzread" = xyes -then : - - ZLIB_CFLAGS=${ZLIB_CFLAGS-""} - ZLIB_LIBS=${ZLIB_LIBS-"-lz"} - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5 -printf %s "checking for inflateCopy in -lz... " >&6; } -if test ${ac_cv_lib_z_inflateCopy+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) ac_check_lib_save_LIBS=$LIBS -LIBS="-lz $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. - The 'extern "C"' is for builds by C++ compilers; - although this is not generally supported in C code supporting it here - has little cost and some practical benefit (sr 110532). */ -#ifdef __cplusplus -extern "C" -#endif -char inflateCopy (void); -int -main (void) -{ -return inflateCopy (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_lib_z_inflateCopy=yes -else case e in #( - e) ac_cv_lib_z_inflateCopy=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_inflateCopy" >&5 -printf "%s\n" "$ac_cv_lib_z_inflateCopy" >&6; } -if test "x$ac_cv_lib_z_inflateCopy" = xyes -then : - printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h - -fi - - -else case e in #( - e) - as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 - ;; -esac -fi - - -CFLAGS=$save_CFLAGS -CPPFLAGS=$save_CPPFLAGS -LDFLAGS=$save_LDFLAGS -LIBS=$save_LIBS - - - -else case e in #( - e) - as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 - ;; + ;; esac -fi - -done - -else - ZLIB_CFLAGS=$pkg_cv_ZLIB_CFLAGS - ZLIB_LIBS=$pkg_cv_ZLIB_LIBS - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } - - printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h - - -fi @@ -21808,6 +21661,9 @@ fi + BZIP2_CFLAGS + C compiler flags for BZIP2, overriding pkg-config + BZIP2_LIBS linker flags for BZIP2, overriding pkg-config pkg_failed=no { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for bzip2" >&5 @@ -22056,6 +21912,10 @@ printf "%s\n" "yes" >&6; } have_bzip2=yes fi + LIBLZMA_CFLAGS + C compiler flags for LIBLZMA, overriding pkg-config + LIBLZMA_LIBS + linker flags for LIBLZMA, overriding pkg-config pkg_failed=no { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for liblzma" >&5 @@ -23547,7 +23407,1920 @@ then : else case e in #( e) case " $LIBOBJS " in - *" dup2.$ac_objext "* ) ;; + *" dup2.$ac_objext "* +elif test $pkg_failed = untried; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + + for ac_header in zlib.h +do : + ac_fn_c_check_header_compile "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" +if test "x$ac_cv_header_zlib_h" = xyes +then : + printf "%s\n" "#define HAVE_ZLIB_H 1" >>confdefs.h + + save_CFLAGS=$CFLAGS +save_CPPFLAGS=$CPPFLAGS +save_LDFLAGS=$LDFLAGS +save_LIBS=$LIBS + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzread in -lz" >&5 +printf %s "checking for gzread in -lz... " >&6; } +if test ${ac_cv_lib_z_gzread+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-lz $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char gzread (void); +int +main (void) +{ +return gzread (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_z_gzread=yes +else case e in #( + e) ac_cv_lib_z_gzread=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_gzread" >&5 +printf "%s\n" "$ac_cv_lib_z_gzread" >&6; } +if test "x$ac_cv_lib_z_gzread" = xyes +then : + + ZLIB_CFLAGS=${ZLIB_CFLAGS-""} + ZLIB_LIBS=${ZLIB_LIBS-"-lz"} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5 +printf %s "checking for inflateCopy in -lz... " >&6; } +if test ${ac_cv_lib_z_inflateCopy+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-lz $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char inflateCopy (void); +int +main (void) +{ +return inflateCopy (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_z_inflateCopy=yes +else case e in #( + e) ac_cv_lib_z_inflateCopy=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_inflateCopy" >&5 +printf "%s\n" "$ac_cv_lib_z_inflateCopy" >&6; } +if test "x$ac_cv_lib_z_inflateCopy" = xyes +then : + printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h + +fi + + +else case e in #( + e) + as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 + ;; +esac +fi + + +CFLAGS=$save_CFLAGS +CPPFLAGS=$save_CPPFLAGS +LDFLAGS=$save_LDFLAGS +LIBS=$save_LIBS + + + +else case e in #( + e) + as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 + ;; +esac +fi + +done + + ;; +esac + + + + + if test "$ac_sys_system" = "Emscripten" -a -z "$BZIP2_CFLAGS" -a -z "$BZIP2_LIBS" +then : + + BZIP2_CFLAGS="-sUSE_BZIP2" + BZIP2_LIBS="-sUSE_BZIP2" + +fi + + + + + BZIP2_CFLAGS + C compiler flags for BZIP2, overriding pkg-config + BZIP2_LIBS linker flags for BZIP2, overriding pkg-config + +pkg_failed=no +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for bzip2" >&5 +printf %s "checking for bzip2... " >&6; } + +if test -n "$BZIP2_CFLAGS"; then + pkg_cv_BZIP2_CFLAGS="$BZIP2_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"bzip2\""; } >&5 + ($PKG_CONFIG --exists --print-errors "bzip2") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_BZIP2_CFLAGS=`$PKG_CONFIG --cflags "bzip2" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$BZIP2_LIBS"; then + pkg_cv_BZIP2_LIBS="$BZIP2_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"bzip2\""; } >&5 + ($PKG_CONFIG --exists --print-errors "bzip2") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_BZIP2_LIBS=`$PKG_CONFIG --libs "bzip2" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + BZIP2_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "bzip2" 2>&1` + else + BZIP2_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "bzip2" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$BZIP2_PKG_ERRORS" >&5 + + + save_CFLAGS=$CFLAGS +save_CPPFLAGS=$CPPFLAGS +save_LDFLAGS=$LDFLAGS +save_LIBS=$LIBS + + + CPPFLAGS="$CPPFLAGS $BZIP2_CFLAGS" + LIBS="$LIBS $BZIP2_LIBS" + for ac_header in bzlib.h +do : + ac_fn_c_check_header_compile "$LINENO" "bzlib.h" "ac_cv_header_bzlib_h" "$ac_includes_default" +if test "x$ac_cv_header_bzlib_h" = xyes +then : + printf "%s\n" "#define HAVE_BZLIB_H 1" >>confdefs.h + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for BZ2_bzCompress in -lbz2" >&5 +printf %s "checking for BZ2_bzCompress in -lbz2... " >&6; } +if test ${ac_cv_lib_bz2_BZ2_bzCompress+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-lbz2 $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char BZ2_bzCompress (void); +int +main (void) +{ +return BZ2_bzCompress (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_bz2_BZ2_bzCompress=yes +else case e in #( + e) ac_cv_lib_bz2_BZ2_bzCompress=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bz2_BZ2_bzCompress" >&5 +printf "%s\n" "$ac_cv_lib_bz2_BZ2_bzCompress" >&6; } +if test "x$ac_cv_lib_bz2_BZ2_bzCompress" = xyes +then : + have_bzip2=yes +else case e in #( + e) have_bzip2=no ;; +esac +fi + + +else case e in #( + e) have_bzip2=no ;; +esac +fi + +done + if test "x$have_bzip2" = xyes +then : + + BZIP2_CFLAGS=${BZIP2_CFLAGS-""} + BZIP2_LIBS=${BZIP2_LIBS-"-lbz2"} + +fi + +CFLAGS=$save_CFLAGS +CPPFLAGS=$save_CPPFLAGS +LDFLAGS=$save_LDFLAGS +LIBS=$save_LIBS + + + +elif test $pkg_failed = untried; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + + save_CFLAGS=$CFLAGS +save_CPPFLAGS=$CPPFLAGS +save_LDFLAGS=$LDFLAGS +save_LIBS=$LIBS + + + CPPFLAGS="$CPPFLAGS $BZIP2_CFLAGS" + LIBS="$LIBS $BZIP2_LIBS" + for ac_header in bzlib.h +do : + ac_fn_c_check_header_compile "$LINENO" "bzlib.h" "ac_cv_header_bzlib_h" "$ac_includes_default" +if test "x$ac_cv_header_bzlib_h" = xyes +then : + printf "%s\n" "#define HAVE_BZLIB_H 1" >>confdefs.h + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for BZ2_bzCompress in -lbz2" >&5 +printf %s "checking for BZ2_bzCompress in -lbz2... " >&6; } +if test ${ac_cv_lib_bz2_BZ2_bzCompress+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-lbz2 $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char BZ2_bzCompress (void); +int +main (void) +{ +return BZ2_bzCompress (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_bz2_BZ2_bzCompress=yes +else case e in #( + e) ac_cv_lib_bz2_BZ2_bzCompress=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bz2_BZ2_bzCompress" >&5 +printf "%s\n" "$ac_cv_lib_bz2_BZ2_bzCompress" >&6; } +if test "x$ac_cv_lib_bz2_BZ2_bzCompress" = xyes +then : + have_bzip2=yes +else case e in #( + e) have_bzip2=no ;; +esac +fi + + +else case e in #( + e) have_bzip2=no ;; +esac +fi + +done + if test "x$have_bzip2" = xyes +then : + + BZIP2_CFLAGS=${BZIP2_CFLAGS-""} + BZIP2_LIBS=${BZIP2_LIBS-"-lbz2"} + +fi + +CFLAGS=$save_CFLAGS +CPPFLAGS=$save_CPPFLAGS +LDFLAGS=$save_LDFLAGS +LIBS=$save_LIBS + + + +else + BZIP2_CFLAGS=$pkg_cv_BZIP2_CFLAGS + BZIP2_LIBS=$pkg_cv_BZIP2_LIBS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + have_bzip2=yes +fi + + LIBLZMA_CFLAGS + C compiler flags for LIBLZMA, overriding pkg-config + LIBLZMA_LIBS + linker flags for LIBLZMA, overriding pkg-config + +pkg_failed=no +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for liblzma" >&5 +printf %s "checking for liblzma... " >&6; } + +if test -n "$LIBLZMA_CFLAGS"; then + pkg_cv_LIBLZMA_CFLAGS="$LIBLZMA_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"liblzma\""; } >&5 + ($PKG_CONFIG --exists --print-errors "liblzma") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBLZMA_CFLAGS=`$PKG_CONFIG --cflags "liblzma" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$LIBLZMA_LIBS"; then + pkg_cv_LIBLZMA_LIBS="$LIBLZMA_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"liblzma\""; } >&5 + ($PKG_CONFIG --exists --print-errors "liblzma") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBLZMA_LIBS=`$PKG_CONFIG --libs "liblzma" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + LIBLZMA_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "liblzma" 2>&1` + else + LIBLZMA_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "liblzma" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$LIBLZMA_PKG_ERRORS" >&5 + + + save_CFLAGS=$CFLAGS +save_CPPFLAGS=$CPPFLAGS +save_LDFLAGS=$LDFLAGS +save_LIBS=$LIBS + + + CPPFLAGS="$CPPFLAGS $LIBLZMA_CFLAGS" + LIBS="$LIBS $LIBLZMA_LIBS" + for ac_header in lzma.h +do : + ac_fn_c_check_header_compile "$LINENO" "lzma.h" "ac_cv_header_lzma_h" "$ac_includes_default" +if test "x$ac_cv_header_lzma_h" = xyes +then : + printf "%s\n" "#define HAVE_LZMA_H 1" >>confdefs.h + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for lzma_easy_encoder in -llzma" >&5 +printf %s "checking for lzma_easy_encoder in -llzma... " >&6; } +if test ${ac_cv_lib_lzma_lzma_easy_encoder+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-llzma $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char lzma_easy_encoder (void); +int +main (void) +{ +return lzma_easy_encoder (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_lzma_lzma_easy_encoder=yes +else case e in #( + e) ac_cv_lib_lzma_lzma_easy_encoder=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lzma_lzma_easy_encoder" >&5 +printf "%s\n" "$ac_cv_lib_lzma_lzma_easy_encoder" >&6; } +if test "x$ac_cv_lib_lzma_lzma_easy_encoder" = xyes +then : + have_liblzma=yes +else case e in #( + e) have_liblzma=no ;; +esac +fi + + +else case e in #( + e) have_liblzma=no ;; +esac +fi + +done + if test "x$have_liblzma" = xyes +then : + + LIBLZMA_CFLAGS=${LIBLZMA_CFLAGS-""} + LIBLZMA_LIBS=${LIBLZMA_LIBS-"-llzma"} + +fi + +CFLAGS=$save_CFLAGS +CPPFLAGS=$save_CPPFLAGS +LDFLAGS=$save_LDFLAGS +LIBS=$save_LIBS + + + +elif test $pkg_failed = untried; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + + save_CFLAGS=$CFLAGS +save_CPPFLAGS=$CPPFLAGS +save_LDFLAGS=$LDFLAGS +save_LIBS=$LIBS + + + CPPFLAGS="$CPPFLAGS $LIBLZMA_CFLAGS" + LIBS="$LIBS $LIBLZMA_LIBS" + for ac_header in lzma.h +do : + ac_fn_c_check_header_compile "$LINENO" "lzma.h" "ac_cv_header_lzma_h" "$ac_includes_default" +if test "x$ac_cv_header_lzma_h" = xyes +then : + printf "%s\n" "#define HAVE_LZMA_H 1" >>confdefs.h + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for lzma_easy_encoder in -llzma" >&5 +printf %s "checking for lzma_easy_encoder in -llzma... " >&6; } +if test ${ac_cv_lib_lzma_lzma_easy_encoder+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-llzma $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char lzma_easy_encoder (void); +int +main (void) +{ +return lzma_easy_encoder (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_lzma_lzma_easy_encoder=yes +else case e in #( + e) ac_cv_lib_lzma_lzma_easy_encoder=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lzma_lzma_easy_encoder" >&5 +printf "%s\n" "$ac_cv_lib_lzma_lzma_easy_encoder" >&6; } +if test "x$ac_cv_lib_lzma_lzma_easy_encoder" = xyes +then : + have_liblzma=yes +else case e in #( + e) have_liblzma=no ;; +esac +fi + + +else case e in #( + e) have_liblzma=no ;; +esac +fi + +done + if test "x$have_liblzma" = xyes +then : + + LIBLZMA_CFLAGS=${LIBLZMA_CFLAGS-""} + LIBLZMA_LIBS=${LIBLZMA_LIBS-"-llzma"} + +fi + +CFLAGS=$save_CFLAGS +CPPFLAGS=$save_CPPFLAGS +LDFLAGS=$save_LDFLAGS +LIBS=$save_LIBS + + + +else + LIBLZMA_CFLAGS=$pkg_cv_LIBLZMA_CFLAGS + LIBLZMA_LIBS=$pkg_cv_LIBLZMA_LIBS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + have_liblzma=yes +fi + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for hstrerror" >&5 +printf %s "checking for hstrerror... " >&6; } +if test ${ac_cv_func_hstrerror+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +void *x=hstrerror + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_hstrerror=yes +else case e in #( + e) ac_cv_func_hstrerror=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_hstrerror" >&5 +printf "%s\n" "$ac_cv_func_hstrerror" >&6; } + if test "x$ac_cv_func_hstrerror" = xyes +then : + +printf "%s\n" "#define HAVE_HSTRERROR 1" >>confdefs.h + +fi + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for getservbyname" >&5 +printf %s "checking for getservbyname... " >&6; } +if test ${ac_cv_func_getservbyname+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +void *x=getservbyname + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_getservbyname=yes +else case e in #( + e) ac_cv_func_getservbyname=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_getservbyname" >&5 +printf "%s\n" "$ac_cv_func_getservbyname" >&6; } + if test "x$ac_cv_func_getservbyname" = xyes +then : + +printf "%s\n" "#define HAVE_GETSERVBYNAME 1" >>confdefs.h + +fi + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for getservbyport" >&5 +printf %s "checking for getservbyport... " >&6; } +if test ${ac_cv_func_getservbyport+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +void *x=getservbyport + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_getservbyport=yes +else case e in #( + e) ac_cv_func_getservbyport=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_getservbyport" >&5 +printf "%s\n" "$ac_cv_func_getservbyport" >&6; } + if test "x$ac_cv_func_getservbyport" = xyes +then : + +printf "%s\n" "#define HAVE_GETSERVBYPORT 1" >>confdefs.h + +fi + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gethostbyname" >&5 +printf %s "checking for gethostbyname... " >&6; } +if test ${ac_cv_func_gethostbyname+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +void *x=gethostbyname + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_gethostbyname=yes +else case e in #( + e) ac_cv_func_gethostbyname=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_gethostbyname" >&5 +printf "%s\n" "$ac_cv_func_gethostbyname" >&6; } + if test "x$ac_cv_func_gethostbyname" = xyes +then : + +printf "%s\n" "#define HAVE_GETHOSTBYNAME 1" >>confdefs.h + +fi + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gethostbyaddr" >&5 +printf %s "checking for gethostbyaddr... " >&6; } +if test ${ac_cv_func_gethostbyaddr+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +void *x=gethostbyaddr + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_gethostbyaddr=yes +else case e in #( + e) ac_cv_func_gethostbyaddr=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_gethostbyaddr" >&5 +printf "%s\n" "$ac_cv_func_gethostbyaddr" >&6; } + if test "x$ac_cv_func_gethostbyaddr" = xyes +then : + +printf "%s\n" "#define HAVE_GETHOSTBYADDR 1" >>confdefs.h + +fi + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for getprotobyname" >&5 +printf %s "checking for getprotobyname... " >&6; } +if test ${ac_cv_func_getprotobyname+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main (void) +{ +void *x=getprotobyname + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_getprotobyname=yes +else case e in #( + e) ac_cv_func_getprotobyname=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_getprotobyname" >&5 +printf "%s\n" "$ac_cv_func_getprotobyname" >&6; } + if test "x$ac_cv_func_getprotobyname" = xyes +then : + +printf "%s\n" "#define HAVE_GETPROTOBYNAME 1" >>confdefs.h + +fi + + + + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inet_aton" >&5 +printf %s "checking for inet_aton... " >&6; } +if test ${ac_cv_func_inet_aton+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include + +int +main (void) +{ +void *x=inet_aton + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_inet_aton=yes +else case e in #( + e) ac_cv_func_inet_aton=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_inet_aton" >&5 +printf "%s\n" "$ac_cv_func_inet_aton" >&6; } + if test "x$ac_cv_func_inet_aton" = xyes +then : + +printf "%s\n" "#define HAVE_INET_ATON 1" >>confdefs.h + +fi + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inet_ntoa" >&5 +printf %s "checking for inet_ntoa... " >&6; } +if test ${ac_cv_func_inet_ntoa+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include + +int +main (void) +{ +void *x=inet_ntoa + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_inet_ntoa=yes +else case e in #( + e) ac_cv_func_inet_ntoa=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_inet_ntoa" >&5 +printf "%s\n" "$ac_cv_func_inet_ntoa" >&6; } + if test "x$ac_cv_func_inet_ntoa" = xyes +then : + +printf "%s\n" "#define HAVE_INET_NTOA 1" >>confdefs.h + +fi + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inet_pton" >&5 +printf %s "checking for inet_pton... " >&6; } +if test ${ac_cv_func_inet_pton+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include + +int +main (void) +{ +void *x=inet_pton + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_inet_pton=yes +else case e in #( + e) ac_cv_func_inet_pton=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_inet_pton" >&5 +printf "%s\n" "$ac_cv_func_inet_pton" >&6; } + if test "x$ac_cv_func_inet_pton" = xyes +then : + +printf "%s\n" "#define HAVE_INET_PTON 1" >>confdefs.h + +fi + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for getpeername" >&5 +printf %s "checking for getpeername... " >&6; } +if test ${ac_cv_func_getpeername+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include + +int +main (void) +{ +void *x=getpeername + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_getpeername=yes +else case e in #( + e) ac_cv_func_getpeername=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_getpeername" >&5 +printf "%s\n" "$ac_cv_func_getpeername" >&6; } + if test "x$ac_cv_func_getpeername" = xyes +then : + +printf "%s\n" "#define HAVE_GETPEERNAME 1" >>confdefs.h + +fi + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for getsockname" >&5 +printf %s "checking for getsockname... " >&6; } +if test ${ac_cv_func_getsockname+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include + +int +main (void) +{ +void *x=getsockname + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_getsockname=yes +else case e in #( + e) ac_cv_func_getsockname=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_getsockname" >&5 +printf "%s\n" "$ac_cv_func_getsockname" >&6; } + if test "x$ac_cv_func_getsockname" = xyes +then : + +printf "%s\n" "#define HAVE_GETSOCKNAME 1" >>confdefs.h + +fi + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for accept" >&5 +printf %s "checking for accept... " >&6; } +if test ${ac_cv_func_accept+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include + +int +main (void) +{ +void *x=accept + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_accept=yes +else case e in #( + e) ac_cv_func_accept=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_accept" >&5 +printf "%s\n" "$ac_cv_func_accept" >&6; } + if test "x$ac_cv_func_accept" = xyes +then : + +printf "%s\n" "#define HAVE_ACCEPT 1" >>confdefs.h + +fi + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for bind" >&5 +printf %s "checking for bind... " >&6; } +if test ${ac_cv_func_bind+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include + +int +main (void) +{ +void *x=bind + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_bind=yes +else case e in #( + e) ac_cv_func_bind=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_bind" >&5 +printf "%s\n" "$ac_cv_func_bind" >&6; } + if test "x$ac_cv_func_bind" = xyes +then : + +printf "%s\n" "#define HAVE_BIND 1" >>confdefs.h + +fi + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for connect" >&5 +printf %s "checking for connect... " >&6; } +if test ${ac_cv_func_connect+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include + +int +main (void) +{ +void *x=connect + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_connect=yes +else case e in #( + e) ac_cv_func_connect=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_connect" >&5 +printf "%s\n" "$ac_cv_func_connect" >&6; } + if test "x$ac_cv_func_connect" = xyes +then : + +printf "%s\n" "#define HAVE_CONNECT 1" >>confdefs.h + +fi + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for listen" >&5 +printf %s "checking for listen... " >&6; } +if test ${ac_cv_func_listen+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include + +int +main (void) +{ +void *x=listen + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_listen=yes +else case e in #( + e) ac_cv_func_listen=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_listen" >&5 +printf "%s\n" "$ac_cv_func_listen" >&6; } + if test "x$ac_cv_func_listen" = xyes +then : + +printf "%s\n" "#define HAVE_LISTEN 1" >>confdefs.h + +fi + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for recvfrom" >&5 +printf %s "checking for recvfrom... " >&6; } +if test ${ac_cv_func_recvfrom+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include + +int +main (void) +{ +void *x=recvfrom + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_recvfrom=yes +else case e in #( + e) ac_cv_func_recvfrom=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_recvfrom" >&5 +printf "%s\n" "$ac_cv_func_recvfrom" >&6; } + if test "x$ac_cv_func_recvfrom" = xyes +then : + +printf "%s\n" "#define HAVE_RECVFROM 1" >>confdefs.h + +fi + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sendto" >&5 +printf %s "checking for sendto... " >&6; } +if test ${ac_cv_func_sendto+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include + +int +main (void) +{ +void *x=sendto + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_sendto=yes +else case e in #( + e) ac_cv_func_sendto=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_sendto" >&5 +printf "%s\n" "$ac_cv_func_sendto" >&6; } + if test "x$ac_cv_func_sendto" = xyes +then : + +printf "%s\n" "#define HAVE_SENDTO 1" >>confdefs.h + +fi + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for setsockopt" >&5 +printf %s "checking for setsockopt... " >&6; } +if test ${ac_cv_func_setsockopt+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include + +int +main (void) +{ +void *x=setsockopt + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_setsockopt=yes +else case e in #( + e) ac_cv_func_setsockopt=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_setsockopt" >&5 +printf "%s\n" "$ac_cv_func_setsockopt" >&6; } + if test "x$ac_cv_func_setsockopt" = xyes +then : + +printf "%s\n" "#define HAVE_SETSOCKOPT 1" >>confdefs.h + +fi + + + + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for socket" >&5 +printf %s "checking for socket... " >&6; } +if test ${ac_cv_func_socket+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include + +int +main (void) +{ +void *x=socket + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_socket=yes +else case e in #( + e) ac_cv_func_socket=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_socket" >&5 +printf "%s\n" "$ac_cv_func_socket" >&6; } + if test "x$ac_cv_func_socket" = xyes +then : + +printf "%s\n" "#define HAVE_SOCKET 1" >>confdefs.h + +fi + + + + +# On some systems, setgroups is in unistd.h, on others, in grp.h + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for setgroups" >&5 +printf %s "checking for setgroups... " >&6; } +if test ${ac_cv_func_setgroups+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#ifdef HAVE_GRP_H +#include +#endif + +int +main (void) +{ +void *x=setgroups + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_func_setgroups=yes +else case e in #( + e) ac_cv_func_setgroups=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_setgroups" >&5 +printf "%s\n" "$ac_cv_func_setgroups" >&6; } + if test "x$ac_cv_func_setgroups" = xyes +then : + +printf "%s\n" "#define HAVE_SETGROUPS 1" >>confdefs.h + +fi + + + + +# check for openpty, login_tty, and forkpty + + + for ac_func in openpty +do : + ac_fn_c_check_func "$LINENO" "openpty" "ac_cv_func_openpty" +if test "x$ac_cv_func_openpty" = xyes +then : + printf "%s\n" "#define HAVE_OPENPTY 1" >>confdefs.h + +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for openpty in -lutil" >&5 +printf %s "checking for openpty in -lutil... " >&6; } +if test ${ac_cv_lib_util_openpty+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-lutil $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char openpty (void); +int +main (void) +{ +return openpty (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_util_openpty=yes +else case e in #( + e) ac_cv_lib_util_openpty=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_util_openpty" >&5 +printf "%s\n" "$ac_cv_lib_util_openpty" >&6; } +if test "x$ac_cv_lib_util_openpty" = xyes +then : + printf "%s\n" "#define HAVE_OPENPTY 1" >>confdefs.h + LIBS="$LIBS -lutil" +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for openpty in -lbsd" >&5 +printf %s "checking for openpty in -lbsd... " >&6; } +if test ${ac_cv_lib_bsd_openpty+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-lbsd $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char openpty (void); +int +main (void) +{ +return openpty (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_bsd_openpty=yes +else case e in #( + e) ac_cv_lib_bsd_openpty=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_openpty" >&5 +printf "%s\n" "$ac_cv_lib_bsd_openpty" >&6; } +if test "x$ac_cv_lib_bsd_openpty" = xyes +then : + printf "%s\n" "#define HAVE_OPENPTY 1" >>confdefs.h + LIBS="$LIBS -lbsd" +fi + ;; +esac +fi + ;; +esac +fi + +done +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing login_tty" >&5 +printf %s "checking for library containing login_tty... " >&6; } +if test ${ac_cv_search_login_tty+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char login_tty (void); +int +main (void) +{ +return login_tty (); + ; + return 0; +} +_ACEOF +for ac_lib in '' util +do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO" +then : + ac_cv_search_login_tty=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext + if test ${ac_cv_search_login_tty+y} +then : + break +fi +done +if test ${ac_cv_search_login_tty+y} +then : + +else case e in #( + e) ac_cv_search_login_tty=no ;; +esac +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_login_tty" >&5 +printf "%s\n" "$ac_cv_search_login_tty" >&6; } +ac_res=$ac_cv_search_login_tty +if test "$ac_res" != no +then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +printf "%s\n" "#define HAVE_LOGIN_TTY 1" >>confdefs.h + + +fi + + + for ac_func in forkpty +do : + ac_fn_c_check_func "$LINENO" "forkpty" "ac_cv_func_forkpty" +if test "x$ac_cv_func_forkpty" = xyes +then : + printf "%s\n" "#define HAVE_FORKPTY 1" >>confdefs.h + +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for forkpty in -lutil" >&5 +printf %s "checking for forkpty in -lutil... " >&6; } +if test ${ac_cv_lib_util_forkpty+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-lutil $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char forkpty (void); +int +main (void) +{ +return forkpty (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_util_forkpty=yes +else case e in #( + e) ac_cv_lib_util_forkpty=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_util_forkpty" >&5 +printf "%s\n" "$ac_cv_lib_util_forkpty" >&6; } +if test "x$ac_cv_lib_util_forkpty" = xyes +then : + printf "%s\n" "#define HAVE_FORKPTY 1" >>confdefs.h + LIBS="$LIBS -lutil" +else case e in #( + e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for forkpty in -lbsd" >&5 +printf %s "checking for forkpty in -lbsd... " >&6; } +if test ${ac_cv_lib_bsd_forkpty+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-lbsd $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char forkpty (void); +int +main (void) +{ +return forkpty (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_bsd_forkpty=yes +else case e in #( + e) ac_cv_lib_bsd_forkpty=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_forkpty" >&5 +printf "%s\n" "$ac_cv_lib_bsd_forkpty" >&6; } +if test "x$ac_cv_lib_bsd_forkpty" = xyes +then : + printf "%s\n" "#define HAVE_FORKPTY 1" >>confdefs.h + LIBS="$LIBS -lbsd" +fi + ;; +esac +fi + ;; +esac +fi + +done + +# check for long file support functions +ac_fn_c_check_func "$LINENO" "fseek64" "ac_cv_func_fseek64" +if test "x$ac_cv_func_fseek64" = xyes +then : + printf "%s\n" "#define HAVE_FSEEK64 1" >>confdefs.h + +fi +ac_fn_c_check_func "$LINENO" "fseeko" "ac_cv_func_fseeko" +if test "x$ac_cv_func_fseeko" = xyes +then : + printf "%s\n" "#define HAVE_FSEEKO 1" >>confdefs.h + +fi +ac_fn_c_check_func "$LINENO" "fstatvfs" "ac_cv_func_fstatvfs" +if test "x$ac_cv_func_fstatvfs" = xyes +then : + printf "%s\n" "#define HAVE_FSTATVFS 1" >>confdefs.h + +fi +ac_fn_c_check_func "$LINENO" "ftell64" "ac_cv_func_ftell64" +if test "x$ac_cv_func_ftell64" = xyes +then : + printf "%s\n" "#define HAVE_FTELL64 1" >>confdefs.h + +fi +ac_fn_c_check_func "$LINENO" "ftello" "ac_cv_func_ftello" +if test "x$ac_cv_func_ftello" = xyes +then : + printf "%s\n" "#define HAVE_FTELLO 1" >>confdefs.h + +fi +ac_fn_c_check_func "$LINENO" "statvfs" "ac_cv_func_statvfs" +if test "x$ac_cv_func_statvfs" = xyes +then : + printf "%s\n" "#define HAVE_STATVFS 1" >>confdefs.h + +fi + + +ac_fn_c_check_func "$LINENO" "dup2" "ac_cv_func_dup2" +if test "x$ac_cv_func_dup2" = xyes +then : + printf "%s\n" "#define HAVE_DUP2 1" >>confdefs.h + +else case e in #( + e) case " $LIBOBJS " in + *" dup2.$ac_objext "* +else + ZLIB_CFLAGS=$pkg_cv_ZLIB_CFLAGS + ZLIB_LIBS=$pkg_cv_ZLIB_LIBS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + + printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h + + +fi ;; *) LIBOBJS="$LIBOBJS dup2.$ac_objext" ;; esac diff --git a/configure.ac b/configure.ac index badc0aa3bf5986..5d097d8e1c6353 100644 --- a/configure.ac +++ b/configure.ac @@ -5327,29 +5327,37 @@ AH_TEMPLATE([HAVE_ZLIB_COPY], [Define if the zlib library has inflateCopy; zlib dnl 2022-03: Until we know if third party zlib modules people use (for hardware dnl accelerators, parallelism, etc.) all support copy, lets not assume. -PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [ - dnl zlib 1.2.0 (2003) added inflateCopy - AC_DEFINE([HAVE_ZLIB_COPY], [1]) -], [ - AC_CHECK_HEADERS([zlib.h], [ - WITH_SAVE_ENV([ - AC_CHECK_LIB([z], [gzread], [ - ZLIB_CFLAGS=${ZLIB_CFLAGS-""} - ZLIB_LIBS=${ZLIB_LIBS-"-lz"} - AC_CHECK_LIB([z], [inflateCopy], [AC_DEFINE([HAVE_ZLIB_COPY], [1])]) +AS_CASE([$ac_sys_system], + [WASI], + [ + dnl WASM does not have zlib + BINASCII_CFLAGS="-DNO_ZLIB_CRC32" + ], + [ + PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [ + dnl zlib 1.2.0 (2003) added inflateCopy + AC_DEFINE([HAVE_ZLIB_COPY], [1]) ], [ - AC_MSG_ERROR([m4_normalize([ - zlib.h and libz are required. Install your OS's zlib-devel or - zlib1g-dev equivalent library or get it from https://zlib.net/. - ])]) - ]) - ]) - ], [ - AC_MSG_ERROR([m4_normalize([ - zlib.h and libz are required. Install your OS's zlib-devel or - zlib1g-dev equivalent library or get it from https://zlib.net/. - ])]) - ]) + AC_CHECK_HEADERS([zlib.h], [ + WITH_SAVE_ENV([ + AC_CHECK_LIB([z], [gzread], [ + ZLIB_CFLAGS=${ZLIB_CFLAGS-""} + ZLIB_LIBS=${ZLIB_LIBS-"-lz"} + AC_CHECK_LIB([z], [inflateCopy], [AC_DEFINE([HAVE_ZLIB_COPY], [1])]) + ], [ + AC_MSG_ERROR([m4_normalize([ + zlib.h and libz are required. Install your OS's zlib-devel or + zlib1g-dev equivalent library or get it from https://zlib.net/. + ])]) + ]) + ]) + ], [ + AC_MSG_ERROR([m4_normalize([ + zlib.h and libz are required. Install your OS's zlib-devel or + zlib1g-dev equivalent library or get it from https://zlib.net/. + ])]) + ]) + ] ]) dnl detect bzip2 from Emscripten emport From 40a3c8b7a24837b5d349966ad45872cfd8012a6b Mon Sep 17 00:00:00 2001 From: stan Date: Mon, 17 Feb 2025 21:33:54 +0000 Subject: [PATCH 09/30] Revert "Revert binascii changes and add exception for WASM in configure" This reverts commit 937a8358afe65b05414bbe380773342e513a37b5. --- Modules/binascii.c | 162 +--- configure | 2113 ++++---------------------------------------- configure.ac | 52 +- 3 files changed, 194 insertions(+), 2133 deletions(-) diff --git a/Modules/binascii.c b/Modules/binascii.c index e97a69a8a42cb7..27096c1010d8d1 100644 --- a/Modules/binascii.c +++ b/Modules/binascii.c @@ -60,9 +60,7 @@ #include "Python.h" #include "pycore_long.h" // _PyLong_DigitValue #include "pycore_strhex.h" // _Py_strhex_bytes_with_sep() -#ifndef NO_ZLIB_CRC32 - #include "zlib.h" -#endif +#include "zlib.h" // crc32() typedef struct binascii_state { PyObject *Error; @@ -616,140 +614,6 @@ binascii_crc_hqx_impl(PyObject *module, Py_buffer *data, unsigned int crc) return PyLong_FromUnsignedLong(crc); } -#ifdef NO_ZLIB_CRC32 -/* Crc - 32 BIT ANSI X3.66 CRC checksum files - Also known as: ISO 3307 -**********************************************************************| -* *| -* Demonstration program to compute the 32-bit CRC used as the frame *| -* check sequence in ADCCP (ANSI X3.66, also known as FIPS PUB 71 *| -* and FED-STD-1003, the U.S. versions of CCITT's X.25 link-level *| -* protocol). The 32-bit FCS was added via the Federal Register, *| -* 1 June 1982, p.23798. I presume but don't know for certain that *| -* this polynomial is or will be included in CCITT V.41, which *| -* defines the 16-bit CRC (often called CRC-CCITT) polynomial. FIPS *| -* PUB 78 says that the 32-bit FCS reduces otherwise undetected *| -* errors by a factor of 10^-5 over 16-bit FCS. *| -* *| -**********************************************************************| - - Copyright (C) 1986 Gary S. Brown. You may use this program, or - code or tables extracted from it, as desired without restriction. - - First, the polynomial itself and its table of feedback terms. The - polynomial is - X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 - Note that we take it "backwards" and put the highest-order term in - the lowest-order bit. The X^32 term is "implied"; the LSB is the - X^31 term, etc. The X^0 term (usually shown as "+1") results in - the MSB being 1. - - Note that the usual hardware shift register implementation, which - is what we're using (we're merely optimizing it by doing eight-bit - chunks at a time) shifts bits into the lowest-order term. In our - implementation, that means shifting towards the right. Why do we - do it this way? Because the calculated CRC must be transmitted in - order from highest-order term to lowest-order term. UARTs transmit - characters in order from LSB to MSB. By storing the CRC this way, - we hand it to the UART in the order low-byte to high-byte; the UART - sends each low-bit to hight-bit; and the result is transmission bit - by bit from highest- to lowest-order term without requiring any bit - shuffling on our part. Reception works similarly. - - The feedback terms table consists of 256, 32-bit entries. Notes: - - 1. The table can be generated at runtime if desired; code to do so - is shown later. It might not be obvious, but the feedback - terms simply represent the results of eight shift/xor opera- - tions for all combinations of data and CRC register values. - - 2. The CRC accumulation logic is the same for all CRC polynomials, - be they sixteen or thirty-two bits wide. You simply choose the - appropriate table. Alternatively, because the table can be - generated at runtime, you can start by generating the table for - the polynomial in question and use exactly the same "updcrc", - if your application needn't simultaneously handle two CRC - polynomials. (Note, however, that XMODEM is strange.) - - 3. For 16-bit CRCs, the table entries need be only 16 bits wide; - of course, 32-bit entries work OK if the high 16 bits are zero. - - 4. The values must be right-shifted by eight bits by the "updcrc" - logic; the shift must be unsigned (bring in zeroes). On some - hardware you could probably optimize the shift in assembler by - using byte-swap instructions. -********************************************************************/ - -static const unsigned int crc_32_tab[256] = { -0x00000000U, 0x77073096U, 0xee0e612cU, 0x990951baU, 0x076dc419U, -0x706af48fU, 0xe963a535U, 0x9e6495a3U, 0x0edb8832U, 0x79dcb8a4U, -0xe0d5e91eU, 0x97d2d988U, 0x09b64c2bU, 0x7eb17cbdU, 0xe7b82d07U, -0x90bf1d91U, 0x1db71064U, 0x6ab020f2U, 0xf3b97148U, 0x84be41deU, -0x1adad47dU, 0x6ddde4ebU, 0xf4d4b551U, 0x83d385c7U, 0x136c9856U, -0x646ba8c0U, 0xfd62f97aU, 0x8a65c9ecU, 0x14015c4fU, 0x63066cd9U, -0xfa0f3d63U, 0x8d080df5U, 0x3b6e20c8U, 0x4c69105eU, 0xd56041e4U, -0xa2677172U, 0x3c03e4d1U, 0x4b04d447U, 0xd20d85fdU, 0xa50ab56bU, -0x35b5a8faU, 0x42b2986cU, 0xdbbbc9d6U, 0xacbcf940U, 0x32d86ce3U, -0x45df5c75U, 0xdcd60dcfU, 0xabd13d59U, 0x26d930acU, 0x51de003aU, -0xc8d75180U, 0xbfd06116U, 0x21b4f4b5U, 0x56b3c423U, 0xcfba9599U, -0xb8bda50fU, 0x2802b89eU, 0x5f058808U, 0xc60cd9b2U, 0xb10be924U, -0x2f6f7c87U, 0x58684c11U, 0xc1611dabU, 0xb6662d3dU, 0x76dc4190U, -0x01db7106U, 0x98d220bcU, 0xefd5102aU, 0x71b18589U, 0x06b6b51fU, -0x9fbfe4a5U, 0xe8b8d433U, 0x7807c9a2U, 0x0f00f934U, 0x9609a88eU, -0xe10e9818U, 0x7f6a0dbbU, 0x086d3d2dU, 0x91646c97U, 0xe6635c01U, -0x6b6b51f4U, 0x1c6c6162U, 0x856530d8U, 0xf262004eU, 0x6c0695edU, -0x1b01a57bU, 0x8208f4c1U, 0xf50fc457U, 0x65b0d9c6U, 0x12b7e950U, -0x8bbeb8eaU, 0xfcb9887cU, 0x62dd1ddfU, 0x15da2d49U, 0x8cd37cf3U, -0xfbd44c65U, 0x4db26158U, 0x3ab551ceU, 0xa3bc0074U, 0xd4bb30e2U, -0x4adfa541U, 0x3dd895d7U, 0xa4d1c46dU, 0xd3d6f4fbU, 0x4369e96aU, -0x346ed9fcU, 0xad678846U, 0xda60b8d0U, 0x44042d73U, 0x33031de5U, -0xaa0a4c5fU, 0xdd0d7cc9U, 0x5005713cU, 0x270241aaU, 0xbe0b1010U, -0xc90c2086U, 0x5768b525U, 0x206f85b3U, 0xb966d409U, 0xce61e49fU, -0x5edef90eU, 0x29d9c998U, 0xb0d09822U, 0xc7d7a8b4U, 0x59b33d17U, -0x2eb40d81U, 0xb7bd5c3bU, 0xc0ba6cadU, 0xedb88320U, 0x9abfb3b6U, -0x03b6e20cU, 0x74b1d29aU, 0xead54739U, 0x9dd277afU, 0x04db2615U, -0x73dc1683U, 0xe3630b12U, 0x94643b84U, 0x0d6d6a3eU, 0x7a6a5aa8U, -0xe40ecf0bU, 0x9309ff9dU, 0x0a00ae27U, 0x7d079eb1U, 0xf00f9344U, -0x8708a3d2U, 0x1e01f268U, 0x6906c2feU, 0xf762575dU, 0x806567cbU, -0x196c3671U, 0x6e6b06e7U, 0xfed41b76U, 0x89d32be0U, 0x10da7a5aU, -0x67dd4accU, 0xf9b9df6fU, 0x8ebeeff9U, 0x17b7be43U, 0x60b08ed5U, -0xd6d6a3e8U, 0xa1d1937eU, 0x38d8c2c4U, 0x4fdff252U, 0xd1bb67f1U, -0xa6bc5767U, 0x3fb506ddU, 0x48b2364bU, 0xd80d2bdaU, 0xaf0a1b4cU, -0x36034af6U, 0x41047a60U, 0xdf60efc3U, 0xa867df55U, 0x316e8eefU, -0x4669be79U, 0xcb61b38cU, 0xbc66831aU, 0x256fd2a0U, 0x5268e236U, -0xcc0c7795U, 0xbb0b4703U, 0x220216b9U, 0x5505262fU, 0xc5ba3bbeU, -0xb2bd0b28U, 0x2bb45a92U, 0x5cb36a04U, 0xc2d7ffa7U, 0xb5d0cf31U, -0x2cd99e8bU, 0x5bdeae1dU, 0x9b64c2b0U, 0xec63f226U, 0x756aa39cU, -0x026d930aU, 0x9c0906a9U, 0xeb0e363fU, 0x72076785U, 0x05005713U, -0x95bf4a82U, 0xe2b87a14U, 0x7bb12baeU, 0x0cb61b38U, 0x92d28e9bU, -0xe5d5be0dU, 0x7cdcefb7U, 0x0bdbdf21U, 0x86d3d2d4U, 0xf1d4e242U, -0x68ddb3f8U, 0x1fda836eU, 0x81be16cdU, 0xf6b9265bU, 0x6fb077e1U, -0x18b74777U, 0x88085ae6U, 0xff0f6a70U, 0x66063bcaU, 0x11010b5cU, -0x8f659effU, 0xf862ae69U, 0x616bffd3U, 0x166ccf45U, 0xa00ae278U, -0xd70dd2eeU, 0x4e048354U, 0x3903b3c2U, 0xa7672661U, 0xd06016f7U, -0x4969474dU, 0x3e6e77dbU, 0xaed16a4aU, 0xd9d65adcU, 0x40df0b66U, -0x37d83bf0U, 0xa9bcae53U, 0xdebb9ec5U, 0x47b2cf7fU, 0x30b5ffe9U, -0xbdbdf21cU, 0xcabac28aU, 0x53b39330U, 0x24b4a3a6U, 0xbad03605U, -0xcdd70693U, 0x54de5729U, 0x23d967bfU, 0xb3667a2eU, 0xc4614ab8U, -0x5d681b02U, 0x2a6f2b94U, 0xb40bbe37U, 0xc30c8ea1U, 0x5a05df1bU, -0x2d02ef8dU -}; - -static unsigned int -internal_crc32(const unsigned char *bin_data, Py_ssize_t len, unsigned int crc) -{ /* By Jim Ahlstrom; All rights transferred to CNRI */ - unsigned int result; - - crc = ~ crc; - while (len-- > 0) { - crc = crc_32_tab[(crc ^ *bin_data++) & 0xff] ^ (crc >> 8); - /* Note: (crc >> 8) MUST zero fill on left */ - } - - result = (crc ^ 0xFFFFFFFF); - return result & 0xffffffff; -} -#endif /* NO_ZLIB_CRC32 */ /*[clinic input] binascii.crc32 -> unsigned_int @@ -764,12 +628,8 @@ Compute CRC-32 incrementally. static unsigned int binascii_crc32_impl(PyObject *module, Py_buffer *data, unsigned int crc) /*[clinic end generated code: output=52cf59056a78593b input=bbe340bc99d25aa8]*/ - -#ifndef NO_ZLIB_CRC32 /* This is the same as zlibmodule.c zlib_crc32_impl. It exists in two - modules for historical reasons. We should consolidate the two however - currently builds without zlib making this not possible. - */ + * modules for historical reasons. We should consolidate the two. */ { /* Releasing the GIL for very small buffers is inefficient and may lower performance */ @@ -800,24 +660,6 @@ binascii_crc32_impl(PyObject *module, Py_buffer *data, unsigned int crc) } return crc & 0xffffffff; } -#else /* NO_ZLIB_CRC32 */ -{ - const unsigned char *bin_data = data->buf; - Py_ssize_t len = data->len; - - /* Releasing the GIL for very small buffers is inefficient - and may lower performance */ - if (len > 1024*5) { - unsigned int result; - Py_BEGIN_ALLOW_THREADS - result = internal_crc32(bin_data, len, crc); - Py_END_ALLOW_THREADS - return result; - } else { - return internal_crc32(bin_data, len, crc); - } -} -#endif /* NO_ZLIB_CRC32 */ /*[clinic input] binascii.b2a_hex diff --git a/configure b/configure index 82d4106a37289a..7b4d4eba9d298a 100755 --- a/configure +++ b/configure @@ -848,12 +848,12 @@ HAVE_GETHOSTBYNAME_R_3_ARG HAVE_GETHOSTBYNAME_R_5_ARG HAVE_GETHOSTBYNAME_R_6_ARG LIBOBJS -ZLIB_LIBS -ZLIB_CFLAGS LIBLZMA_LIBS LIBLZMA_CFLAGS BZIP2_LIBS BZIP2_CFLAGS +ZLIB_LIBS +ZLIB_CFLAGS TRUE MACHDEP_OBJS DYNLOADFILE @@ -1161,12 +1161,12 @@ X11_CFLAGS X11_LIBS GDBM_CFLAGS GDBM_LIBS +ZLIB_CFLAGS +ZLIB_LIBS BZIP2_CFLAGS BZIP2_LIBS LIBLZMA_CFLAGS LIBLZMA_LIBS -ZLIB_CFLAGS -ZLIB_LIBS LIBREADLINE_CFLAGS LIBREADLINE_LIBS LIBEDIT_CFLAGS @@ -1998,6 +1998,13 @@ Some influential environment variables: GDBM_LIBS additional linker flags for gdbm ZLIB_CFLAGS C compiler flags for ZLIB, overriding pkg-config ZLIB_LIBS linker flags for ZLIB, overriding pkg-config + BZIP2_CFLAGS + C compiler flags for BZIP2, overriding pkg-config + BZIP2_LIBS linker flags for BZIP2, overriding pkg-config + LIBLZMA_CFLAGS + C compiler flags for LIBLZMA, overriding pkg-config + LIBLZMA_LIBS + linker flags for LIBLZMA, overriding pkg-config LIBREADLINE_CFLAGS C compiler flags for LIBREADLINE, overriding pkg-config LIBREADLINE_LIBS @@ -21442,13 +21449,6 @@ fi -case $ac_sys_system in #( - WASI) : - - BINASCII_CFLAGS="-DNO_ZLIB_CRC32" - ;; #( - *) : - pkg_failed=no { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for zlib >= 1.2.0" >&5 @@ -21509,20 +21509,20 @@ fi echo "$ZLIB_PKG_ERRORS" >&5 - for ac_header in zlib.h + for ac_header in zlib.h do : ac_fn_c_check_header_compile "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" if test "x$ac_cv_header_zlib_h" = xyes then : printf "%s\n" "#define HAVE_ZLIB_H 1" >>confdefs.h - save_CFLAGS=$CFLAGS + save_CFLAGS=$CFLAGS save_CPPFLAGS=$CPPFLAGS save_LDFLAGS=$LDFLAGS save_LIBS=$LIBS - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzread in -lz" >&5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzread in -lz" >&5 printf %s "checking for gzread in -lz... " >&6; } if test ${ac_cv_lib_z_gzread+y} then : @@ -21568,9 +21568,9 @@ printf "%s\n" "$ac_cv_lib_z_gzread" >&6; } if test "x$ac_cv_lib_z_gzread" = xyes then : - ZLIB_CFLAGS=${ZLIB_CFLAGS-""} - ZLIB_LIBS=${ZLIB_LIBS-"-lz"} - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5 + ZLIB_CFLAGS=${ZLIB_CFLAGS-""} + ZLIB_LIBS=${ZLIB_LIBS-"-lz"} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5 printf %s "checking for inflateCopy in -lz... " >&6; } if test ${ac_cv_lib_z_inflateCopy+y} then : @@ -21622,8 +21622,8 @@ fi else case e in #( e) - as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 - ;; + as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 + ;; esac fi @@ -21637,15 +21637,162 @@ LIBS=$save_LIBS else case e in #( e) - as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 - ;; + as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 + ;; esac fi done - ;; +elif test $pkg_failed = untried; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + + for ac_header in zlib.h +do : + ac_fn_c_check_header_compile "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" +if test "x$ac_cv_header_zlib_h" = xyes +then : + printf "%s\n" "#define HAVE_ZLIB_H 1" >>confdefs.h + + save_CFLAGS=$CFLAGS +save_CPPFLAGS=$CPPFLAGS +save_LDFLAGS=$LDFLAGS +save_LIBS=$LIBS + + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzread in -lz" >&5 +printf %s "checking for gzread in -lz... " >&6; } +if test ${ac_cv_lib_z_gzread+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-lz $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char gzread (void); +int +main (void) +{ +return gzread (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_z_gzread=yes +else case e in #( + e) ac_cv_lib_z_gzread=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_gzread" >&5 +printf "%s\n" "$ac_cv_lib_z_gzread" >&6; } +if test "x$ac_cv_lib_z_gzread" = xyes +then : + + ZLIB_CFLAGS=${ZLIB_CFLAGS-""} + ZLIB_LIBS=${ZLIB_LIBS-"-lz"} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5 +printf %s "checking for inflateCopy in -lz... " >&6; } +if test ${ac_cv_lib_z_inflateCopy+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-lz $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char inflateCopy (void); +int +main (void) +{ +return inflateCopy (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_z_inflateCopy=yes +else case e in #( + e) ac_cv_lib_z_inflateCopy=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_inflateCopy" >&5 +printf "%s\n" "$ac_cv_lib_z_inflateCopy" >&6; } +if test "x$ac_cv_lib_z_inflateCopy" = xyes +then : + printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h + +fi + + +else case e in #( + e) + as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 + ;; +esac +fi + + +CFLAGS=$save_CFLAGS +CPPFLAGS=$save_CPPFLAGS +LDFLAGS=$save_LDFLAGS +LIBS=$save_LIBS + + + +else case e in #( + e) + as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 + ;; esac +fi + +done + +else + ZLIB_CFLAGS=$pkg_cv_ZLIB_CFLAGS + ZLIB_LIBS=$pkg_cv_ZLIB_LIBS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + + printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h + + +fi @@ -21661,9 +21808,6 @@ fi - BZIP2_CFLAGS - C compiler flags for BZIP2, overriding pkg-config - BZIP2_LIBS linker flags for BZIP2, overriding pkg-config pkg_failed=no { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for bzip2" >&5 @@ -21912,10 +22056,6 @@ printf "%s\n" "yes" >&6; } have_bzip2=yes fi - LIBLZMA_CFLAGS - C compiler flags for LIBLZMA, overriding pkg-config - LIBLZMA_LIBS - linker flags for LIBLZMA, overriding pkg-config pkg_failed=no { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for liblzma" >&5 @@ -23407,1920 +23547,7 @@ then : else case e in #( e) case " $LIBOBJS " in - *" dup2.$ac_objext "* -elif test $pkg_failed = untried; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } - - for ac_header in zlib.h -do : - ac_fn_c_check_header_compile "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" -if test "x$ac_cv_header_zlib_h" = xyes -then : - printf "%s\n" "#define HAVE_ZLIB_H 1" >>confdefs.h - - save_CFLAGS=$CFLAGS -save_CPPFLAGS=$CPPFLAGS -save_LDFLAGS=$LDFLAGS -save_LIBS=$LIBS - - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzread in -lz" >&5 -printf %s "checking for gzread in -lz... " >&6; } -if test ${ac_cv_lib_z_gzread+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) ac_check_lib_save_LIBS=$LIBS -LIBS="-lz $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. - The 'extern "C"' is for builds by C++ compilers; - although this is not generally supported in C code supporting it here - has little cost and some practical benefit (sr 110532). */ -#ifdef __cplusplus -extern "C" -#endif -char gzread (void); -int -main (void) -{ -return gzread (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_lib_z_gzread=yes -else case e in #( - e) ac_cv_lib_z_gzread=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_gzread" >&5 -printf "%s\n" "$ac_cv_lib_z_gzread" >&6; } -if test "x$ac_cv_lib_z_gzread" = xyes -then : - - ZLIB_CFLAGS=${ZLIB_CFLAGS-""} - ZLIB_LIBS=${ZLIB_LIBS-"-lz"} - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5 -printf %s "checking for inflateCopy in -lz... " >&6; } -if test ${ac_cv_lib_z_inflateCopy+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) ac_check_lib_save_LIBS=$LIBS -LIBS="-lz $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. - The 'extern "C"' is for builds by C++ compilers; - although this is not generally supported in C code supporting it here - has little cost and some practical benefit (sr 110532). */ -#ifdef __cplusplus -extern "C" -#endif -char inflateCopy (void); -int -main (void) -{ -return inflateCopy (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_lib_z_inflateCopy=yes -else case e in #( - e) ac_cv_lib_z_inflateCopy=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_inflateCopy" >&5 -printf "%s\n" "$ac_cv_lib_z_inflateCopy" >&6; } -if test "x$ac_cv_lib_z_inflateCopy" = xyes -then : - printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h - -fi - - -else case e in #( - e) - as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 - ;; -esac -fi - - -CFLAGS=$save_CFLAGS -CPPFLAGS=$save_CPPFLAGS -LDFLAGS=$save_LDFLAGS -LIBS=$save_LIBS - - - -else case e in #( - e) - as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 - ;; -esac -fi - -done - - ;; -esac - - - - - if test "$ac_sys_system" = "Emscripten" -a -z "$BZIP2_CFLAGS" -a -z "$BZIP2_LIBS" -then : - - BZIP2_CFLAGS="-sUSE_BZIP2" - BZIP2_LIBS="-sUSE_BZIP2" - -fi - - - - - BZIP2_CFLAGS - C compiler flags for BZIP2, overriding pkg-config - BZIP2_LIBS linker flags for BZIP2, overriding pkg-config - -pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for bzip2" >&5 -printf %s "checking for bzip2... " >&6; } - -if test -n "$BZIP2_CFLAGS"; then - pkg_cv_BZIP2_CFLAGS="$BZIP2_CFLAGS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"bzip2\""; } >&5 - ($PKG_CONFIG --exists --print-errors "bzip2") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_BZIP2_CFLAGS=`$PKG_CONFIG --cflags "bzip2" 2>/dev/null` - test "x$?" != "x0" && pkg_failed=yes -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi -if test -n "$BZIP2_LIBS"; then - pkg_cv_BZIP2_LIBS="$BZIP2_LIBS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"bzip2\""; } >&5 - ($PKG_CONFIG --exists --print-errors "bzip2") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_BZIP2_LIBS=`$PKG_CONFIG --libs "bzip2" 2>/dev/null` - test "x$?" != "x0" && pkg_failed=yes -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi - - - -if test $pkg_failed = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } - -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi - if test $_pkg_short_errors_supported = yes; then - BZIP2_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "bzip2" 2>&1` - else - BZIP2_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "bzip2" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$BZIP2_PKG_ERRORS" >&5 - - - save_CFLAGS=$CFLAGS -save_CPPFLAGS=$CPPFLAGS -save_LDFLAGS=$LDFLAGS -save_LIBS=$LIBS - - - CPPFLAGS="$CPPFLAGS $BZIP2_CFLAGS" - LIBS="$LIBS $BZIP2_LIBS" - for ac_header in bzlib.h -do : - ac_fn_c_check_header_compile "$LINENO" "bzlib.h" "ac_cv_header_bzlib_h" "$ac_includes_default" -if test "x$ac_cv_header_bzlib_h" = xyes -then : - printf "%s\n" "#define HAVE_BZLIB_H 1" >>confdefs.h - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for BZ2_bzCompress in -lbz2" >&5 -printf %s "checking for BZ2_bzCompress in -lbz2... " >&6; } -if test ${ac_cv_lib_bz2_BZ2_bzCompress+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) ac_check_lib_save_LIBS=$LIBS -LIBS="-lbz2 $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. - The 'extern "C"' is for builds by C++ compilers; - although this is not generally supported in C code supporting it here - has little cost and some practical benefit (sr 110532). */ -#ifdef __cplusplus -extern "C" -#endif -char BZ2_bzCompress (void); -int -main (void) -{ -return BZ2_bzCompress (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_lib_bz2_BZ2_bzCompress=yes -else case e in #( - e) ac_cv_lib_bz2_BZ2_bzCompress=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bz2_BZ2_bzCompress" >&5 -printf "%s\n" "$ac_cv_lib_bz2_BZ2_bzCompress" >&6; } -if test "x$ac_cv_lib_bz2_BZ2_bzCompress" = xyes -then : - have_bzip2=yes -else case e in #( - e) have_bzip2=no ;; -esac -fi - - -else case e in #( - e) have_bzip2=no ;; -esac -fi - -done - if test "x$have_bzip2" = xyes -then : - - BZIP2_CFLAGS=${BZIP2_CFLAGS-""} - BZIP2_LIBS=${BZIP2_LIBS-"-lbz2"} - -fi - -CFLAGS=$save_CFLAGS -CPPFLAGS=$save_CPPFLAGS -LDFLAGS=$save_LDFLAGS -LIBS=$save_LIBS - - - -elif test $pkg_failed = untried; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } - - save_CFLAGS=$CFLAGS -save_CPPFLAGS=$CPPFLAGS -save_LDFLAGS=$LDFLAGS -save_LIBS=$LIBS - - - CPPFLAGS="$CPPFLAGS $BZIP2_CFLAGS" - LIBS="$LIBS $BZIP2_LIBS" - for ac_header in bzlib.h -do : - ac_fn_c_check_header_compile "$LINENO" "bzlib.h" "ac_cv_header_bzlib_h" "$ac_includes_default" -if test "x$ac_cv_header_bzlib_h" = xyes -then : - printf "%s\n" "#define HAVE_BZLIB_H 1" >>confdefs.h - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for BZ2_bzCompress in -lbz2" >&5 -printf %s "checking for BZ2_bzCompress in -lbz2... " >&6; } -if test ${ac_cv_lib_bz2_BZ2_bzCompress+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) ac_check_lib_save_LIBS=$LIBS -LIBS="-lbz2 $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. - The 'extern "C"' is for builds by C++ compilers; - although this is not generally supported in C code supporting it here - has little cost and some practical benefit (sr 110532). */ -#ifdef __cplusplus -extern "C" -#endif -char BZ2_bzCompress (void); -int -main (void) -{ -return BZ2_bzCompress (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_lib_bz2_BZ2_bzCompress=yes -else case e in #( - e) ac_cv_lib_bz2_BZ2_bzCompress=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bz2_BZ2_bzCompress" >&5 -printf "%s\n" "$ac_cv_lib_bz2_BZ2_bzCompress" >&6; } -if test "x$ac_cv_lib_bz2_BZ2_bzCompress" = xyes -then : - have_bzip2=yes -else case e in #( - e) have_bzip2=no ;; -esac -fi - - -else case e in #( - e) have_bzip2=no ;; -esac -fi - -done - if test "x$have_bzip2" = xyes -then : - - BZIP2_CFLAGS=${BZIP2_CFLAGS-""} - BZIP2_LIBS=${BZIP2_LIBS-"-lbz2"} - -fi - -CFLAGS=$save_CFLAGS -CPPFLAGS=$save_CPPFLAGS -LDFLAGS=$save_LDFLAGS -LIBS=$save_LIBS - - - -else - BZIP2_CFLAGS=$pkg_cv_BZIP2_CFLAGS - BZIP2_LIBS=$pkg_cv_BZIP2_LIBS - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } - have_bzip2=yes -fi - - LIBLZMA_CFLAGS - C compiler flags for LIBLZMA, overriding pkg-config - LIBLZMA_LIBS - linker flags for LIBLZMA, overriding pkg-config - -pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for liblzma" >&5 -printf %s "checking for liblzma... " >&6; } - -if test -n "$LIBLZMA_CFLAGS"; then - pkg_cv_LIBLZMA_CFLAGS="$LIBLZMA_CFLAGS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"liblzma\""; } >&5 - ($PKG_CONFIG --exists --print-errors "liblzma") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_LIBLZMA_CFLAGS=`$PKG_CONFIG --cflags "liblzma" 2>/dev/null` - test "x$?" != "x0" && pkg_failed=yes -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi -if test -n "$LIBLZMA_LIBS"; then - pkg_cv_LIBLZMA_LIBS="$LIBLZMA_LIBS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"liblzma\""; } >&5 - ($PKG_CONFIG --exists --print-errors "liblzma") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_LIBLZMA_LIBS=`$PKG_CONFIG --libs "liblzma" 2>/dev/null` - test "x$?" != "x0" && pkg_failed=yes -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi - - - -if test $pkg_failed = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } - -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi - if test $_pkg_short_errors_supported = yes; then - LIBLZMA_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "liblzma" 2>&1` - else - LIBLZMA_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "liblzma" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$LIBLZMA_PKG_ERRORS" >&5 - - - save_CFLAGS=$CFLAGS -save_CPPFLAGS=$CPPFLAGS -save_LDFLAGS=$LDFLAGS -save_LIBS=$LIBS - - - CPPFLAGS="$CPPFLAGS $LIBLZMA_CFLAGS" - LIBS="$LIBS $LIBLZMA_LIBS" - for ac_header in lzma.h -do : - ac_fn_c_check_header_compile "$LINENO" "lzma.h" "ac_cv_header_lzma_h" "$ac_includes_default" -if test "x$ac_cv_header_lzma_h" = xyes -then : - printf "%s\n" "#define HAVE_LZMA_H 1" >>confdefs.h - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for lzma_easy_encoder in -llzma" >&5 -printf %s "checking for lzma_easy_encoder in -llzma... " >&6; } -if test ${ac_cv_lib_lzma_lzma_easy_encoder+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) ac_check_lib_save_LIBS=$LIBS -LIBS="-llzma $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. - The 'extern "C"' is for builds by C++ compilers; - although this is not generally supported in C code supporting it here - has little cost and some practical benefit (sr 110532). */ -#ifdef __cplusplus -extern "C" -#endif -char lzma_easy_encoder (void); -int -main (void) -{ -return lzma_easy_encoder (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_lib_lzma_lzma_easy_encoder=yes -else case e in #( - e) ac_cv_lib_lzma_lzma_easy_encoder=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lzma_lzma_easy_encoder" >&5 -printf "%s\n" "$ac_cv_lib_lzma_lzma_easy_encoder" >&6; } -if test "x$ac_cv_lib_lzma_lzma_easy_encoder" = xyes -then : - have_liblzma=yes -else case e in #( - e) have_liblzma=no ;; -esac -fi - - -else case e in #( - e) have_liblzma=no ;; -esac -fi - -done - if test "x$have_liblzma" = xyes -then : - - LIBLZMA_CFLAGS=${LIBLZMA_CFLAGS-""} - LIBLZMA_LIBS=${LIBLZMA_LIBS-"-llzma"} - -fi - -CFLAGS=$save_CFLAGS -CPPFLAGS=$save_CPPFLAGS -LDFLAGS=$save_LDFLAGS -LIBS=$save_LIBS - - - -elif test $pkg_failed = untried; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } - - save_CFLAGS=$CFLAGS -save_CPPFLAGS=$CPPFLAGS -save_LDFLAGS=$LDFLAGS -save_LIBS=$LIBS - - - CPPFLAGS="$CPPFLAGS $LIBLZMA_CFLAGS" - LIBS="$LIBS $LIBLZMA_LIBS" - for ac_header in lzma.h -do : - ac_fn_c_check_header_compile "$LINENO" "lzma.h" "ac_cv_header_lzma_h" "$ac_includes_default" -if test "x$ac_cv_header_lzma_h" = xyes -then : - printf "%s\n" "#define HAVE_LZMA_H 1" >>confdefs.h - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for lzma_easy_encoder in -llzma" >&5 -printf %s "checking for lzma_easy_encoder in -llzma... " >&6; } -if test ${ac_cv_lib_lzma_lzma_easy_encoder+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) ac_check_lib_save_LIBS=$LIBS -LIBS="-llzma $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. - The 'extern "C"' is for builds by C++ compilers; - although this is not generally supported in C code supporting it here - has little cost and some practical benefit (sr 110532). */ -#ifdef __cplusplus -extern "C" -#endif -char lzma_easy_encoder (void); -int -main (void) -{ -return lzma_easy_encoder (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_lib_lzma_lzma_easy_encoder=yes -else case e in #( - e) ac_cv_lib_lzma_lzma_easy_encoder=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lzma_lzma_easy_encoder" >&5 -printf "%s\n" "$ac_cv_lib_lzma_lzma_easy_encoder" >&6; } -if test "x$ac_cv_lib_lzma_lzma_easy_encoder" = xyes -then : - have_liblzma=yes -else case e in #( - e) have_liblzma=no ;; -esac -fi - - -else case e in #( - e) have_liblzma=no ;; -esac -fi - -done - if test "x$have_liblzma" = xyes -then : - - LIBLZMA_CFLAGS=${LIBLZMA_CFLAGS-""} - LIBLZMA_LIBS=${LIBLZMA_LIBS-"-llzma"} - -fi - -CFLAGS=$save_CFLAGS -CPPFLAGS=$save_CPPFLAGS -LDFLAGS=$save_LDFLAGS -LIBS=$save_LIBS - - - -else - LIBLZMA_CFLAGS=$pkg_cv_LIBLZMA_CFLAGS - LIBLZMA_LIBS=$pkg_cv_LIBLZMA_LIBS - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } - have_liblzma=yes -fi - - - - - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for hstrerror" >&5 -printf %s "checking for hstrerror... " >&6; } -if test ${ac_cv_func_hstrerror+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main (void) -{ -void *x=hstrerror - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_func_hstrerror=yes -else case e in #( - e) ac_cv_func_hstrerror=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_hstrerror" >&5 -printf "%s\n" "$ac_cv_func_hstrerror" >&6; } - if test "x$ac_cv_func_hstrerror" = xyes -then : - -printf "%s\n" "#define HAVE_HSTRERROR 1" >>confdefs.h - -fi - - - - - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for getservbyname" >&5 -printf %s "checking for getservbyname... " >&6; } -if test ${ac_cv_func_getservbyname+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main (void) -{ -void *x=getservbyname - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_func_getservbyname=yes -else case e in #( - e) ac_cv_func_getservbyname=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_getservbyname" >&5 -printf "%s\n" "$ac_cv_func_getservbyname" >&6; } - if test "x$ac_cv_func_getservbyname" = xyes -then : - -printf "%s\n" "#define HAVE_GETSERVBYNAME 1" >>confdefs.h - -fi - - - - - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for getservbyport" >&5 -printf %s "checking for getservbyport... " >&6; } -if test ${ac_cv_func_getservbyport+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main (void) -{ -void *x=getservbyport - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_func_getservbyport=yes -else case e in #( - e) ac_cv_func_getservbyport=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_getservbyport" >&5 -printf "%s\n" "$ac_cv_func_getservbyport" >&6; } - if test "x$ac_cv_func_getservbyport" = xyes -then : - -printf "%s\n" "#define HAVE_GETSERVBYPORT 1" >>confdefs.h - -fi - - - - - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gethostbyname" >&5 -printf %s "checking for gethostbyname... " >&6; } -if test ${ac_cv_func_gethostbyname+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main (void) -{ -void *x=gethostbyname - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_func_gethostbyname=yes -else case e in #( - e) ac_cv_func_gethostbyname=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_gethostbyname" >&5 -printf "%s\n" "$ac_cv_func_gethostbyname" >&6; } - if test "x$ac_cv_func_gethostbyname" = xyes -then : - -printf "%s\n" "#define HAVE_GETHOSTBYNAME 1" >>confdefs.h - -fi - - - - - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gethostbyaddr" >&5 -printf %s "checking for gethostbyaddr... " >&6; } -if test ${ac_cv_func_gethostbyaddr+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main (void) -{ -void *x=gethostbyaddr - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_func_gethostbyaddr=yes -else case e in #( - e) ac_cv_func_gethostbyaddr=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_gethostbyaddr" >&5 -printf "%s\n" "$ac_cv_func_gethostbyaddr" >&6; } - if test "x$ac_cv_func_gethostbyaddr" = xyes -then : - -printf "%s\n" "#define HAVE_GETHOSTBYADDR 1" >>confdefs.h - -fi - - - - - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for getprotobyname" >&5 -printf %s "checking for getprotobyname... " >&6; } -if test ${ac_cv_func_getprotobyname+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main (void) -{ -void *x=getprotobyname - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_func_getprotobyname=yes -else case e in #( - e) ac_cv_func_getprotobyname=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_getprotobyname" >&5 -printf "%s\n" "$ac_cv_func_getprotobyname" >&6; } - if test "x$ac_cv_func_getprotobyname" = xyes -then : - -printf "%s\n" "#define HAVE_GETPROTOBYNAME 1" >>confdefs.h - -fi - - - - - - - - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inet_aton" >&5 -printf %s "checking for inet_aton... " >&6; } -if test ${ac_cv_func_inet_aton+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -#include -#include - -int -main (void) -{ -void *x=inet_aton - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_func_inet_aton=yes -else case e in #( - e) ac_cv_func_inet_aton=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_inet_aton" >&5 -printf "%s\n" "$ac_cv_func_inet_aton" >&6; } - if test "x$ac_cv_func_inet_aton" = xyes -then : - -printf "%s\n" "#define HAVE_INET_ATON 1" >>confdefs.h - -fi - - - - - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inet_ntoa" >&5 -printf %s "checking for inet_ntoa... " >&6; } -if test ${ac_cv_func_inet_ntoa+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -#include -#include - -int -main (void) -{ -void *x=inet_ntoa - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_func_inet_ntoa=yes -else case e in #( - e) ac_cv_func_inet_ntoa=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_inet_ntoa" >&5 -printf "%s\n" "$ac_cv_func_inet_ntoa" >&6; } - if test "x$ac_cv_func_inet_ntoa" = xyes -then : - -printf "%s\n" "#define HAVE_INET_NTOA 1" >>confdefs.h - -fi - - - - - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inet_pton" >&5 -printf %s "checking for inet_pton... " >&6; } -if test ${ac_cv_func_inet_pton+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -#include -#include - -int -main (void) -{ -void *x=inet_pton - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_func_inet_pton=yes -else case e in #( - e) ac_cv_func_inet_pton=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_inet_pton" >&5 -printf "%s\n" "$ac_cv_func_inet_pton" >&6; } - if test "x$ac_cv_func_inet_pton" = xyes -then : - -printf "%s\n" "#define HAVE_INET_PTON 1" >>confdefs.h - -fi - - - - - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for getpeername" >&5 -printf %s "checking for getpeername... " >&6; } -if test ${ac_cv_func_getpeername+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -#include -#include - -int -main (void) -{ -void *x=getpeername - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_func_getpeername=yes -else case e in #( - e) ac_cv_func_getpeername=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_getpeername" >&5 -printf "%s\n" "$ac_cv_func_getpeername" >&6; } - if test "x$ac_cv_func_getpeername" = xyes -then : - -printf "%s\n" "#define HAVE_GETPEERNAME 1" >>confdefs.h - -fi - - - - - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for getsockname" >&5 -printf %s "checking for getsockname... " >&6; } -if test ${ac_cv_func_getsockname+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -#include -#include - -int -main (void) -{ -void *x=getsockname - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_func_getsockname=yes -else case e in #( - e) ac_cv_func_getsockname=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_getsockname" >&5 -printf "%s\n" "$ac_cv_func_getsockname" >&6; } - if test "x$ac_cv_func_getsockname" = xyes -then : - -printf "%s\n" "#define HAVE_GETSOCKNAME 1" >>confdefs.h - -fi - - - - - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for accept" >&5 -printf %s "checking for accept... " >&6; } -if test ${ac_cv_func_accept+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -#include -#include - -int -main (void) -{ -void *x=accept - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_func_accept=yes -else case e in #( - e) ac_cv_func_accept=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_accept" >&5 -printf "%s\n" "$ac_cv_func_accept" >&6; } - if test "x$ac_cv_func_accept" = xyes -then : - -printf "%s\n" "#define HAVE_ACCEPT 1" >>confdefs.h - -fi - - - - - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for bind" >&5 -printf %s "checking for bind... " >&6; } -if test ${ac_cv_func_bind+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -#include -#include - -int -main (void) -{ -void *x=bind - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_func_bind=yes -else case e in #( - e) ac_cv_func_bind=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_bind" >&5 -printf "%s\n" "$ac_cv_func_bind" >&6; } - if test "x$ac_cv_func_bind" = xyes -then : - -printf "%s\n" "#define HAVE_BIND 1" >>confdefs.h - -fi - - - - - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for connect" >&5 -printf %s "checking for connect... " >&6; } -if test ${ac_cv_func_connect+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -#include -#include - -int -main (void) -{ -void *x=connect - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_func_connect=yes -else case e in #( - e) ac_cv_func_connect=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_connect" >&5 -printf "%s\n" "$ac_cv_func_connect" >&6; } - if test "x$ac_cv_func_connect" = xyes -then : - -printf "%s\n" "#define HAVE_CONNECT 1" >>confdefs.h - -fi - - - - - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for listen" >&5 -printf %s "checking for listen... " >&6; } -if test ${ac_cv_func_listen+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -#include -#include - -int -main (void) -{ -void *x=listen - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_func_listen=yes -else case e in #( - e) ac_cv_func_listen=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_listen" >&5 -printf "%s\n" "$ac_cv_func_listen" >&6; } - if test "x$ac_cv_func_listen" = xyes -then : - -printf "%s\n" "#define HAVE_LISTEN 1" >>confdefs.h - -fi - - - - - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for recvfrom" >&5 -printf %s "checking for recvfrom... " >&6; } -if test ${ac_cv_func_recvfrom+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -#include -#include - -int -main (void) -{ -void *x=recvfrom - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_func_recvfrom=yes -else case e in #( - e) ac_cv_func_recvfrom=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_recvfrom" >&5 -printf "%s\n" "$ac_cv_func_recvfrom" >&6; } - if test "x$ac_cv_func_recvfrom" = xyes -then : - -printf "%s\n" "#define HAVE_RECVFROM 1" >>confdefs.h - -fi - - - - - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sendto" >&5 -printf %s "checking for sendto... " >&6; } -if test ${ac_cv_func_sendto+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -#include -#include - -int -main (void) -{ -void *x=sendto - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_func_sendto=yes -else case e in #( - e) ac_cv_func_sendto=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_sendto" >&5 -printf "%s\n" "$ac_cv_func_sendto" >&6; } - if test "x$ac_cv_func_sendto" = xyes -then : - -printf "%s\n" "#define HAVE_SENDTO 1" >>confdefs.h - -fi - - - - - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for setsockopt" >&5 -printf %s "checking for setsockopt... " >&6; } -if test ${ac_cv_func_setsockopt+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -#include -#include - -int -main (void) -{ -void *x=setsockopt - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_func_setsockopt=yes -else case e in #( - e) ac_cv_func_setsockopt=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_setsockopt" >&5 -printf "%s\n" "$ac_cv_func_setsockopt" >&6; } - if test "x$ac_cv_func_setsockopt" = xyes -then : - -printf "%s\n" "#define HAVE_SETSOCKOPT 1" >>confdefs.h - -fi - - - - - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for socket" >&5 -printf %s "checking for socket... " >&6; } -if test ${ac_cv_func_socket+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -#include -#include - -int -main (void) -{ -void *x=socket - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_func_socket=yes -else case e in #( - e) ac_cv_func_socket=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_socket" >&5 -printf "%s\n" "$ac_cv_func_socket" >&6; } - if test "x$ac_cv_func_socket" = xyes -then : - -printf "%s\n" "#define HAVE_SOCKET 1" >>confdefs.h - -fi - - - - -# On some systems, setgroups is in unistd.h, on others, in grp.h - - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for setgroups" >&5 -printf %s "checking for setgroups... " >&6; } -if test ${ac_cv_func_setgroups+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#ifdef HAVE_GRP_H -#include -#endif - -int -main (void) -{ -void *x=setgroups - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_func_setgroups=yes -else case e in #( - e) ac_cv_func_setgroups=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_setgroups" >&5 -printf "%s\n" "$ac_cv_func_setgroups" >&6; } - if test "x$ac_cv_func_setgroups" = xyes -then : - -printf "%s\n" "#define HAVE_SETGROUPS 1" >>confdefs.h - -fi - - - - -# check for openpty, login_tty, and forkpty - - - for ac_func in openpty -do : - ac_fn_c_check_func "$LINENO" "openpty" "ac_cv_func_openpty" -if test "x$ac_cv_func_openpty" = xyes -then : - printf "%s\n" "#define HAVE_OPENPTY 1" >>confdefs.h - -else case e in #( - e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for openpty in -lutil" >&5 -printf %s "checking for openpty in -lutil... " >&6; } -if test ${ac_cv_lib_util_openpty+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) ac_check_lib_save_LIBS=$LIBS -LIBS="-lutil $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. - The 'extern "C"' is for builds by C++ compilers; - although this is not generally supported in C code supporting it here - has little cost and some practical benefit (sr 110532). */ -#ifdef __cplusplus -extern "C" -#endif -char openpty (void); -int -main (void) -{ -return openpty (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_lib_util_openpty=yes -else case e in #( - e) ac_cv_lib_util_openpty=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_util_openpty" >&5 -printf "%s\n" "$ac_cv_lib_util_openpty" >&6; } -if test "x$ac_cv_lib_util_openpty" = xyes -then : - printf "%s\n" "#define HAVE_OPENPTY 1" >>confdefs.h - LIBS="$LIBS -lutil" -else case e in #( - e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for openpty in -lbsd" >&5 -printf %s "checking for openpty in -lbsd... " >&6; } -if test ${ac_cv_lib_bsd_openpty+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) ac_check_lib_save_LIBS=$LIBS -LIBS="-lbsd $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. - The 'extern "C"' is for builds by C++ compilers; - although this is not generally supported in C code supporting it here - has little cost and some practical benefit (sr 110532). */ -#ifdef __cplusplus -extern "C" -#endif -char openpty (void); -int -main (void) -{ -return openpty (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_lib_bsd_openpty=yes -else case e in #( - e) ac_cv_lib_bsd_openpty=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_openpty" >&5 -printf "%s\n" "$ac_cv_lib_bsd_openpty" >&6; } -if test "x$ac_cv_lib_bsd_openpty" = xyes -then : - printf "%s\n" "#define HAVE_OPENPTY 1" >>confdefs.h - LIBS="$LIBS -lbsd" -fi - ;; -esac -fi - ;; -esac -fi - -done -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing login_tty" >&5 -printf %s "checking for library containing login_tty... " >&6; } -if test ${ac_cv_search_login_tty+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. - The 'extern "C"' is for builds by C++ compilers; - although this is not generally supported in C code supporting it here - has little cost and some practical benefit (sr 110532). */ -#ifdef __cplusplus -extern "C" -#endif -char login_tty (void); -int -main (void) -{ -return login_tty (); - ; - return 0; -} -_ACEOF -for ac_lib in '' util -do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO" -then : - ac_cv_search_login_tty=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext - if test ${ac_cv_search_login_tty+y} -then : - break -fi -done -if test ${ac_cv_search_login_tty+y} -then : - -else case e in #( - e) ac_cv_search_login_tty=no ;; -esac -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_login_tty" >&5 -printf "%s\n" "$ac_cv_search_login_tty" >&6; } -ac_res=$ac_cv_search_login_tty -if test "$ac_res" != no -then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - -printf "%s\n" "#define HAVE_LOGIN_TTY 1" >>confdefs.h - - -fi - - - for ac_func in forkpty -do : - ac_fn_c_check_func "$LINENO" "forkpty" "ac_cv_func_forkpty" -if test "x$ac_cv_func_forkpty" = xyes -then : - printf "%s\n" "#define HAVE_FORKPTY 1" >>confdefs.h - -else case e in #( - e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for forkpty in -lutil" >&5 -printf %s "checking for forkpty in -lutil... " >&6; } -if test ${ac_cv_lib_util_forkpty+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) ac_check_lib_save_LIBS=$LIBS -LIBS="-lutil $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. - The 'extern "C"' is for builds by C++ compilers; - although this is not generally supported in C code supporting it here - has little cost and some practical benefit (sr 110532). */ -#ifdef __cplusplus -extern "C" -#endif -char forkpty (void); -int -main (void) -{ -return forkpty (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_lib_util_forkpty=yes -else case e in #( - e) ac_cv_lib_util_forkpty=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_util_forkpty" >&5 -printf "%s\n" "$ac_cv_lib_util_forkpty" >&6; } -if test "x$ac_cv_lib_util_forkpty" = xyes -then : - printf "%s\n" "#define HAVE_FORKPTY 1" >>confdefs.h - LIBS="$LIBS -lutil" -else case e in #( - e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for forkpty in -lbsd" >&5 -printf %s "checking for forkpty in -lbsd... " >&6; } -if test ${ac_cv_lib_bsd_forkpty+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) ac_check_lib_save_LIBS=$LIBS -LIBS="-lbsd $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. - The 'extern "C"' is for builds by C++ compilers; - although this is not generally supported in C code supporting it here - has little cost and some practical benefit (sr 110532). */ -#ifdef __cplusplus -extern "C" -#endif -char forkpty (void); -int -main (void) -{ -return forkpty (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_lib_bsd_forkpty=yes -else case e in #( - e) ac_cv_lib_bsd_forkpty=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_forkpty" >&5 -printf "%s\n" "$ac_cv_lib_bsd_forkpty" >&6; } -if test "x$ac_cv_lib_bsd_forkpty" = xyes -then : - printf "%s\n" "#define HAVE_FORKPTY 1" >>confdefs.h - LIBS="$LIBS -lbsd" -fi - ;; -esac -fi - ;; -esac -fi - -done - -# check for long file support functions -ac_fn_c_check_func "$LINENO" "fseek64" "ac_cv_func_fseek64" -if test "x$ac_cv_func_fseek64" = xyes -then : - printf "%s\n" "#define HAVE_FSEEK64 1" >>confdefs.h - -fi -ac_fn_c_check_func "$LINENO" "fseeko" "ac_cv_func_fseeko" -if test "x$ac_cv_func_fseeko" = xyes -then : - printf "%s\n" "#define HAVE_FSEEKO 1" >>confdefs.h - -fi -ac_fn_c_check_func "$LINENO" "fstatvfs" "ac_cv_func_fstatvfs" -if test "x$ac_cv_func_fstatvfs" = xyes -then : - printf "%s\n" "#define HAVE_FSTATVFS 1" >>confdefs.h - -fi -ac_fn_c_check_func "$LINENO" "ftell64" "ac_cv_func_ftell64" -if test "x$ac_cv_func_ftell64" = xyes -then : - printf "%s\n" "#define HAVE_FTELL64 1" >>confdefs.h - -fi -ac_fn_c_check_func "$LINENO" "ftello" "ac_cv_func_ftello" -if test "x$ac_cv_func_ftello" = xyes -then : - printf "%s\n" "#define HAVE_FTELLO 1" >>confdefs.h - -fi -ac_fn_c_check_func "$LINENO" "statvfs" "ac_cv_func_statvfs" -if test "x$ac_cv_func_statvfs" = xyes -then : - printf "%s\n" "#define HAVE_STATVFS 1" >>confdefs.h - -fi - - -ac_fn_c_check_func "$LINENO" "dup2" "ac_cv_func_dup2" -if test "x$ac_cv_func_dup2" = xyes -then : - printf "%s\n" "#define HAVE_DUP2 1" >>confdefs.h - -else case e in #( - e) case " $LIBOBJS " in - *" dup2.$ac_objext "* -else - ZLIB_CFLAGS=$pkg_cv_ZLIB_CFLAGS - ZLIB_LIBS=$pkg_cv_ZLIB_LIBS - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } - - printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h - - -fi ;; + *" dup2.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS dup2.$ac_objext" ;; esac diff --git a/configure.ac b/configure.ac index 5d097d8e1c6353..badc0aa3bf5986 100644 --- a/configure.ac +++ b/configure.ac @@ -5327,37 +5327,29 @@ AH_TEMPLATE([HAVE_ZLIB_COPY], [Define if the zlib library has inflateCopy; zlib dnl 2022-03: Until we know if third party zlib modules people use (for hardware dnl accelerators, parallelism, etc.) all support copy, lets not assume. -AS_CASE([$ac_sys_system], - [WASI], - [ - dnl WASM does not have zlib - BINASCII_CFLAGS="-DNO_ZLIB_CRC32" - ], - [ - PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [ - dnl zlib 1.2.0 (2003) added inflateCopy - AC_DEFINE([HAVE_ZLIB_COPY], [1]) +PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [ + dnl zlib 1.2.0 (2003) added inflateCopy + AC_DEFINE([HAVE_ZLIB_COPY], [1]) +], [ + AC_CHECK_HEADERS([zlib.h], [ + WITH_SAVE_ENV([ + AC_CHECK_LIB([z], [gzread], [ + ZLIB_CFLAGS=${ZLIB_CFLAGS-""} + ZLIB_LIBS=${ZLIB_LIBS-"-lz"} + AC_CHECK_LIB([z], [inflateCopy], [AC_DEFINE([HAVE_ZLIB_COPY], [1])]) ], [ - AC_CHECK_HEADERS([zlib.h], [ - WITH_SAVE_ENV([ - AC_CHECK_LIB([z], [gzread], [ - ZLIB_CFLAGS=${ZLIB_CFLAGS-""} - ZLIB_LIBS=${ZLIB_LIBS-"-lz"} - AC_CHECK_LIB([z], [inflateCopy], [AC_DEFINE([HAVE_ZLIB_COPY], [1])]) - ], [ - AC_MSG_ERROR([m4_normalize([ - zlib.h and libz are required. Install your OS's zlib-devel or - zlib1g-dev equivalent library or get it from https://zlib.net/. - ])]) - ]) - ]) - ], [ - AC_MSG_ERROR([m4_normalize([ - zlib.h and libz are required. Install your OS's zlib-devel or - zlib1g-dev equivalent library or get it from https://zlib.net/. - ])]) - ]) - ] + AC_MSG_ERROR([m4_normalize([ + zlib.h and libz are required. Install your OS's zlib-devel or + zlib1g-dev equivalent library or get it from https://zlib.net/. + ])]) + ]) + ]) + ], [ + AC_MSG_ERROR([m4_normalize([ + zlib.h and libz are required. Install your OS's zlib-devel or + zlib1g-dev equivalent library or get it from https://zlib.net/. + ])]) + ]) ]) dnl detect bzip2 from Emscripten emport From e347c1733c00de9902397d8ecb039ae74013d4d8 Mon Sep 17 00:00:00 2001 From: stan Date: Mon, 17 Feb 2025 22:05:44 +0000 Subject: [PATCH 10/30] Fix stuff --- configure | 6 ++++++ configure.ac | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 7b4d4eba9d298a..2906a8b19a4251 100755 --- a/configure +++ b/configure @@ -21449,6 +21449,10 @@ fi +case $ac_sys_system in #( + WASI) : + ;; #( + *) : pkg_failed=no { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for zlib >= 1.2.0" >&5 @@ -21793,6 +21797,8 @@ printf "%s\n" "yes" >&6; } fi + ;; +esac diff --git a/configure.ac b/configure.ac index badc0aa3bf5986..4fa90e6f0646f1 100644 --- a/configure.ac +++ b/configure.ac @@ -5327,7 +5327,9 @@ AH_TEMPLATE([HAVE_ZLIB_COPY], [Define if the zlib library has inflateCopy; zlib dnl 2022-03: Until we know if third party zlib modules people use (for hardware dnl accelerators, parallelism, etc.) all support copy, lets not assume. -PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [ +AS_CASE([$ac_sys_system], + [WASI], [], +[PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [ dnl zlib 1.2.0 (2003) added inflateCopy AC_DEFINE([HAVE_ZLIB_COPY], [1]) ], [ @@ -5351,6 +5353,7 @@ PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [ ])]) ]) ]) +]) dnl detect bzip2 from Emscripten emport PY_CHECK_EMSCRIPTEN_PORT([BZIP2], [-sUSE_BZIP2]) From c6fafae4dcf2e6548386ad0e6594f11bdfabe2ad Mon Sep 17 00:00:00 2001 From: stan Date: Mon, 17 Feb 2025 22:41:22 +0000 Subject: [PATCH 11/30] Use non-zlib implementation if WASI --- Modules/binascii.c | 162 ++++++++++++++++++++++++++++++++++++++++++++- configure | 11 ++- configure.ac | 9 ++- 3 files changed, 175 insertions(+), 7 deletions(-) diff --git a/Modules/binascii.c b/Modules/binascii.c index 27096c1010d8d1..b00e286072acd1 100644 --- a/Modules/binascii.c +++ b/Modules/binascii.c @@ -60,7 +60,9 @@ #include "Python.h" #include "pycore_long.h" // _PyLong_DigitValue #include "pycore_strhex.h" // _Py_strhex_bytes_with_sep() -#include "zlib.h" // crc32() +#ifndef NO_ZLIB_CRC32 +# include "zlib.h" +#endif typedef struct binascii_state { PyObject *Error; @@ -614,6 +616,140 @@ binascii_crc_hqx_impl(PyObject *module, Py_buffer *data, unsigned int crc) return PyLong_FromUnsignedLong(crc); } +#ifdef NO_ZLIB_CRC32 +/* Crc - 32 BIT ANSI X3.66 CRC checksum files + Also known as: ISO 3307 +**********************************************************************| +* *| +* Demonstration program to compute the 32-bit CRC used as the frame *| +* check sequence in ADCCP (ANSI X3.66, also known as FIPS PUB 71 *| +* and FED-STD-1003, the U.S. versions of CCITT's X.25 link-level *| +* protocol). The 32-bit FCS was added via the Federal Register, *| +* 1 June 1982, p.23798. I presume but don't know for certain that *| +* this polynomial is or will be included in CCITT V.41, which *| +* defines the 16-bit CRC (often called CRC-CCITT) polynomial. FIPS *| +* PUB 78 says that the 32-bit FCS reduces otherwise undetected *| +* errors by a factor of 10^-5 over 16-bit FCS. *| +* *| +**********************************************************************| + + Copyright (C) 1986 Gary S. Brown. You may use this program, or + code or tables extracted from it, as desired without restriction. + + First, the polynomial itself and its table of feedback terms. The + polynomial is + X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 + Note that we take it "backwards" and put the highest-order term in + the lowest-order bit. The X^32 term is "implied"; the LSB is the + X^31 term, etc. The X^0 term (usually shown as "+1") results in + the MSB being 1. + + Note that the usual hardware shift register implementation, which + is what we're using (we're merely optimizing it by doing eight-bit + chunks at a time) shifts bits into the lowest-order term. In our + implementation, that means shifting towards the right. Why do we + do it this way? Because the calculated CRC must be transmitted in + order from highest-order term to lowest-order term. UARTs transmit + characters in order from LSB to MSB. By storing the CRC this way, + we hand it to the UART in the order low-byte to high-byte; the UART + sends each low-bit to hight-bit; and the result is transmission bit + by bit from highest- to lowest-order term without requiring any bit + shuffling on our part. Reception works similarly. + + The feedback terms table consists of 256, 32-bit entries. Notes: + + 1. The table can be generated at runtime if desired; code to do so + is shown later. It might not be obvious, but the feedback + terms simply represent the results of eight shift/xor opera- + tions for all combinations of data and CRC register values. + + 2. The CRC accumulation logic is the same for all CRC polynomials, + be they sixteen or thirty-two bits wide. You simply choose the + appropriate table. Alternatively, because the table can be + generated at runtime, you can start by generating the table for + the polynomial in question and use exactly the same "updcrc", + if your application needn't simultaneously handle two CRC + polynomials. (Note, however, that XMODEM is strange.) + + 3. For 16-bit CRCs, the table entries need be only 16 bits wide; + of course, 32-bit entries work OK if the high 16 bits are zero. + + 4. The values must be right-shifted by eight bits by the "updcrc" + logic; the shift must be unsigned (bring in zeroes). On some + hardware you could probably optimize the shift in assembler by + using byte-swap instructions. +********************************************************************/ + +static const unsigned int crc_32_tab[256] = { +0x00000000U, 0x77073096U, 0xee0e612cU, 0x990951baU, 0x076dc419U, +0x706af48fU, 0xe963a535U, 0x9e6495a3U, 0x0edb8832U, 0x79dcb8a4U, +0xe0d5e91eU, 0x97d2d988U, 0x09b64c2bU, 0x7eb17cbdU, 0xe7b82d07U, +0x90bf1d91U, 0x1db71064U, 0x6ab020f2U, 0xf3b97148U, 0x84be41deU, +0x1adad47dU, 0x6ddde4ebU, 0xf4d4b551U, 0x83d385c7U, 0x136c9856U, +0x646ba8c0U, 0xfd62f97aU, 0x8a65c9ecU, 0x14015c4fU, 0x63066cd9U, +0xfa0f3d63U, 0x8d080df5U, 0x3b6e20c8U, 0x4c69105eU, 0xd56041e4U, +0xa2677172U, 0x3c03e4d1U, 0x4b04d447U, 0xd20d85fdU, 0xa50ab56bU, +0x35b5a8faU, 0x42b2986cU, 0xdbbbc9d6U, 0xacbcf940U, 0x32d86ce3U, +0x45df5c75U, 0xdcd60dcfU, 0xabd13d59U, 0x26d930acU, 0x51de003aU, +0xc8d75180U, 0xbfd06116U, 0x21b4f4b5U, 0x56b3c423U, 0xcfba9599U, +0xb8bda50fU, 0x2802b89eU, 0x5f058808U, 0xc60cd9b2U, 0xb10be924U, +0x2f6f7c87U, 0x58684c11U, 0xc1611dabU, 0xb6662d3dU, 0x76dc4190U, +0x01db7106U, 0x98d220bcU, 0xefd5102aU, 0x71b18589U, 0x06b6b51fU, +0x9fbfe4a5U, 0xe8b8d433U, 0x7807c9a2U, 0x0f00f934U, 0x9609a88eU, +0xe10e9818U, 0x7f6a0dbbU, 0x086d3d2dU, 0x91646c97U, 0xe6635c01U, +0x6b6b51f4U, 0x1c6c6162U, 0x856530d8U, 0xf262004eU, 0x6c0695edU, +0x1b01a57bU, 0x8208f4c1U, 0xf50fc457U, 0x65b0d9c6U, 0x12b7e950U, +0x8bbeb8eaU, 0xfcb9887cU, 0x62dd1ddfU, 0x15da2d49U, 0x8cd37cf3U, +0xfbd44c65U, 0x4db26158U, 0x3ab551ceU, 0xa3bc0074U, 0xd4bb30e2U, +0x4adfa541U, 0x3dd895d7U, 0xa4d1c46dU, 0xd3d6f4fbU, 0x4369e96aU, +0x346ed9fcU, 0xad678846U, 0xda60b8d0U, 0x44042d73U, 0x33031de5U, +0xaa0a4c5fU, 0xdd0d7cc9U, 0x5005713cU, 0x270241aaU, 0xbe0b1010U, +0xc90c2086U, 0x5768b525U, 0x206f85b3U, 0xb966d409U, 0xce61e49fU, +0x5edef90eU, 0x29d9c998U, 0xb0d09822U, 0xc7d7a8b4U, 0x59b33d17U, +0x2eb40d81U, 0xb7bd5c3bU, 0xc0ba6cadU, 0xedb88320U, 0x9abfb3b6U, +0x03b6e20cU, 0x74b1d29aU, 0xead54739U, 0x9dd277afU, 0x04db2615U, +0x73dc1683U, 0xe3630b12U, 0x94643b84U, 0x0d6d6a3eU, 0x7a6a5aa8U, +0xe40ecf0bU, 0x9309ff9dU, 0x0a00ae27U, 0x7d079eb1U, 0xf00f9344U, +0x8708a3d2U, 0x1e01f268U, 0x6906c2feU, 0xf762575dU, 0x806567cbU, +0x196c3671U, 0x6e6b06e7U, 0xfed41b76U, 0x89d32be0U, 0x10da7a5aU, +0x67dd4accU, 0xf9b9df6fU, 0x8ebeeff9U, 0x17b7be43U, 0x60b08ed5U, +0xd6d6a3e8U, 0xa1d1937eU, 0x38d8c2c4U, 0x4fdff252U, 0xd1bb67f1U, +0xa6bc5767U, 0x3fb506ddU, 0x48b2364bU, 0xd80d2bdaU, 0xaf0a1b4cU, +0x36034af6U, 0x41047a60U, 0xdf60efc3U, 0xa867df55U, 0x316e8eefU, +0x4669be79U, 0xcb61b38cU, 0xbc66831aU, 0x256fd2a0U, 0x5268e236U, +0xcc0c7795U, 0xbb0b4703U, 0x220216b9U, 0x5505262fU, 0xc5ba3bbeU, +0xb2bd0b28U, 0x2bb45a92U, 0x5cb36a04U, 0xc2d7ffa7U, 0xb5d0cf31U, +0x2cd99e8bU, 0x5bdeae1dU, 0x9b64c2b0U, 0xec63f226U, 0x756aa39cU, +0x026d930aU, 0x9c0906a9U, 0xeb0e363fU, 0x72076785U, 0x05005713U, +0x95bf4a82U, 0xe2b87a14U, 0x7bb12baeU, 0x0cb61b38U, 0x92d28e9bU, +0xe5d5be0dU, 0x7cdcefb7U, 0x0bdbdf21U, 0x86d3d2d4U, 0xf1d4e242U, +0x68ddb3f8U, 0x1fda836eU, 0x81be16cdU, 0xf6b9265bU, 0x6fb077e1U, +0x18b74777U, 0x88085ae6U, 0xff0f6a70U, 0x66063bcaU, 0x11010b5cU, +0x8f659effU, 0xf862ae69U, 0x616bffd3U, 0x166ccf45U, 0xa00ae278U, +0xd70dd2eeU, 0x4e048354U, 0x3903b3c2U, 0xa7672661U, 0xd06016f7U, +0x4969474dU, 0x3e6e77dbU, 0xaed16a4aU, 0xd9d65adcU, 0x40df0b66U, +0x37d83bf0U, 0xa9bcae53U, 0xdebb9ec5U, 0x47b2cf7fU, 0x30b5ffe9U, +0xbdbdf21cU, 0xcabac28aU, 0x53b39330U, 0x24b4a3a6U, 0xbad03605U, +0xcdd70693U, 0x54de5729U, 0x23d967bfU, 0xb3667a2eU, 0xc4614ab8U, +0x5d681b02U, 0x2a6f2b94U, 0xb40bbe37U, 0xc30c8ea1U, 0x5a05df1bU, +0x2d02ef8dU +}; + +static unsigned int +internal_crc32(const unsigned char *bin_data, Py_ssize_t len, unsigned int crc) +{ /* By Jim Ahlstrom; All rights transferred to CNRI */ + unsigned int result; + + crc = ~ crc; + while (len-- > 0) { + crc = crc_32_tab[(crc ^ *bin_data++) & 0xff] ^ (crc >> 8); + /* Note: (crc >> 8) MUST zero fill on left */ + } + + result = (crc ^ 0xFFFFFFFF); + return result & 0xffffffff; +} +#endif /* NO_ZLIB_CRC32 */ /*[clinic input] binascii.crc32 -> unsigned_int @@ -628,8 +764,12 @@ Compute CRC-32 incrementally. static unsigned int binascii_crc32_impl(PyObject *module, Py_buffer *data, unsigned int crc) /*[clinic end generated code: output=52cf59056a78593b input=bbe340bc99d25aa8]*/ + +#ifndef NO_ZLIB_CRC32 /* This is the same as zlibmodule.c zlib_crc32_impl. It exists in two - * modules for historical reasons. We should consolidate the two. */ + modules for historical reasons. They should be consolidated however + this will not be possible for WASI does not have zlib. + */ { /* Releasing the GIL for very small buffers is inefficient and may lower performance */ @@ -660,6 +800,24 @@ binascii_crc32_impl(PyObject *module, Py_buffer *data, unsigned int crc) } return crc & 0xffffffff; } +#else /* NO_ZLIB_CRC32 */ +{ + const unsigned char *bin_data = data->buf; + Py_ssize_t len = data->len; + + /* Releasing the GIL for very small buffers is inefficient + and may lower performance */ + if (len > 1024*5) { + unsigned int result; + Py_BEGIN_ALLOW_THREADS + result = internal_crc32(bin_data, len, crc); + Py_END_ALLOW_THREADS + return result; + } else { + return internal_crc32(bin_data, len, crc); + } +} +#endif /* NO_ZLIB_CRC32 */ /*[clinic input] binascii.b2a_hex diff --git a/configure b/configure index 2906a8b19a4251..c5dc33bf23b19f 100755 --- a/configure +++ b/configure @@ -21451,7 +21451,10 @@ fi case $ac_sys_system in #( WASI) : - ;; #( + + BINASCII_CFLAGS="-DNO_ZLIB_CRC32" + BINASCII_LIBS="" + ;; #( *) : pkg_failed=no @@ -21795,6 +21798,8 @@ printf "%s\n" "yes" >&6; } printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h + BINASCII_CFLAGS="$ZLIB_CFLAGS" + BINASCII_LIBS="$ZLIB_LIBS" fi ;; @@ -32626,8 +32631,8 @@ fi if test "x$py_cv_module_binascii" = xyes then : - as_fn_append MODULE_BLOCK "MODULE_BINASCII_CFLAGS=$ZLIB_CFLAGS$as_nl" - as_fn_append MODULE_BLOCK "MODULE_BINASCII_LDFLAGS=$ZLIB_LIBS$as_nl" + as_fn_append MODULE_BLOCK "MODULE_BINASCII_CFLAGS=$BINASCII_CFLAGS$as_nl" + as_fn_append MODULE_BLOCK "MODULE_BINASCII_LDFLAGS=$BINASCII_LIBS$as_nl" fi diff --git a/configure.ac b/configure.ac index 4fa90e6f0646f1..f0277dc43e705d 100644 --- a/configure.ac +++ b/configure.ac @@ -5328,10 +5328,15 @@ dnl 2022-03: Until we know if third party zlib modules people use (for hardware dnl accelerators, parallelism, etc.) all support copy, lets not assume. AS_CASE([$ac_sys_system], - [WASI], [], + [WASI], [ + BINASCII_CFLAGS="-DNO_ZLIB_CRC32" + BINASCII_LIBS="" + ], [PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [ dnl zlib 1.2.0 (2003) added inflateCopy AC_DEFINE([HAVE_ZLIB_COPY], [1]) + BINASCII_CFLAGS="$ZLIB_CFLAGS" + BINASCII_LIBS="$ZLIB_LIBS" ], [ AC_CHECK_HEADERS([zlib.h], [ WITH_SAVE_ENV([ @@ -7937,7 +7942,7 @@ PY_STDLIB_MOD([_uuid], dnl compression libs PY_STDLIB_MOD_SIMPLE([zlib], [$ZLIB_CFLAGS], [$ZLIB_LIBS]) dnl binascii uses zlib for optimized crc32. -PY_STDLIB_MOD_SIMPLE([binascii], [$ZLIB_CFLAGS], [$ZLIB_LIBS]) +PY_STDLIB_MOD_SIMPLE([binascii], [$BINASCII_CFLAGS], [$BINASCII_LIBS]) PY_STDLIB_MOD([_bz2], [], [test "$have_bzip2" = yes], [$BZIP2_CFLAGS], [$BZIP2_LIBS]) PY_STDLIB_MOD([_lzma], [], [test "$have_liblzma" = yes], From c779e376ba59988639ea29ec30cdb05ce9d04679 Mon Sep 17 00:00:00 2001 From: stan Date: Mon, 17 Feb 2025 22:56:51 +0000 Subject: [PATCH 12/30] Fix minor error --- configure | 30 ++++++++++++++++++++++++------ configure.ac | 3 ++- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/configure b/configure index c5dc33bf23b19f..271c96031d62bf 100755 --- a/configure +++ b/configure @@ -32593,18 +32593,26 @@ printf "%s\n" "$py_cv_module__uuid" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module zlib" >&5 +printf %s "checking for stdlib extension module zlib... " >&6; } if test "$py_cv_module_zlib" != "n/a" then : + + if true +then : + if test "$ac_sys_system" != WASI +then : py_cv_module_zlib=yes +else case e in #( + e) py_cv_module_zlib=missing ;; +esac fi - if test "$py_cv_module_zlib" = yes; then - MODULE_ZLIB_TRUE= - MODULE_ZLIB_FALSE='#' -else - MODULE_ZLIB_TRUE='#' - MODULE_ZLIB_FALSE= +else case e in #( + e) py_cv_module_zlib=disabled ;; +esac fi +fi as_fn_append MODULE_BLOCK "MODULE_ZLIB_STATE=$py_cv_module_zlib$as_nl" if test "x$py_cv_module_zlib" = xyes then : @@ -32613,6 +32621,16 @@ then : as_fn_append MODULE_BLOCK "MODULE_ZLIB_LDFLAGS=$ZLIB_LIBS$as_nl" fi + if test "$py_cv_module_zlib" = yes; then + MODULE_ZLIB_TRUE= + MODULE_ZLIB_FALSE='#' +else + MODULE_ZLIB_TRUE='#' + MODULE_ZLIB_FALSE= +fi + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $py_cv_module_zlib" >&5 +printf "%s\n" "$py_cv_module_zlib" >&6; } if test "$py_cv_module_binascii" != "n/a" diff --git a/configure.ac b/configure.ac index f0277dc43e705d..75ac0436d7204d 100644 --- a/configure.ac +++ b/configure.ac @@ -7940,7 +7940,8 @@ PY_STDLIB_MOD([_uuid], [$LIBUUID_CFLAGS], [$LIBUUID_LIBS]) dnl compression libs -PY_STDLIB_MOD_SIMPLE([zlib], [$ZLIB_CFLAGS], [$ZLIB_LIBS]) +PY_STDLIB_MOD([zlib], [], [test "$ac_sys_system" != WASI], + [$ZLIB_CFLAGS], [$ZLIB_LIBS]) dnl binascii uses zlib for optimized crc32. PY_STDLIB_MOD_SIMPLE([binascii], [$BINASCII_CFLAGS], [$BINASCII_LIBS]) PY_STDLIB_MOD([_bz2], [], [test "$have_bzip2" = yes], From 966808631bfa6f6a564de1631ff60137580159f7 Mon Sep 17 00:00:00 2001 From: stan Date: Mon, 17 Feb 2025 23:35:34 +0000 Subject: [PATCH 13/30] Correct indentation --- configure.ac | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/configure.ac b/configure.ac index 75ac0436d7204d..c39ee9d01a4f49 100644 --- a/configure.ac +++ b/configure.ac @@ -5329,36 +5329,39 @@ dnl accelerators, parallelism, etc.) all support copy, lets not assume. AS_CASE([$ac_sys_system], [WASI], [ + PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [ + AC_DEFINE([HAVE_ZLIB_COPY], [1]) + ] BINASCII_CFLAGS="-DNO_ZLIB_CRC32" BINASCII_LIBS="" ], -[PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [ - dnl zlib 1.2.0 (2003) added inflateCopy - AC_DEFINE([HAVE_ZLIB_COPY], [1]) - BINASCII_CFLAGS="$ZLIB_CFLAGS" - BINASCII_LIBS="$ZLIB_LIBS" -], [ - AC_CHECK_HEADERS([zlib.h], [ - WITH_SAVE_ENV([ - AC_CHECK_LIB([z], [gzread], [ - ZLIB_CFLAGS=${ZLIB_CFLAGS-""} - ZLIB_LIBS=${ZLIB_LIBS-"-lz"} - AC_CHECK_LIB([z], [inflateCopy], [AC_DEFINE([HAVE_ZLIB_COPY], [1])]) + [PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [ + dnl zlib 1.2.0 (2003) added inflateCopy + AC_DEFINE([HAVE_ZLIB_COPY], [1]) + BINASCII_CFLAGS="$ZLIB_CFLAGS" + BINASCII_LIBS="$ZLIB_LIBS" + ], [ + AC_CHECK_HEADERS([zlib.h], [ + WITH_SAVE_ENV([ + AC_CHECK_LIB([z], [gzread], [ + ZLIB_CFLAGS=${ZLIB_CFLAGS-""} + ZLIB_LIBS=${ZLIB_LIBS-"-lz"} + AC_CHECK_LIB([z], [inflateCopy], [AC_DEFINE([HAVE_ZLIB_COPY], [1])]) + ], [ + AC_MSG_ERROR([m4_normalize([ + zlib.h and libz are required. Install your OS's zlib-devel or + zlib1g-dev equivalent library or get it from https://zlib.net/. + ])]) + ]) + ]) ], [ AC_MSG_ERROR([m4_normalize([ zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/. - ])]) - ]) + ])]) ]) - ], [ - AC_MSG_ERROR([m4_normalize([ - zlib.h and libz are required. Install your OS's zlib-devel or - zlib1g-dev equivalent library or get it from https://zlib.net/. - ])]) ]) ]) -]) dnl detect bzip2 from Emscripten emport PY_CHECK_EMSCRIPTEN_PORT([BZIP2], [-sUSE_BZIP2]) From 6f5e65e3fef5744f901cd8a119215fa5d8ca96e2 Mon Sep 17 00:00:00 2001 From: stan Date: Mon, 17 Feb 2025 23:38:55 +0000 Subject: [PATCH 14/30] Pushing configure would be handy :-/ --- configure | 160 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 127 insertions(+), 33 deletions(-) diff --git a/configure b/configure index 271c96031d62bf..c38cf32a4c23ed 100755 --- a/configure +++ b/configure @@ -1996,15 +1996,6 @@ Some influential environment variables: X11_LIBS linker flags for X11, overriding pkg-config GDBM_CFLAGS C compiler flags for gdbm GDBM_LIBS additional linker flags for gdbm - ZLIB_CFLAGS C compiler flags for ZLIB, overriding pkg-config - ZLIB_LIBS linker flags for ZLIB, overriding pkg-config - BZIP2_CFLAGS - C compiler flags for BZIP2, overriding pkg-config - BZIP2_LIBS linker flags for BZIP2, overriding pkg-config - LIBLZMA_CFLAGS - C compiler flags for LIBLZMA, overriding pkg-config - LIBLZMA_LIBS - linker flags for LIBLZMA, overriding pkg-config LIBREADLINE_CFLAGS C compiler flags for LIBREADLINE, overriding pkg-config LIBREADLINE_LIBS @@ -21452,10 +21443,105 @@ fi case $ac_sys_system in #( WASI) : + +pkg_failed=no +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for zlib >= 1.2.0" >&5 +printf %s "checking for zlib >= 1.2.0... " >&6; } + +if test -n "$ZLIB_CFLAGS"; then + pkg_cv_ZLIB_CFLAGS="$ZLIB_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"zlib >= 1.2.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "zlib >= 1.2.0") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_ZLIB_CFLAGS=`$PKG_CONFIG --cflags "zlib >= 1.2.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$ZLIB_LIBS"; then + pkg_cv_ZLIB_LIBS="$ZLIB_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"zlib >= 1.2.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "zlib >= 1.2.0") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_ZLIB_LIBS=`$PKG_CONFIG --libs "zlib >= 1.2.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + ZLIB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "zlib >= 1.2.0" 2>&1` + else + ZLIB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "zlib >= 1.2.0" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$ZLIB_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (zlib >= 1.2.0) were not met: + +$ZLIB_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables ZLIB_CFLAGS +and ZLIB_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables ZLIB_CFLAGS +and ZLIB_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See 'config.log' for more details" "$LINENO" 5; } +else + ZLIB_CFLAGS=$pkg_cv_ZLIB_CFLAGS + ZLIB_LIBS=$pkg_cv_ZLIB_LIBS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + + printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h + + BINASCII_CFLAGS="-DNO_ZLIB_CRC32" BINASCII_LIBS="" ;; #( *) : + ZLIB_CFLAGS C compiler flags for ZLIB, overriding pkg-config + ZLIB_LIBS linker flags for ZLIB, overriding pkg-config pkg_failed=no { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for zlib >= 1.2.0" >&5 @@ -21516,20 +21602,20 @@ fi echo "$ZLIB_PKG_ERRORS" >&5 - for ac_header in zlib.h + for ac_header in zlib.h do : ac_fn_c_check_header_compile "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" if test "x$ac_cv_header_zlib_h" = xyes then : printf "%s\n" "#define HAVE_ZLIB_H 1" >>confdefs.h - save_CFLAGS=$CFLAGS + save_CFLAGS=$CFLAGS save_CPPFLAGS=$CPPFLAGS save_LDFLAGS=$LDFLAGS save_LIBS=$LIBS - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzread in -lz" >&5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzread in -lz" >&5 printf %s "checking for gzread in -lz... " >&6; } if test ${ac_cv_lib_z_gzread+y} then : @@ -21575,9 +21661,9 @@ printf "%s\n" "$ac_cv_lib_z_gzread" >&6; } if test "x$ac_cv_lib_z_gzread" = xyes then : - ZLIB_CFLAGS=${ZLIB_CFLAGS-""} - ZLIB_LIBS=${ZLIB_LIBS-"-lz"} - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5 + ZLIB_CFLAGS=${ZLIB_CFLAGS-""} + ZLIB_LIBS=${ZLIB_LIBS-"-lz"} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5 printf %s "checking for inflateCopy in -lz... " >&6; } if test ${ac_cv_lib_z_inflateCopy+y} then : @@ -21629,8 +21715,8 @@ fi else case e in #( e) - as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 - ;; + as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 + ;; esac fi @@ -21644,8 +21730,8 @@ LIBS=$save_LIBS else case e in #( e) - as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 - ;; + as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 + ;; esac fi @@ -21655,20 +21741,20 @@ elif test $pkg_failed = untried; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } - for ac_header in zlib.h + for ac_header in zlib.h do : ac_fn_c_check_header_compile "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" if test "x$ac_cv_header_zlib_h" = xyes then : printf "%s\n" "#define HAVE_ZLIB_H 1" >>confdefs.h - save_CFLAGS=$CFLAGS + save_CFLAGS=$CFLAGS save_CPPFLAGS=$CPPFLAGS save_LDFLAGS=$LDFLAGS save_LIBS=$LIBS - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzread in -lz" >&5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzread in -lz" >&5 printf %s "checking for gzread in -lz... " >&6; } if test ${ac_cv_lib_z_gzread+y} then : @@ -21714,9 +21800,9 @@ printf "%s\n" "$ac_cv_lib_z_gzread" >&6; } if test "x$ac_cv_lib_z_gzread" = xyes then : - ZLIB_CFLAGS=${ZLIB_CFLAGS-""} - ZLIB_LIBS=${ZLIB_LIBS-"-lz"} - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5 + ZLIB_CFLAGS=${ZLIB_CFLAGS-""} + ZLIB_LIBS=${ZLIB_LIBS-"-lz"} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5 printf %s "checking for inflateCopy in -lz... " >&6; } if test ${ac_cv_lib_z_inflateCopy+y} then : @@ -21768,8 +21854,8 @@ fi else case e in #( e) - as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 - ;; + as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 + ;; esac fi @@ -21783,8 +21869,8 @@ LIBS=$save_LIBS else case e in #( e) - as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 - ;; + as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 + ;; esac fi @@ -21796,10 +21882,10 @@ else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } - printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h + printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h - BINASCII_CFLAGS="$ZLIB_CFLAGS" - BINASCII_LIBS="$ZLIB_LIBS" + BINASCII_CFLAGS="$ZLIB_CFLAGS" + BINASCII_LIBS="$ZLIB_LIBS" fi ;; @@ -21819,6 +21905,9 @@ fi + BZIP2_CFLAGS + C compiler flags for BZIP2, overriding pkg-config + BZIP2_LIBS linker flags for BZIP2, overriding pkg-config pkg_failed=no { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for bzip2" >&5 @@ -22067,6 +22156,10 @@ printf "%s\n" "yes" >&6; } have_bzip2=yes fi + LIBLZMA_CFLAGS + C compiler flags for LIBLZMA, overriding pkg-config + LIBLZMA_LIBS + linker flags for LIBLZMA, overriding pkg-config pkg_failed=no { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for liblzma" >&5 @@ -23558,7 +23651,8 @@ then : else case e in #( e) case " $LIBOBJS " in - *" dup2.$ac_objext "* ) ;; + *" dup2.$ac_objext "* +fi ;; *) LIBOBJS="$LIBOBJS dup2.$ac_objext" ;; esac From 2626b5e84be36e2326c7f60b7fc160a4f56cad0e Mon Sep 17 00:00:00 2001 From: stan Date: Mon, 17 Feb 2025 23:42:17 +0000 Subject: [PATCH 15/30] Fix error --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index c39ee9d01a4f49..3c5b8f9f284a4f 100644 --- a/configure.ac +++ b/configure.ac @@ -5331,9 +5331,9 @@ AS_CASE([$ac_sys_system], [WASI], [ PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [ AC_DEFINE([HAVE_ZLIB_COPY], [1]) + BINASCII_CFLAGS="-DNO_ZLIB_CRC32" + BINASCII_LIBS="" ] - BINASCII_CFLAGS="-DNO_ZLIB_CRC32" - BINASCII_LIBS="" ], [PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [ dnl zlib 1.2.0 (2003) added inflateCopy From 080918a28d5211e6d014b10df9dfe3b464781c0b Mon Sep 17 00:00:00 2001 From: stan Date: Mon, 17 Feb 2025 23:42:52 +0000 Subject: [PATCH 16/30] Fix error configure --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index c38cf32a4c23ed..ddcdd9462db631 100755 --- a/configure +++ b/configure @@ -21535,9 +21535,9 @@ printf "%s\n" "yes" >&6; } printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h + BINASCII_CFLAGS="-DNO_ZLIB_CRC32" + BINASCII_LIBS="" - BINASCII_CFLAGS="-DNO_ZLIB_CRC32" - BINASCII_LIBS="" ;; #( *) : ZLIB_CFLAGS C compiler flags for ZLIB, overriding pkg-config From 3fe2aa56053dbca882e906c8e959039c3b188dbf Mon Sep 17 00:00:00 2001 From: stan Date: Mon, 17 Feb 2025 23:45:47 +0000 Subject: [PATCH 17/30] It was a ) --- configure | 84 +++++++++++++++++++++++++++++++++++----------------- configure.ac | 8 ++--- 2 files changed, 61 insertions(+), 31 deletions(-) diff --git a/configure b/configure index ddcdd9462db631..3e8a80f3b9ee64 100755 --- a/configure +++ b/configure @@ -1996,6 +1996,15 @@ Some influential environment variables: X11_LIBS linker flags for X11, overriding pkg-config GDBM_CFLAGS C compiler flags for gdbm GDBM_LIBS additional linker flags for gdbm + ZLIB_CFLAGS C compiler flags for ZLIB, overriding pkg-config + ZLIB_LIBS linker flags for ZLIB, overriding pkg-config + BZIP2_CFLAGS + C compiler flags for BZIP2, overriding pkg-config + BZIP2_LIBS linker flags for BZIP2, overriding pkg-config + LIBLZMA_CFLAGS + C compiler flags for LIBLZMA, overriding pkg-config + LIBLZMA_LIBS + linker flags for LIBLZMA, overriding pkg-config LIBREADLINE_CFLAGS C compiler flags for LIBREADLINE, overriding pkg-config LIBREADLINE_LIBS @@ -21445,19 +21454,34 @@ case $ac_sys_system in #( pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for zlib >= 1.2.0" >&5 -printf %s "checking for zlib >= 1.2.0... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for zlib >= 1.2.0 + printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h + + " >&5 +printf %s "checking for zlib >= 1.2.0 + printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h + + ... " >&6; } if test -n "$ZLIB_CFLAGS"; then pkg_cv_ZLIB_CFLAGS="$ZLIB_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"zlib >= 1.2.0\""; } >&5 - ($PKG_CONFIG --exists --print-errors "zlib >= 1.2.0") 2>&5 + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"zlib >= 1.2.0 + printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h + + \""; } >&5 + ($PKG_CONFIG --exists --print-errors "zlib >= 1.2.0 + printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h + + ") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_ZLIB_CFLAGS=`$PKG_CONFIG --cflags "zlib >= 1.2.0" 2>/dev/null` + pkg_cv_ZLIB_CFLAGS=`$PKG_CONFIG --cflags "zlib >= 1.2.0 + printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h + + " 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -21469,12 +21493,21 @@ if test -n "$ZLIB_LIBS"; then pkg_cv_ZLIB_LIBS="$ZLIB_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"zlib >= 1.2.0\""; } >&5 - ($PKG_CONFIG --exists --print-errors "zlib >= 1.2.0") 2>&5 + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"zlib >= 1.2.0 + printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h + + \""; } >&5 + ($PKG_CONFIG --exists --print-errors "zlib >= 1.2.0 + printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h + + ") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_ZLIB_LIBS=`$PKG_CONFIG --libs "zlib >= 1.2.0" 2>/dev/null` + pkg_cv_ZLIB_LIBS=`$PKG_CONFIG --libs "zlib >= 1.2.0 + printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h + + " 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -21495,14 +21528,23 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - ZLIB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "zlib >= 1.2.0" 2>&1` + ZLIB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "zlib >= 1.2.0 + printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h + + " 2>&1` else - ZLIB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "zlib >= 1.2.0" 2>&1` + ZLIB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "zlib >= 1.2.0 + printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h + + " 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$ZLIB_PKG_ERRORS" >&5 - as_fn_error $? "Package requirements (zlib >= 1.2.0) were not met: + as_fn_error $? "Package requirements (zlib >= 1.2.0 + printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h + + ) were not met: $ZLIB_PKG_ERRORS @@ -21533,15 +21575,11 @@ else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } - printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h - - BINASCII_CFLAGS="-DNO_ZLIB_CRC32" - BINASCII_LIBS="" - +fi + BINASCII_CFLAGS="-DNO_ZLIB_CRC32" + BINASCII_LIBS="" ;; #( *) : - ZLIB_CFLAGS C compiler flags for ZLIB, overriding pkg-config - ZLIB_LIBS linker flags for ZLIB, overriding pkg-config pkg_failed=no { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for zlib >= 1.2.0" >&5 @@ -21905,9 +21943,6 @@ fi - BZIP2_CFLAGS - C compiler flags for BZIP2, overriding pkg-config - BZIP2_LIBS linker flags for BZIP2, overriding pkg-config pkg_failed=no { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for bzip2" >&5 @@ -22156,10 +22191,6 @@ printf "%s\n" "yes" >&6; } have_bzip2=yes fi - LIBLZMA_CFLAGS - C compiler flags for LIBLZMA, overriding pkg-config - LIBLZMA_LIBS - linker flags for LIBLZMA, overriding pkg-config pkg_failed=no { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for liblzma" >&5 @@ -23651,8 +23682,7 @@ then : else case e in #( e) case " $LIBOBJS " in - *" dup2.$ac_objext "* -fi ;; + *" dup2.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS dup2.$ac_objext" ;; esac diff --git a/configure.ac b/configure.ac index 3c5b8f9f284a4f..f4cc32caec3bbf 100644 --- a/configure.ac +++ b/configure.ac @@ -5329,11 +5329,11 @@ dnl accelerators, parallelism, etc.) all support copy, lets not assume. AS_CASE([$ac_sys_system], [WASI], [ - PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [ + PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0] [ AC_DEFINE([HAVE_ZLIB_COPY], [1]) - BINASCII_CFLAGS="-DNO_ZLIB_CRC32" - BINASCII_LIBS="" - ] + ]) + BINASCII_CFLAGS="-DNO_ZLIB_CRC32" + BINASCII_LIBS="" ], [PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [ dnl zlib 1.2.0 (2003) added inflateCopy From 192f0bd30e06e88403636ac18b4076757c31e1b0 Mon Sep 17 00:00:00 2001 From: stan Date: Mon, 17 Feb 2025 23:53:27 +0000 Subject: [PATCH 18/30] Try this --- configure | 126 +-------------------------------------------------- configure.ac | 5 +- 2 files changed, 4 insertions(+), 127 deletions(-) diff --git a/configure b/configure index 3e8a80f3b9ee64..44d38336462a48 100755 --- a/configure +++ b/configure @@ -21452,130 +21452,8 @@ fi case $ac_sys_system in #( WASI) : - -pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for zlib >= 1.2.0 - printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h - - " >&5 -printf %s "checking for zlib >= 1.2.0 - printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h - - ... " >&6; } - -if test -n "$ZLIB_CFLAGS"; then - pkg_cv_ZLIB_CFLAGS="$ZLIB_CFLAGS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"zlib >= 1.2.0 - printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h - - \""; } >&5 - ($PKG_CONFIG --exists --print-errors "zlib >= 1.2.0 - printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h - - ") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_ZLIB_CFLAGS=`$PKG_CONFIG --cflags "zlib >= 1.2.0 - printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h - - " 2>/dev/null` - test "x$?" != "x0" && pkg_failed=yes -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi -if test -n "$ZLIB_LIBS"; then - pkg_cv_ZLIB_LIBS="$ZLIB_LIBS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"zlib >= 1.2.0 - printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h - - \""; } >&5 - ($PKG_CONFIG --exists --print-errors "zlib >= 1.2.0 - printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h - - ") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_ZLIB_LIBS=`$PKG_CONFIG --libs "zlib >= 1.2.0 - printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h - - " 2>/dev/null` - test "x$?" != "x0" && pkg_failed=yes -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi - - - -if test $pkg_failed = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } - -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi - if test $_pkg_short_errors_supported = yes; then - ZLIB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "zlib >= 1.2.0 - printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h - - " 2>&1` - else - ZLIB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "zlib >= 1.2.0 - printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h - - " 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$ZLIB_PKG_ERRORS" >&5 - - as_fn_error $? "Package requirements (zlib >= 1.2.0 - printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h - - ) were not met: - -$ZLIB_PKG_ERRORS - -Consider adjusting the PKG_CONFIG_PATH environment variable if you -installed software in a non-standard prefix. - -Alternatively, you may set the environment variables ZLIB_CFLAGS -and ZLIB_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details." "$LINENO" 5 -elif test $pkg_failed = untried; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} -as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it -is in your PATH or set the PKG_CONFIG environment variable to the full -path to pkg-config. - -Alternatively, you may set the environment variables ZLIB_CFLAGS -and ZLIB_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details. - -To get pkg-config, see . -See 'config.log' for more details" "$LINENO" 5; } -else - ZLIB_CFLAGS=$pkg_cv_ZLIB_CFLAGS - ZLIB_LIBS=$pkg_cv_ZLIB_LIBS - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } - -fi + ZLIB_CFLAGS=${ZLIB_CFLAGS-""} + ZLIB_LIBS=${ZLIB_LIBS-"-lz"} BINASCII_CFLAGS="-DNO_ZLIB_CRC32" BINASCII_LIBS="" ;; #( diff --git a/configure.ac b/configure.ac index f4cc32caec3bbf..42e545619e0282 100644 --- a/configure.ac +++ b/configure.ac @@ -5329,9 +5329,8 @@ dnl accelerators, parallelism, etc.) all support copy, lets not assume. AS_CASE([$ac_sys_system], [WASI], [ - PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0] [ - AC_DEFINE([HAVE_ZLIB_COPY], [1]) - ]) + ZLIB_CFLAGS=${ZLIB_CFLAGS-""} + ZLIB_LIBS=${ZLIB_LIBS-"-lz"} BINASCII_CFLAGS="-DNO_ZLIB_CRC32" BINASCII_LIBS="" ], From 8a7b1166deb10818e91dca5c57c8e9e3b5bd3c26 Mon Sep 17 00:00:00 2001 From: stan Date: Tue, 18 Feb 2025 09:01:46 +0000 Subject: [PATCH 19/30] Set up zlib flags correctly --- configure | 18 +++++++++++++++--- configure.ac | 6 ++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/configure b/configure index 44d38336462a48..450ea653ba7760 100755 --- a/configure +++ b/configure @@ -21449,12 +21449,24 @@ fi + + + + if test "$ac_sys_system" = "Emscripten" -a -z "$ZLIB_CFLAGS" -a -z "$ZLIB_LIBS" +then : + + ZLIB_CFLAGS="-sUSE_ZLIB" + ZLIB_LIBS="-sUSE_ZLIB" + +fi + + + + case $ac_sys_system in #( WASI) : - ZLIB_CFLAGS=${ZLIB_CFLAGS-""} - ZLIB_LIBS=${ZLIB_LIBS-"-lz"} - BINASCII_CFLAGS="-DNO_ZLIB_CRC32" + BINASCII_CFLAGS="-DNO_ZLIB_CRC32" BINASCII_LIBS="" ;; #( *) : diff --git a/configure.ac b/configure.ac index 42e545619e0282..3660850222c9bc 100644 --- a/configure.ac +++ b/configure.ac @@ -5327,10 +5327,12 @@ AH_TEMPLATE([HAVE_ZLIB_COPY], [Define if the zlib library has inflateCopy; zlib dnl 2022-03: Until we know if third party zlib modules people use (for hardware dnl accelerators, parallelism, etc.) all support copy, lets not assume. +dnl For Emscripten/WASI builds, set up zlib flags correctly. +PY_CHECK_EMSCRIPTEN_PORT([ZLIB], [-sUSE_ZLIB]) + AS_CASE([$ac_sys_system], [WASI], [ - ZLIB_CFLAGS=${ZLIB_CFLAGS-""} - ZLIB_LIBS=${ZLIB_LIBS-"-lz"} + dnl For WASI we use the internal CRC32. BINASCII_CFLAGS="-DNO_ZLIB_CRC32" BINASCII_LIBS="" ], From cba1f606ee8459a82aab6ea48e8c11f20c36b094 Mon Sep 17 00:00:00 2001 From: stan Date: Tue, 18 Feb 2025 09:44:20 +0000 Subject: [PATCH 20/30] Set up AS_CASE better --- configure | 205 ++++++++++----------------------------------------- configure.ac | 17 +++-- 2 files changed, 49 insertions(+), 173 deletions(-) diff --git a/configure b/configure index 450ea653ba7760..2ea13346d290ee 100755 --- a/configure +++ b/configure @@ -21450,27 +21450,6 @@ fi - - - if test "$ac_sys_system" = "Emscripten" -a -z "$ZLIB_CFLAGS" -a -z "$ZLIB_LIBS" -then : - - ZLIB_CFLAGS="-sUSE_ZLIB" - ZLIB_LIBS="-sUSE_ZLIB" - -fi - - - - -case $ac_sys_system in #( - WASI) : - - BINASCII_CFLAGS="-DNO_ZLIB_CRC32" - BINASCII_LIBS="" - ;; #( - *) : - pkg_failed=no { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for zlib >= 1.2.0" >&5 printf %s "checking for zlib >= 1.2.0... " >&6; } @@ -21529,146 +21508,53 @@ fi # Put the nasty error message in config.log where it belongs echo "$ZLIB_PKG_ERRORS" >&5 + as_fn_error $? "Package requirements (zlib >= 1.2.0) were not met: - for ac_header in zlib.h -do : - ac_fn_c_check_header_compile "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" -if test "x$ac_cv_header_zlib_h" = xyes -then : - printf "%s\n" "#define HAVE_ZLIB_H 1" >>confdefs.h - - save_CFLAGS=$CFLAGS -save_CPPFLAGS=$CPPFLAGS -save_LDFLAGS=$LDFLAGS -save_LIBS=$LIBS - - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzread in -lz" >&5 -printf %s "checking for gzread in -lz... " >&6; } -if test ${ac_cv_lib_z_gzread+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) ac_check_lib_save_LIBS=$LIBS -LIBS="-lz $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. - The 'extern "C"' is for builds by C++ compilers; - although this is not generally supported in C code supporting it here - has little cost and some practical benefit (sr 110532). */ -#ifdef __cplusplus -extern "C" -#endif -char gzread (void); -int -main (void) -{ -return gzread (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_lib_z_gzread=yes -else case e in #( - e) ac_cv_lib_z_gzread=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_gzread" >&5 -printf "%s\n" "$ac_cv_lib_z_gzread" >&6; } -if test "x$ac_cv_lib_z_gzread" = xyes -then : - - ZLIB_CFLAGS=${ZLIB_CFLAGS-""} - ZLIB_LIBS=${ZLIB_LIBS-"-lz"} - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5 -printf %s "checking for inflateCopy in -lz... " >&6; } -if test ${ac_cv_lib_z_inflateCopy+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) ac_check_lib_save_LIBS=$LIBS -LIBS="-lz $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. - The 'extern "C"' is for builds by C++ compilers; - although this is not generally supported in C code supporting it here - has little cost and some practical benefit (sr 110532). */ -#ifdef __cplusplus -extern "C" -#endif -char inflateCopy (void); -int -main (void) -{ -return inflateCopy (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_lib_z_inflateCopy=yes -else case e in #( - e) ac_cv_lib_z_inflateCopy=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_inflateCopy" >&5 -printf "%s\n" "$ac_cv_lib_z_inflateCopy" >&6; } -if test "x$ac_cv_lib_z_inflateCopy" = xyes -then : - printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h - -fi +$ZLIB_PKG_ERRORS +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. -else case e in #( - e) - as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 - ;; -esac -fi +Alternatively, you may set the environment variables ZLIB_CFLAGS +and ZLIB_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. +Alternatively, you may set the environment variables ZLIB_CFLAGS +and ZLIB_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. -CFLAGS=$save_CFLAGS -CPPFLAGS=$save_CPPFLAGS -LDFLAGS=$save_LDFLAGS -LIBS=$save_LIBS +To get pkg-config, see . +See 'config.log' for more details" "$LINENO" 5; } +else + ZLIB_CFLAGS=$pkg_cv_ZLIB_CFLAGS + ZLIB_LIBS=$pkg_cv_ZLIB_LIBS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h -else case e in #( - e) - as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 - ;; -esac -fi -done +case $ac_sys_system in #( + WASI) : -elif test $pkg_failed = untried; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } + BINASCII_CFLAGS="-DNO_ZLIB_CRC32" + BINASCII_LIBS="" + ZLIB_TEST="test 1 = 0" + ;; #( + *) : + ZLIB_TEST="test 1 = 1" + BINASCII_CFLAGS="$ZLIB_CFLAGS" + BINASCII_LIBS="$ZLIB_LIBS" for ac_header in zlib.h do : ac_fn_c_check_header_compile "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" @@ -21803,21 +21689,10 @@ esac fi done - -else - ZLIB_CFLAGS=$pkg_cv_ZLIB_CFLAGS - ZLIB_LIBS=$pkg_cv_ZLIB_LIBS - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } - - printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h - - BINASCII_CFLAGS="$ZLIB_CFLAGS" - BINASCII_LIBS="$ZLIB_LIBS" - -fi - ;; + ;; esac +] +fi @@ -32614,7 +32489,7 @@ then : if true then : - if test "$ac_sys_system" != WASI + if $ZLIB_TEST then : py_cv_module_zlib=yes else case e in #( diff --git a/configure.ac b/configure.ac index 3660850222c9bc..48aeb29397df9c 100644 --- a/configure.ac +++ b/configure.ac @@ -5327,21 +5327,23 @@ AH_TEMPLATE([HAVE_ZLIB_COPY], [Define if the zlib library has inflateCopy; zlib dnl 2022-03: Until we know if third party zlib modules people use (for hardware dnl accelerators, parallelism, etc.) all support copy, lets not assume. -dnl For Emscripten/WASI builds, set up zlib flags correctly. -PY_CHECK_EMSCRIPTEN_PORT([ZLIB], [-sUSE_ZLIB]) +PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [ + dnl zlib 1.2.0 (2003) added inflateCopy + AC_DEFINE([HAVE_ZLIB_COPY], [1]) +] AS_CASE([$ac_sys_system], [WASI], [ dnl For WASI we use the internal CRC32. BINASCII_CFLAGS="-DNO_ZLIB_CRC32" BINASCII_LIBS="" + ZLIB_TEST="[test 1 = 0]" ], - [PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [ - dnl zlib 1.2.0 (2003) added inflateCopy - AC_DEFINE([HAVE_ZLIB_COPY], [1]) + [ + ZLIB_TEST="[test 1 = 1]" BINASCII_CFLAGS="$ZLIB_CFLAGS" BINASCII_LIBS="$ZLIB_LIBS" - ], [ + AC_CHECK_HEADERS([zlib.h], [ WITH_SAVE_ENV([ AC_CHECK_LIB([z], [gzread], [ @@ -7944,8 +7946,7 @@ PY_STDLIB_MOD([_uuid], [$LIBUUID_CFLAGS], [$LIBUUID_LIBS]) dnl compression libs -PY_STDLIB_MOD([zlib], [], [test "$ac_sys_system" != WASI], - [$ZLIB_CFLAGS], [$ZLIB_LIBS]) +PY_STDLIB_MOD([zlib], [], [$ZLIB_TEST], [$ZLIB_CFLAGS], [$ZLIB_LIBS]) dnl binascii uses zlib for optimized crc32. PY_STDLIB_MOD_SIMPLE([binascii], [$BINASCII_CFLAGS], [$BINASCII_LIBS]) PY_STDLIB_MOD([_bz2], [], [test "$have_bzip2" = yes], From 126d65106cf10720173e600d5b7bed1e5888f522 Mon Sep 17 00:00:00 2001 From: stan Date: Tue, 18 Feb 2025 09:45:57 +0000 Subject: [PATCH 21/30] Push configure too --- configure | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 2ea13346d290ee..089c6340cada64 100755 --- a/configure +++ b/configure @@ -21539,7 +21539,7 @@ else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } - printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h + printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h @@ -21555,6 +21555,7 @@ case $ac_sys_system in #( ZLIB_TEST="test 1 = 1" BINASCII_CFLAGS="$ZLIB_CFLAGS" BINASCII_LIBS="$ZLIB_LIBS" + for ac_header in zlib.h do : ac_fn_c_check_header_compile "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" From f1371fe1d7dc71a976f23772f978a811924d3374 Mon Sep 17 00:00:00 2001 From: stan Date: Tue, 18 Feb 2025 09:55:36 +0000 Subject: [PATCH 22/30] empty flags --- configure | 49 +++++++++++++++++-------------------------------- configure.ac | 28 +++++++++++++++------------- 2 files changed, 32 insertions(+), 45 deletions(-) diff --git a/configure b/configure index 089c6340cada64..81956f20b25ee5 100755 --- a/configure +++ b/configure @@ -21448,6 +21448,16 @@ printf "%s\n" "#define HAVE_LCHFLAGS 1" >>confdefs.h fi +case $ac_sys_system in #( + WASI) : + + ZLIB_CFLAGS="" + ZLIB_LIBS="" + BINASCII_CFLAGS="-DNO_ZLIB_CRC32" + BINASCII_LIBS="" + ZLIB_TEST="test 1 = 0" + ;; #( + *) : pkg_failed=no @@ -21508,49 +21518,25 @@ fi # Put the nasty error message in config.log where it belongs echo "$ZLIB_PKG_ERRORS" >&5 - as_fn_error $? "Package requirements (zlib >= 1.2.0) were not met: - -$ZLIB_PKG_ERRORS -Consider adjusting the PKG_CONFIG_PATH environment variable if you -installed software in a non-standard prefix. + as_fn_error $? "zlib >= 1.2.0 not found via pkg-config. Install zlib-devel." "$LINENO" 5 -Alternatively, you may set the environment variables ZLIB_CFLAGS -and ZLIB_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;} -as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it -is in your PATH or set the PKG_CONFIG environment variable to the full -path to pkg-config. -Alternatively, you may set the environment variables ZLIB_CFLAGS -and ZLIB_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details. + as_fn_error $? "zlib >= 1.2.0 not found via pkg-config. Install zlib-devel." "$LINENO" 5 -To get pkg-config, see . -See 'config.log' for more details" "$LINENO" 5; } else ZLIB_CFLAGS=$pkg_cv_ZLIB_CFLAGS ZLIB_LIBS=$pkg_cv_ZLIB_LIBS { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } - printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h - + printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h -case $ac_sys_system in #( - WASI) : - - BINASCII_CFLAGS="-DNO_ZLIB_CRC32" - BINASCII_LIBS="" - ZLIB_TEST="test 1 = 0" - ;; #( - *) : +fi ZLIB_TEST="test 1 = 1" BINASCII_CFLAGS="$ZLIB_CFLAGS" @@ -21684,16 +21670,15 @@ LIBS=$save_LIBS else case e in #( e) - as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 + as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 ;; esac fi done - ;; + + ;; esac -] -fi diff --git a/configure.ac b/configure.ac index 48aeb29397df9c..500fa59604d76c 100644 --- a/configure.ac +++ b/configure.ac @@ -5321,25 +5321,27 @@ if test "$ac_cv_have_lchflags" = yes ; then AC_DEFINE([HAVE_LCHFLAGS], [1], [Define to 1 if you have the 'lchflags' function.]) fi - dnl Check for compression libraries AH_TEMPLATE([HAVE_ZLIB_COPY], [Define if the zlib library has inflateCopy; zlib 1.2.0 (2003) added inflateCopy.]) dnl 2022-03: Until we know if third party zlib modules people use (for hardware dnl accelerators, parallelism, etc.) all support copy, lets not assume. -PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [ - dnl zlib 1.2.0 (2003) added inflateCopy - AC_DEFINE([HAVE_ZLIB_COPY], [1]) -] - AS_CASE([$ac_sys_system], [WASI], [ - dnl For WASI we use the internal CRC32. - BINASCII_CFLAGS="-DNO_ZLIB_CRC32" - BINASCII_LIBS="" - ZLIB_TEST="[test 1 = 0]" - ], + dnl Skip pkg-config check for zlib on WASI + ZLIB_CFLAGS="" + ZLIB_LIBS="" + BINASCII_CFLAGS="-DNO_ZLIB_CRC32" + BINASCII_LIBS="" + ZLIB_TEST="[test 1 = 0]" + ], [ + PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [ + AC_DEFINE([HAVE_ZLIB_COPY], [1]) + ], [ + AC_MSG_ERROR([zlib >= 1.2.0 not found via pkg-config. Install zlib-devel.]) + ]) + ZLIB_TEST="[test 1 = 1]" BINASCII_CFLAGS="$ZLIB_CFLAGS" BINASCII_LIBS="$ZLIB_LIBS" @@ -5363,8 +5365,8 @@ AS_CASE([$ac_sys_system], zlib1g-dev equivalent library or get it from https://zlib.net/. ])]) ]) - ]) -]) + ] +) dnl detect bzip2 from Emscripten emport PY_CHECK_EMSCRIPTEN_PORT([BZIP2], [-sUSE_BZIP2]) From d6ecbe2f216d8f40bed2512aea997fa020cad004 Mon Sep 17 00:00:00 2001 From: stan Date: Tue, 18 Feb 2025 10:01:02 +0000 Subject: [PATCH 23/30] push configure changes --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 81956f20b25ee5..06b96f72d11a5d 100755 --- a/configure +++ b/configure @@ -21670,7 +21670,7 @@ LIBS=$save_LIBS else case e in #( e) - as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 + as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 ;; esac fi From b024f1d30f6fc65c6388395043841b2a9a13511b Mon Sep 17 00:00:00 2001 From: stan Date: Tue, 18 Feb 2025 20:40:16 +0000 Subject: [PATCH 24/30] Retry from scratch --- configure | 243 +++++++++++++++++++++++++++++++++++++++++---------- configure.ac | 66 +++++++------- 2 files changed, 229 insertions(+), 80 deletions(-) diff --git a/configure b/configure index 06b96f72d11a5d..99c33cee559816 100755 --- a/configure +++ b/configure @@ -21448,16 +21448,6 @@ printf "%s\n" "#define HAVE_LCHFLAGS 1" >>confdefs.h fi -case $ac_sys_system in #( - WASI) : - - ZLIB_CFLAGS="" - ZLIB_LIBS="" - BINASCII_CFLAGS="-DNO_ZLIB_CRC32" - BINASCII_LIBS="" - ZLIB_TEST="test 1 = 0" - ;; #( - *) : pkg_failed=no @@ -21519,43 +21509,170 @@ fi echo "$ZLIB_PKG_ERRORS" >&5 - as_fn_error $? "zlib >= 1.2.0 not found via pkg-config. Install zlib-devel." "$LINENO" 5 + save_CFLAGS=$CFLAGS +save_CPPFLAGS=$CPPFLAGS +save_LDFLAGS=$LDFLAGS +save_LIBS=$LIBS -elif test $pkg_failed = untried; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } - as_fn_error $? "zlib >= 1.2.0 not found via pkg-config. Install zlib-devel." "$LINENO" 5 + CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS" + LIBS="$LIBS $ZLIB_LIBS" + for ac_header in zlib.h +do : + ac_fn_c_check_header_compile "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" +if test "x$ac_cv_header_zlib_h" = xyes +then : + printf "%s\n" "#define HAVE_ZLIB_H 1" >>confdefs.h -else - ZLIB_CFLAGS=$pkg_cv_ZLIB_CFLAGS - ZLIB_LIBS=$pkg_cv_ZLIB_LIBS - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } + py_check_lib_save_LIBS=$LIBS +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzread in -lz" >&5 +printf %s "checking for gzread in -lz... " >&6; } +if test ${ac_cv_lib_z_gzread+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-lz $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ - printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char gzread (void); +int +main (void) +{ +return gzread (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_z_gzread=yes +else case e in #( + e) ac_cv_lib_z_gzread=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_gzread" >&5 +printf "%s\n" "$ac_cv_lib_z_gzread" >&6; } +if test "x$ac_cv_lib_z_gzread" = xyes +then : + have_zlib=yes +else case e in #( + e) have_zlib=no ;; +esac +fi + +LIBS=$py_check_lib_save_LIBS +else case e in #( + e) have_zlib=no ;; +esac fi - ZLIB_TEST="test 1 = 1" - BINASCII_CFLAGS="$ZLIB_CFLAGS" - BINASCII_LIBS="$ZLIB_LIBS" +done + if test "x$have_zlib" = xyes +then : - for ac_header in zlib.h -do : - ac_fn_c_check_header_compile "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" -if test "x$ac_cv_header_zlib_h" = xyes + ZLIB_CFLAGS=${ZLIB_CFLAGS-""} + ZLIB_LIBS=${ZLIB_LIBS-"-lz"} + py_check_lib_save_LIBS=$LIBS +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5 +printf %s "checking for inflateCopy in -lz... " >&6; } +if test ${ac_cv_lib_z_inflateCopy+y} then : - printf "%s\n" "#define HAVE_ZLIB_H 1" >>confdefs.h + printf %s "(cached) " >&6 +else case e in #( + e) ac_check_lib_save_LIBS=$LIBS +LIBS="-lz $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ - save_CFLAGS=$CFLAGS +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. + The 'extern "C"' is for builds by C++ compilers; + although this is not generally supported in C code supporting it here + has little cost and some practical benefit (sr 110532). */ +#ifdef __cplusplus +extern "C" +#endif +char inflateCopy (void); +int +main (void) +{ +return inflateCopy (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + ac_cv_lib_z_inflateCopy=yes +else case e in #( + e) ac_cv_lib_z_inflateCopy=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_inflateCopy" >&5 +printf "%s\n" "$ac_cv_lib_z_inflateCopy" >&6; } +if test "x$ac_cv_lib_z_inflateCopy" = xyes +then : + printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h + +fi + +LIBS=$py_check_lib_save_LIBS + + +fi + +CFLAGS=$save_CFLAGS +CPPFLAGS=$save_CPPFLAGS +LDFLAGS=$save_LDFLAGS +LIBS=$save_LIBS + + + +elif test $pkg_failed = untried; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + + save_CFLAGS=$CFLAGS save_CPPFLAGS=$CPPFLAGS save_LDFLAGS=$LDFLAGS save_LIBS=$LIBS - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzread in -lz" >&5 + CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS" + LIBS="$LIBS $ZLIB_LIBS" + for ac_header in zlib.h +do : + ac_fn_c_check_header_compile "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" +if test "x$ac_cv_header_zlib_h" = xyes +then : + printf "%s\n" "#define HAVE_ZLIB_H 1" >>confdefs.h + + py_check_lib_save_LIBS=$LIBS +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzread in -lz" >&5 printf %s "checking for gzread in -lz... " >&6; } if test ${ac_cv_lib_z_gzread+y} then : @@ -21599,11 +21716,29 @@ fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_gzread" >&5 printf "%s\n" "$ac_cv_lib_z_gzread" >&6; } if test "x$ac_cv_lib_z_gzread" = xyes +then : + have_zlib=yes +else case e in #( + e) have_zlib=no ;; +esac +fi + +LIBS=$py_check_lib_save_LIBS + + +else case e in #( + e) have_zlib=no ;; +esac +fi + +done + if test "x$have_zlib" = xyes then : - ZLIB_CFLAGS=${ZLIB_CFLAGS-""} - ZLIB_LIBS=${ZLIB_LIBS-"-lz"} - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5 + ZLIB_CFLAGS=${ZLIB_CFLAGS-""} + ZLIB_LIBS=${ZLIB_LIBS-"-lz"} + py_check_lib_save_LIBS=$LIBS +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5 printf %s "checking for inflateCopy in -lz... " >&6; } if test ${ac_cv_lib_z_inflateCopy+y} then : @@ -21652,14 +21787,10 @@ then : fi +LIBS=$py_check_lib_save_LIBS -else case e in #( - e) - as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 - ;; -esac -fi +fi CFLAGS=$save_CFLAGS CPPFLAGS=$save_CPPFLAGS @@ -21668,15 +21799,38 @@ LIBS=$save_LIBS +else + ZLIB_CFLAGS=$pkg_cv_ZLIB_CFLAGS + ZLIB_LIBS=$pkg_cv_ZLIB_LIBS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + + have_zlib=yes + printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h + + +fi +case $host_os in #( + WASI) : + + BINASCII_CFLAGS="-DNO_USE_ZLIB" + BINASCII_LIBS="" + ;; #( + *) : + + if test "x$have_zlib" = xyes +then : + + BINASCII_CFLAGS="$ZLIB_CFLAGS" + BINASCII_LIBS="$ZLIB_LIBS" + else case e in #( e) - as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 + as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 ;; esac fi -done - ;; esac @@ -32475,7 +32629,7 @@ then : if true then : - if $ZLIB_TEST + if test "$have_zlib" = yes then : py_cv_module_zlib=yes else case e in #( @@ -34987,4 +35141,3 @@ if test "$ac_cv_header_stdatomic_h" != "yes"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Your compiler or platform does have a working C11 stdatomic.h. A future version of Python may require stdatomic.h." >&5 printf "%s\n" "$as_me: Your compiler or platform does have a working C11 stdatomic.h. A future version of Python may require stdatomic.h." >&6;} fi - diff --git a/configure.ac b/configure.ac index 500fa59604d76c..f413a181d0182d 100644 --- a/configure.ac +++ b/configure.ac @@ -5321,46 +5321,41 @@ if test "$ac_cv_have_lchflags" = yes ; then AC_DEFINE([HAVE_LCHFLAGS], [1], [Define to 1 if you have the 'lchflags' function.]) fi + dnl Check for compression libraries AH_TEMPLATE([HAVE_ZLIB_COPY], [Define if the zlib library has inflateCopy; zlib 1.2.0 (2003) added inflateCopy.]) -dnl 2022-03: Until we know if third party zlib modules people use (for hardware -dnl accelerators, parallelism, etc.) all support copy, lets not assume. -AS_CASE([$ac_sys_system], +PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], +[ + have_zlib=yes + AC_DEFINE([HAVE_ZLIB_COPY], [1]) +], +[ + WITH_SAVE_ENV([ + CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS" + LIBS="$LIBS $ZLIB_LIBS" + AC_CHECK_HEADERS([zlib.h], [ + PY_CHECK_LIB([z], [gzread], [have_zlib=yes], [have_zlib=no]) + ], [have_zlib=no]) + AS_VAR_IF([have_zlib], [yes], [ + ZLIB_CFLAGS=${ZLIB_CFLAGS-""} + ZLIB_LIBS=${ZLIB_LIBS-"-lz"} + PY_CHECK_LIB([z], [inflateCopy], [AC_DEFINE([HAVE_ZLIB_COPY], [1])]) + ]) + ]) +]) +AS_CASE([$host_os], [WASI], [ - dnl Skip pkg-config check for zlib on WASI - ZLIB_CFLAGS="" - ZLIB_LIBS="" - BINASCII_CFLAGS="-DNO_ZLIB_CRC32" + dnl WASI: Do not use zlib for binascii + BINASCII_CFLAGS="-DNO_USE_ZLIB" BINASCII_LIBS="" - ZLIB_TEST="[test 1 = 0]" ], [ - PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [ - AC_DEFINE([HAVE_ZLIB_COPY], [1]) + AS_VAR_IF([have_zlib], [yes], [ + BINASCII_CFLAGS="$ZLIB_CFLAGS" + BINASCII_LIBS="$ZLIB_LIBS" ], [ - AC_MSG_ERROR([zlib >= 1.2.0 not found via pkg-config. Install zlib-devel.]) - ]) - - ZLIB_TEST="[test 1 = 1]" - BINASCII_CFLAGS="$ZLIB_CFLAGS" - BINASCII_LIBS="$ZLIB_LIBS" - - AC_CHECK_HEADERS([zlib.h], [ - WITH_SAVE_ENV([ - AC_CHECK_LIB([z], [gzread], [ - ZLIB_CFLAGS=${ZLIB_CFLAGS-""} - ZLIB_LIBS=${ZLIB_LIBS-"-lz"} - AC_CHECK_LIB([z], [inflateCopy], [AC_DEFINE([HAVE_ZLIB_COPY], [1])]) - ], [ - AC_MSG_ERROR([m4_normalize([ - zlib.h and libz are required. Install your OS's zlib-devel or - zlib1g-dev equivalent library or get it from https://zlib.net/. - ])]) - ]) - ]) - ], [ - AC_MSG_ERROR([m4_normalize([ + AC_MSG_ERROR([m4_normalize([ zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/. ])]) @@ -7948,8 +7943,9 @@ PY_STDLIB_MOD([_uuid], [$LIBUUID_CFLAGS], [$LIBUUID_LIBS]) dnl compression libs -PY_STDLIB_MOD([zlib], [], [$ZLIB_TEST], [$ZLIB_CFLAGS], [$ZLIB_LIBS]) -dnl binascii uses zlib for optimized crc32. +PY_STDLIB_MOD([zlib], [], [test "$have_zlib" = yes], + [$ZLIB_CFLAGS], [$ZLIB_LIBS]) +dnl binascii can use zlib for optimized crc32. PY_STDLIB_MOD_SIMPLE([binascii], [$BINASCII_CFLAGS], [$BINASCII_LIBS]) PY_STDLIB_MOD([_bz2], [], [test "$have_bzip2" = yes], [$BZIP2_CFLAGS], [$BZIP2_LIBS]) @@ -8044,4 +8040,4 @@ if test "$ac_cv_header_stdatomic_h" != "yes"; then Your compiler or platform does have a working C11 stdatomic.h. A future version of Python may require stdatomic.h. ])) -fi +fi \ No newline at end of file From 3f5de2437fc4f96feed1671edd82a21cd6920599 Mon Sep 17 00:00:00 2001 From: stan Date: Tue, 18 Feb 2025 20:50:14 +0000 Subject: [PATCH 25/30] Fix case --- configure | 3 +-- configure.ac | 9 +++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/configure b/configure index 99c33cee559816..6f8ec4249c962e 100755 --- a/configure +++ b/configure @@ -21808,9 +21808,8 @@ printf "%s\n" "yes" >&6; } have_zlib=yes printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h - fi -case $host_os in #( +case $ac_sys_system in #( WASI) : BINASCII_CFLAGS="-DNO_USE_ZLIB" diff --git a/configure.ac b/configure.ac index f413a181d0182d..3df4b3e7c2cd78 100644 --- a/configure.ac +++ b/configure.ac @@ -5325,12 +5325,9 @@ fi dnl Check for compression libraries AH_TEMPLATE([HAVE_ZLIB_COPY], [Define if the zlib library has inflateCopy; zlib 1.2.0 (2003) added inflateCopy.]) -PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], -[ +PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [ have_zlib=yes - AC_DEFINE([HAVE_ZLIB_COPY], [1]) -], -[ + AC_DEFINE([HAVE_ZLIB_COPY], [1])], [ WITH_SAVE_ENV([ CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS" LIBS="$LIBS $ZLIB_LIBS" @@ -5344,7 +5341,7 @@ PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], ]) ]) ]) -AS_CASE([$host_os], +AS_CASE([$ac_sys_system], [WASI], [ dnl WASI: Do not use zlib for binascii BINASCII_CFLAGS="-DNO_USE_ZLIB" From a8b03137966727a33c17387f2848e91ec7264ae2 Mon Sep 17 00:00:00 2001 From: stan Date: Tue, 18 Feb 2025 21:00:32 +0000 Subject: [PATCH 26/30] Fix typo --- configure | 2 +- configure.ac | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 6f8ec4249c962e..767737d110455b 100755 --- a/configure +++ b/configure @@ -21812,7 +21812,7 @@ fi case $ac_sys_system in #( WASI) : - BINASCII_CFLAGS="-DNO_USE_ZLIB" + BINASCII_CFLAGS="-DNO_ZLIB_CRC32" BINASCII_LIBS="" ;; #( *) : diff --git a/configure.ac b/configure.ac index 3df4b3e7c2cd78..d57b3b3d991e13 100644 --- a/configure.ac +++ b/configure.ac @@ -5344,10 +5344,9 @@ PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [ AS_CASE([$ac_sys_system], [WASI], [ dnl WASI: Do not use zlib for binascii - BINASCII_CFLAGS="-DNO_USE_ZLIB" + BINASCII_CFLAGS="-DNO_ZLIB_CRC32" BINASCII_LIBS="" - ], - [ + ], [ AS_VAR_IF([have_zlib], [yes], [ BINASCII_CFLAGS="$ZLIB_CFLAGS" BINASCII_LIBS="$ZLIB_LIBS" From f74b9819d1f0eaf372bf5d94f27e92dd4e992ca0 Mon Sep 17 00:00:00 2001 From: stan Date: Tue, 18 Feb 2025 21:09:49 +0000 Subject: [PATCH 27/30] Try being explicit --- configure | 1 + configure.ac | 1 + 2 files changed, 2 insertions(+) diff --git a/configure b/configure index 767737d110455b..52aa71110eec92 100755 --- a/configure +++ b/configure @@ -21814,6 +21814,7 @@ case $ac_sys_system in #( BINASCII_CFLAGS="-DNO_ZLIB_CRC32" BINASCII_LIBS="" + have_zlib=no ;; #( *) : diff --git a/configure.ac b/configure.ac index d57b3b3d991e13..4746633e44fa28 100644 --- a/configure.ac +++ b/configure.ac @@ -5346,6 +5346,7 @@ AS_CASE([$ac_sys_system], dnl WASI: Do not use zlib for binascii BINASCII_CFLAGS="-DNO_ZLIB_CRC32" BINASCII_LIBS="" + have_zlib=no ], [ AS_VAR_IF([have_zlib], [yes], [ BINASCII_CFLAGS="$ZLIB_CFLAGS" From 76f5dcdc0f1d0dc2b4822cd5fe38dff546ecb90e Mon Sep 17 00:00:00 2001 From: stan Date: Tue, 18 Feb 2025 21:39:53 +0000 Subject: [PATCH 28/30] Try if statements --- configure | 36 +++++++++++++++++++++++------------- configure.ac | 29 ++++++++++++++++------------- 2 files changed, 39 insertions(+), 26 deletions(-) diff --git a/configure b/configure index 52aa71110eec92..a9e1fd59f9dda8 100755 --- a/configure +++ b/configure @@ -21450,6 +21450,20 @@ fi + + + if test "$ac_sys_system" = "Emscripten" -a -z "$ZLIB_CFLAGS" -a -z "$ZLIB_LIBS" +then : + + ZLIB_CFLAGS="-sUSE_ZLIB" + ZLIB_LIBS="-sUSE_ZLIB" + +fi + + + + + pkg_failed=no { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for zlib >= 1.2.0" >&5 printf %s "checking for zlib >= 1.2.0... " >&6; } @@ -21808,31 +21822,27 @@ printf "%s\n" "yes" >&6; } have_zlib=yes printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h + fi case $ac_sys_system in #( WASI) : - BINASCII_CFLAGS="-DNO_ZLIB_CRC32" + BINASCII_CFLAGS="-DNO_ZLIB_CRC32" BINASCII_LIBS="" - have_zlib=no ;; #( *) : - if test "x$have_zlib" = xyes -then : - - BINASCII_CFLAGS="$ZLIB_CFLAGS" - BINASCII_LIBS="$ZLIB_LIBS" + if test "$have_zlib" != "yes"; then + as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 + fi + BINASCII_CFLAGS="$ZLIB_CFLAGS" + BINASCII_LIBS="$ZLIB_LIBS" -else case e in #( - e) - as_fn_error $? "zlib.h and libz are required. Install your OS's zlib-devel or zlib1g-dev equivalent library or get it from https://zlib.net/." "$LINENO" 5 + ;; #( + *) : ;; esac -fi - ;; -esac diff --git a/configure.ac b/configure.ac index 4746633e44fa28..1e5a44b80b2ae9 100644 --- a/configure.ac +++ b/configure.ac @@ -5325,9 +5325,13 @@ fi dnl Check for compression libraries AH_TEMPLATE([HAVE_ZLIB_COPY], [Define if the zlib library has inflateCopy; zlib 1.2.0 (2003) added inflateCopy.]) +dnl detect zlib from Emscripten emport +PY_CHECK_EMSCRIPTEN_PORT([ZLIB], [-sUSE_ZLIB]) + PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [ have_zlib=yes - AC_DEFINE([HAVE_ZLIB_COPY], [1])], [ + AC_DEFINE([HAVE_ZLIB_COPY], [1]) +], [ WITH_SAVE_ENV([ CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS" LIBS="$LIBS $ZLIB_LIBS" @@ -5343,23 +5347,22 @@ PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [ ]) AS_CASE([$ac_sys_system], [WASI], [ - dnl WASI: Do not use zlib for binascii BINASCII_CFLAGS="-DNO_ZLIB_CRC32" BINASCII_LIBS="" - have_zlib=no - ], [ - AS_VAR_IF([have_zlib], [yes], [ - BINASCII_CFLAGS="$ZLIB_CFLAGS" - BINASCII_LIBS="$ZLIB_LIBS" - ], [ - AC_MSG_ERROR([m4_normalize([ - zlib.h and libz are required. Install your OS's zlib-devel or - zlib1g-dev equivalent library or get it from https://zlib.net/. - ])]) - ]) + ], + [*], [ + if test "$have_zlib" != "yes"; then + AC_MSG_ERROR([m4_normalize([ + zlib.h and libz are required. Install your OS's zlib-devel or + zlib1g-dev equivalent library or get it from https://zlib.net/. + ])]) + fi + BINASCII_CFLAGS="$ZLIB_CFLAGS" + BINASCII_LIBS="$ZLIB_LIBS" ] ) + dnl detect bzip2 from Emscripten emport PY_CHECK_EMSCRIPTEN_PORT([BZIP2], [-sUSE_BZIP2]) From 3c37b06842dffb9f83319cd5fc9cbd373783208a Mon Sep 17 00:00:00 2001 From: stan Date: Tue, 18 Feb 2025 21:55:17 +0000 Subject: [PATCH 29/30] Try be even more explicit --- configure | 1 + configure.ac | 1 + 2 files changed, 2 insertions(+) diff --git a/configure b/configure index a9e1fd59f9dda8..484877356369ac 100755 --- a/configure +++ b/configure @@ -21829,6 +21829,7 @@ case $ac_sys_system in #( BINASCII_CFLAGS="-DNO_ZLIB_CRC32" BINASCII_LIBS="" + have_zlib=no ;; #( *) : diff --git a/configure.ac b/configure.ac index 1e5a44b80b2ae9..2b0ef9f26cdee2 100644 --- a/configure.ac +++ b/configure.ac @@ -5349,6 +5349,7 @@ AS_CASE([$ac_sys_system], [WASI], [ BINASCII_CFLAGS="-DNO_ZLIB_CRC32" BINASCII_LIBS="" + have_zlib=no ], [*], [ if test "$have_zlib" != "yes"; then From 8e368c61ca478ca2e4ffc1fdd0795bbbd7a99822 Mon Sep 17 00:00:00 2001 From: stan Date: Wed, 19 Feb 2025 10:07:28 +0000 Subject: [PATCH 30/30] Modify setups --- Modules/Setup.bootstrap.in | 2 +- Modules/Setup.stdlib.in | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/Setup.bootstrap.in b/Modules/Setup.bootstrap.in index 772adcaa6b1f86..95ea16dcf5c806 100644 --- a/Modules/Setup.bootstrap.in +++ b/Modules/Setup.bootstrap.in @@ -26,7 +26,7 @@ time timemodule.c _typing _typingmodule.c _weakref _weakref.c # used by shutil -zlib zlibmodule.c +#zlib zlibmodule.c # commonly used core modules _abc _abc.c diff --git a/Modules/Setup.stdlib.in b/Modules/Setup.stdlib.in index 99c309475fca6d..a331e18f0617f8 100644 --- a/Modules/Setup.stdlib.in +++ b/Modules/Setup.stdlib.in @@ -66,6 +66,7 @@ @MODULE_BINASCII_TRUE@binascii binascii.c @MODULE__BZ2_TRUE@_bz2 _bz2module.c @MODULE__LZMA_TRUE@_lzma _lzmamodule.c +@MODULE_ZLIB_TRUE@zlib zlibmodule.c # dbm/gdbm # dbm needs either libndbm, libgdbm_compat, or libdb 5.x