Skip to content

[Bug] libpulsarwithdeps.a misses some symbols on Linux or macOS #512

Closed

Description

@BewareMyPower

Search before asking

  • I searched in the issues and found nothing similar.

Version

https://dist.apache.org/repos/dist/dev/pulsar/pulsar-client-cpp/pulsar-client-cpp-3.8.0-candidate-2/

Minimal reproduce step

Download the macos-arm64.zip and follow the guide here to verify it.

What did you expect to see?

The application run successfully

What did you see instead?

% clang++ main.cc ./lib/libpulsarwithdeps.a -std=c++11 -I./include
Undefined symbols for architecture arm64:
  "_bitset_resize", referenced from:
      _roaring_bitmap_to_bitset in libpulsarwithdeps.a[1287](roaring.c.o)
      _roaring_bitmap_to_bitset in libpulsarwithdeps.a[1287](roaring.c.o)
ld: symbol(s) not found for architecture arm64

Anything else?

This should be caused by the static library of roaring is not included in the *.a file.

This dependency was introduced since #497, so it's a regression

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Activity

  1. added this to the 3.8.0 milestone on Oct 16, 2025
  2. changed the title [-][Bug] libpulsarwithdeps.a on macOS misses some symbols[/-] [+][Bug] libpulsarwithdeps.a misses some symbols[/+] on Oct 16, 2025
  3. BewareMyPower commented on Oct 16, 2025

    @BewareMyPower
    ContributorAuthor

    The debian package also misses the symbol.

    # g++ main.cc  -std=c++11 /usr/lib/libpulsarwithdeps.a
    /usr/bin/ld: /usr/lib/libpulsarwithdeps.a(roaring.c.o): in function `roaring_bitmap_to_bitset':
    roaring.c:(.text+0xe79c): undefined reference to `bitset_resize'
    collect2: error: ld returned 1 exit status
    

    The root cause is we use ar -x to uncompress static libraries to object files (*.o). However, libroaring has duplicated bitset.c.o. For example, on my macOS laptop,

    % ar t vcpkg/packages/roaring_arm64-osx/lib/libroaring.a
    __.SYMDEF SORTED
    isadetection.c.o
    array_util.c.o
    bitset_util.c.o
    art.c.o
    bitset.c.o
    array.c.o
    bitset.c.o

    After ar -x, only one bitset.c.o is retained, which means the other one is lost

  4. changed the title [-][Bug] libpulsarwithdeps.a misses some symbols[/-] [+][Bug] libpulsarwithdeps.a misses some symbols on Linux or macOS[/+] on Oct 16, 2025
  5. BewareMyPower commented on Oct 16, 2025

    @BewareMyPower
    ContributorAuthor

    The workaround is not to use ar -x to extract *.a files to *.o files. For example, on macOS, the following trick works:

    diff --git a/build-support/merge_archives.sh b/build-support/merge_archives.sh
    index 065130d..d7e3c53 100755
    --- a/build-support/merge_archives.sh
    +++ b/build-support/merge_archives.sh
    @@ -20,6 +20,7 @@
    
     set -e
    
    +ROOT="$pwd/.."
     MERGED_LIBRARY=$1
     shift
     ITEMS=$*
    @@ -44,7 +45,9 @@ for ITEM in $ITEMS; do
         LIBS="$LIBS $LIB_NAME/*.o"
         cd ..
     done
    +LIBS="$LIBS $ROOT/vcpkg/buildtrees/roaring/arm64-osx-dbg/src/CMakeFiles/roaring.dir/bitset.c.o"
    
    +set -x
     ar -qc $MERGED_LIBRARY $LIBS

    P.S. Change dbg to rel in release.

    However, it's a bit complicated that we need to write a new script to scan object files (*.o) from dependencies directly under the vcpkg/buildtrees directory. In addition, the build on Windows is different that I don't have time to verify if the Windows library has the same issue.

    A quick fix is to remove the libroaring dependency and use an alternative for Roaring64Map from libroaring for now. /cc @shibd

  6. removed this from the 3.8.0 milestone on Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions