Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate symbols from apple_static_xcframework #2430

Open
vakhidbetrakhmadov opened this issue Mar 17, 2024 · 0 comments
Open

Duplicate symbols from apple_static_xcframework #2430

vakhidbetrakhmadov opened this issue Mar 17, 2024 · 0 comments

Comments

@vakhidbetrakhmadov
Copy link
Contributor

vakhidbetrakhmadov commented Mar 17, 2024

Hi ✋

I am trying to build a static xcframework for external distribution.

I have the following dependency tree:

apple_static_xcframework (FooSDK) -> 
swift_library (Foo) ->
apple_static_framework_import (Zip - prebuilt static Swift library) -> 
apple_static_framework_import (Minizip - prebuilt static C library)

I am facing an issue that symbols from Zip and Minizip are duplicated in the final binary of the product xcframework.

I can see in the build logs that both Zip and Minizip are passed twice in the libtool invocation:

SUBCOMMAND: # //:FooSDK [action 'Linking FooSDK-arm64-apple-ios13.0-fl.a', configuration: 3b270167ad09e1b14e1cecd3ecac79b255a5a5eb6162dc1c3e64c83ef54484da, execution platform: @local_config_platform//:host]
(cd /private/var/tmp/_bazel_vakhid.betrakhmadov/1ef088b48d7b9d0d70d1dfde8f0aabef/execroot/__main__ && \
  exec env - \
    APPLE_SDK_PLATFORM=iPhoneOS \
    APPLE_SDK_VERSION_OVERRIDE=17.2 \
    PATH=<...>
    XCODE_VERSION_OVERRIDE=15.2.0.15C500b \
    ZERO_AR_DATE=1 \
  external/local_config_cc/libtool \
  -D \
  -no_warning_for_no_symbols \
  -static \
  -arch_only arm64 \
  -syslibroot __BAZEL_XCODE_SDKROOT__ \
  -o bazel-out/darwin_arm64-fastbuild/bin/FooSDK-arm64-apple-ios13.0-fl.a \
  bazel-out/ios-arm64-min13.0-applebin_ios-ios_arm64-fastbuild-ST-5a3d504b05e8/bin/libFoo.a \
  Minizip.xcframework/ios-arm64/Minizip.framework/Minizip \
  Zip.xcframework/ios-arm64/Zip.framework/Zip \
  Minizip.xcframework/ios-arm64/Minizip.framework/Minizip \
  Zip.xcframework/ios-arm64/Zip.framework/Zip)
