Skip to content

zlib name clashes since #1142 #1176

Closed
Closed
@G4Vi

Description

@G4Vi

Since #1142

Perl includes vendored zlib in Compress-Raw-Zlib and attempts build and link it in. In attempt to avoid name clashes, Compress-Raw-Zlib applies Z_PREFIX Perl_crz_, but unfortunately some symbols fall through the cracks, see below.

For APPerl it's easy enough for me to patch Perl's Compress-Raw-Zlib to use cosmo's zlib as Compress-Raw-Zlib allows building the Perl module with existing zlib or from source. However, I'd prefer if we reverted 5488f0b as I think there's likely other existing software that doesn't expect zlib to already be linked in. Either way, to save space, I'm going to set Compress-Raw-Zlib to use cosmo's zlib, but namespacing the symbols probably allows more software to build out of the box. The only downside I'm seeing is that naive cosmocc builds may include multiple versions of zlib, which can occur anyways if they have their own properly namespaced zlib. Are there any examples of existing software that uses zlib that is dependent on zlib using non-namespaced symbol names (so it couldn't be configured to use cosmo's namespaced zlib)?

cc @ahgamut

with Perl 5.36 included Compress-Raw-Zlib

home/sample/repos/cosmopolitan/cosmocc/bin/../libexec/gcc/x86_64-linux-cosmo/12.3.0/ld.bfd: /home/sample/repos/cosmopolitan/cosmocc/bin/../x86_64-linux-cosmo/lib/libcosmo.a(zutil.o):/home/sample/repos/cosmopolitan/third_party/zlib/zutil.c:18: multiple definition of `z_errmsg'; lib/auto/Compress/Raw/Zlib/Zlib.a(zutil.o):(.rodata+0x0): first defined here
/home/sample/repos/cosmopolitan/cosmocc/bin/../libexec/gcc/x86_64-linux-cosmo/12.3.0/ld.bfd: /home/sample/repos/cosmopolitan/cosmocc/bin/../x86_64-linux-cosmo/lib/libcosmo.a(crc32.o): in function `crc32_combine_gen64':
/home/sample/repos/cosmopolitan/third_party/zlib/crc32.c:1212: multiple definition of `crc32_combine_gen64'; lib/auto/Compress/Raw/Zlib/Zlib.a(crc32.o):crc32.c:(.text+0x1e3): first defined here
/home/sample/repos/cosmopolitan/cosmocc/bin/../libexec/gcc/x86_64-linux-cosmo/12.3.0/ld.bfd: /home/sample/repos/cosmopolitan/cosmocc/bin/../x86_64-linux-cosmo/lib/libcosmo.a(crc32.o): in function `crc32_combine_gen':
/home/sample/repos/cosmopolitan/third_party/zlib/crc32.c:1220: multiple definition of `crc32_combine_gen'; lib/auto/Compress/Raw/Zlib/Zlib.a(crc32.o):crc32.c:(.text+0x1e8): first defined here
/home/sample/repos/cosmopolitan/cosmocc/bin/../libexec/gcc/x86_64-linux-cosmo/12.3.0/ld.bfd: /home/sample/repos/cosmopolitan/cosmocc/bin/../x86_64-linux-cosmo/lib/libcosmo.a(crc32.o): in function `crc32_combine_op':
/home/sample/repos/cosmopolitan/third_party/zlib/crc32.c:1231: multiple definition of `crc32_combine_op'; lib/auto/Compress/Raw/Zlib/Zlib.a(crc32.o):crc32.c:(.text+0x1ea): first defined here

with Compress-Raw-Zlib-2.212 released April 2024:

/home/sample/repos/cosmopolitan/cosmocc/bin/../libexec/gcc/x86_64-linux-cosmo/12.3.0/ld.bfd: /home/sample/repos/cosmopolitan/cosmocc/bin/../x86_64-linux-cosmo/lib/libcosmo.a(zutil.o):/home/sample/repos/cosmopolitan/third_party/zlib/zutil.c:18: multiple definition of `z_errmsg'; lib/auto/Compress/Raw/Zlib/Zlib.a(zutil.o):(.rodata+0x0): first defined here

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions