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

[bug] Apple flags are not sent to other build systems (bitcode, arc, visibility) #12197

Open
paulocoutinhox opened this issue Sep 25, 2022 · 3 comments · May be fixed by #15027
Open

[bug] Apple flags are not sent to other build systems (bitcode, arc, visibility) #12197

paulocoutinhox opened this issue Sep 25, 2022 · 3 comments · May be fixed by #15027
Assignees

Comments

@paulocoutinhox
Copy link
Contributor

Hi,

With the new feature of enabling bitcode, arc and visibility, we can see that only dependencies built with Xcode will receive the flags:

d383bb2

But recipes like openssl and others that don't will be built with this, will be compiled without the bitcode, for example.

The result is an error when link:

ld: '/Users/paulo/.conan/data/openssl/1.1.1q/_/_/package/801ae4682e3f478afa7107aea3a8a4cf47aa78a5/lib/libcrypto.a(digest.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Environment Details (include every applicable attribute)

  • Operating System+version: macos latest
  • Compiler+version: clang 13
  • Conan version: 1.52
  • Python version: 3.9

Steps to reproduce (Include if Applicable)

Logs (Executed commands with output) (Include/Attach if Applicable)

Configuration (profile_host):
[settings]
arch=armv8
arch_build=armv8
build_type=Debug
compiler=apple-clang
compiler.libcxx=libc++
compiler.version=14
os=iOS
os.sdk=iphoneos
os.version=11.0
os_build=Macos
[options]
nativium_arch=arm64
nativium_build_type=debug
nativium_group=ios
nativium_product_name=Nativium
nativium_project_name=nativium
nativium_target=ios
nativium_version=1.0.0
nativium_version_code=1
[build_requires]
[env]
[conf]
tools.apple:enable_bitcode=True
tools.apple:enable_arc=True

Configuration (profile_build):
[settings]
arch=armv8
arch_build=armv8
build_type=Release
compiler=apple-clang
compiler.libcxx=libc++
compiler.version=14
os=Macos
os_build=Macos
[options]
[build_requires]
[env]
@paulocoutinhox
Copy link
Contributor Author

One test case.

With my toolchain, the openssl receive the correct params:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang  -I. -Iinclude -fPIC -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.0.sdk -fno-common -g -fPIC -mios-version-min=11.0 -arch arm64 -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.0.sdk -fembed-bitcode-marker -fno-objc-arc -fvisibility=hidden -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.0.sdk -fembed-bitcode-marker -fno-objc-arc -fvisibility=hidden -fPIC -DOPENSSL_PIC -DOPENSSLDIR="\"/Users/paulo/.conan/data/openssl/1.1.1q/_/_/package/801ae4682e3f478afa7107aea3a8a4cf47aa78a5/res\"" -DENGINESDIR="\"/Users/paulo/.conan/data/openssl/1.1.1q/_/_/package/801ae4682e3f478afa7107aea3a8a4cf47aa78a5/lib/engines-1.1\"" -D_REENTRANT -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.0.sdk -fembed-bitcode-marker -fno-objc-arc -fvisibility=hidden -MMD -MF apps/app_rand.d.tmp -MT apps/app_rand.o -c -o apps/app_rand.o apps/app_rand.c

The param exists about bitcode: -fembed-bitcode-marker.

When i use conan bitcode configuration:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang  -I. -Iinclude -fPIC -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.0.sdk -fno-common -g -fPIC -mios-version-min=11.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.0.sdk -arch arm64 -g -O0 -fPIC -DOPENSSL_PIC -DOPENSSLDIR="\"/Users/paulo/.conan/data/openssl/1.1.1q/_/_/package/801ae4682e3f478afa7107aea3a8a4cf47aa78a5/res\"" -DENGINESDIR="\"/Users/paulo/.conan/data/openssl/1.1.1q/_/_/package/801ae4682e3f478afa7107aea3a8a4cf47aa78a5/lib/engines-1.1\"" -D_REENTRANT  -MMD -MF apps/app_rand.d.tmp -MT apps/app_rand.o -c -o apps/app_rand.o apps/app_rand.c

The param DON'T exists about bitcode: -fembed-bitcode-marker.

@memsharded
Copy link
Member

Yes, it is true that tools.apple:enable_bitcode is only applied by CMakeToolchain atm. It should be extended to other build systems, prioritizing Autotools.

But there is a problem with this, some particular packages, like openssl, will not use such integrations, so they would need to explicitly encode it in the recipes. There is no easy way to pass special configuration or flags to the openssl build system, everything needs to be done in-recipe. What is your toolchain? How do you manage to pass it to the openssl build?

@SpaceIm
Copy link
Contributor

SpaceIm commented Nov 10, 2022

One question: Was is it a good idea to provide this conf? I mean it could have been something left to users profiles through tools.build.cflags.
Specifically tools.apple:enable_visibility is non-sense since it's absolutely not specific to apple. Moreover it's usually forced in shared libs, and when it's not forced it means that lib doesn't support visibility hidden in shared lib.
So because proper behavior of these flags can't be guaranteed regardless of shared option value & what underlying build system is doing to export symbols, I think it would have been better handled by advanced users through generic tools.build.cflags.

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

Successfully merging a pull request may close this issue.

3 participants