# Configuration: 3b270167ad09e1b14e1cecd3ecac79b255a5a5eb6162dc1c3e64c83ef54484da
# Execution platform: @local_config_platform//:host
INFO: From Linking FooSDK-arm64-apple-ios13.0-fl.a:
/Applications/Xcode-15.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: warning renaming duplicate member name 'Minizip-dummy.o' from '/var/folders/vg/008npg05001_zj7sn4p3m08h0000gq/T//libtool.USDk3Nmf/Minizip_975577f5767cce772c4b949d8b4cef2f.o(Minizip-dummy.o)' and '/var/folders/vg/008npg05001_zj7sn4p3m08h0000gq/T//libtool.USDk3Nmf/Minizip_975577f5767cce772c4b949d8b4cef2f.o(Minizip-dummy.o)'
/Applications/Xcode-15.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: warning renaming duplicate member name 'Minizip_vers.o' from '/var/folders/vg/008npg05001_zj7sn4p3m08h0000gq/T//libtool.USDk3Nmf/Minizip_975577f5767cce772c4b949d8b4cef2f.o(Minizip_vers.o)' and '/var/folders/vg/008npg05001_zj7sn4p3m08h0000gq/T//libtool.USDk3Nmf/Minizip_975577f5767cce772c4b949d8b4cef2f.o(Minizip_vers.o)'
/Applications/Xcode-15.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: warning renaming duplicate member name 'QuickZip.o' from '/var/folders/vg/008npg05001_zj7sn4p3m08h0000gq/T//libtool.USDk3Nmf/Zip_1fe1076498a57ae78089c33f29f146d5.o(QuickZip.o)' and '/var/folders/vg/008npg05001_zj7sn4p3m08h0000gq/T//libtool.USDk3Nmf/Zip_1fe1076498a57ae78089c33f29f146d5.o(QuickZip.o)'
/Applications/Xcode-15.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: warning renaming duplicate member name 'Zip-dummy.o' from '/var/folders/vg/008npg05001_zj7sn4p3m08h0000gq/T//libtool.USDk3Nmf/Zip_1fe1076498a57ae78089c33f29f146d5.o(Zip-dummy.o)' and '/var/folders/vg/008npg05001_zj7sn4p3m08h0000gq/T//libtool.USDk3Nmf/Zip_1fe1076498a57ae78089c33f29f146d5.o(Zip-dummy.o)'
/Applications/Xcode-15.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: warning renaming duplicate member name 'Zip.o' from '/var/folders/vg/008npg05001_zj7sn4p3m08h0000gq/T//libtool.USDk3Nmf/Zip_1fe1076498a57ae78089c33f29f146d5.o(Zip.o)' and '/var/folders/vg/008npg05001_zj7sn4p3m08h0000gq/T//libtool.USDk3Nmf/Zip_1fe1076498a57ae78089c33f29f146d5.o(Zip.o)'
/Applications/Xcode-15.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: warning renaming duplicate member name 'ZipUtilities.o' from '/var/folders/vg/008npg05001_zj7sn4p3m08h0000gq/T//libtool.USDk3Nmf/Zip_1fe1076498a57ae78089c33f29f146d5.o(ZipUtilities.o)' and '/var/folders/vg/008npg05001_zj7sn4p3m08h0000gq/T//libtool.USDk3Nmf/Zip_1fe1076498a57ae78089c33f29f146d5.o(ZipUtilities.o)'
/Applications/Xcode-15.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: warning renaming duplicate member name 'Zip_vers.o' from '/var/folders/vg/008npg05001_zj7sn4p3m08h0000gq/T//libtool.USDk3Nmf/Zip_1fe1076498a57ae78089c33f29f146d5.o(Zip_vers.o)' and '/var/folders/vg/008npg05001_zj7sn4p3m08h0000gq/T//libtool.USDk3Nmf/Zip_1fe1076498a57ae78089c33f29f146d5.o(Zip_vers.o)'
/Applications/Xcode-15.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: warning renaming duplicate member name 'ioapi.o' from '/var/folders/vg/008npg05001_zj7sn4p3m08h0000gq/T//libtool.USDk3Nmf/Minizip_975577f5767cce772c4b949d8b4cef2f.o(ioapi.o)' and '/var/folders/vg/008npg05001_zj7sn4p3m08h0000gq/T//libtool.USDk3Nmf/Minizip_975577f5767cce772c4b949d8b4cef2f.o(ioapi.o)'
/Applications/Xcode-15.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: warning renaming duplicate member name 'unzip.o' from '/var/folders/vg/008npg05001_zj7sn4p3m08h0000gq/T//libtool.USDk3Nmf/Minizip_975577f5767cce772c4b949d8b4cef2f.o(unzip.o)' and '/var/folders/vg/008npg05001_zj7sn4p3m08h0000gq/T//libtool.USDk3Nmf/Minizip_975577f5767cce772c4b949d8b4cef2f.o(unzip.o)'
/Applications/Xcode-15.2.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: warning renaming duplicate member name 'zip.o' from '/var/folders/vg/008npg05001_zj7sn4p3m08h0000gq/T//libtool.USDk3Nmf/Minizip_975577f5767cce772c4b949d8b4cef2f.o(zip.o)' and '/var/folders/vg/008npg05001_zj7sn4p3m08h0000gq/T//libtool.USDk3Nmf/Minizip_975577f5767cce772c4b949d8b4cef2f.o(zip.o)'

I am also able to validate that symbols are indeed duplicated by running nm on the final binary.

I have prepared a minimum repro example matching the dependency tree described above: repro_example.zip

You can run bazelisk build :FooSDK and check build logs and the final binary to also validate the issue.

I also found an old issue - bazelbuild/bazel#11223 - and an old PR - bazelbuild/bazel#11225 - in bazel repo that seem to be closely related.

I've tried to debug, but so far i was not able to pin point the problem and find a solution.

Could you please take a look at this 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant