Conan: How to detect compiler flag changes?

Created on 6 Feb 2018  路  13Comments  路  Source: conan-io/conan

Hello,

I'm using Conan 1.0.4.

I've built a lot of dependencies with my darwin-toolchain as a build_requirement.

I had to add Bitcode support, so I've added the corresponding compiler flags -fembed-bitcode.

However, that had no impact on the package ID, and running conan install still installed the non-Bitcode binaries.

I thought about adding an option to my darwin-toolchain, but since this is a build_requirement it would have been discarded as soon as binary packages would have been created.

Is there a good way to prevent this issue? Apart from adding the option in every recipe I got?

Should the package ID depend on other things? Having a Gentoo-like flag handling might not be appropriate for Conan.

I did not dig a lot on that, but that seems like a tough problem!

EDIT: In this specific case, maybe bitcode should become a conan setting, it is specific to iOS (maybe watchOS and tvOS as well) but from my understanding it's becoming widely used by iOS apps.

To help us debug your issue please explain:

  • [x] I've read the CONTRIBUTING guide.
  • [x] I've specified the Conan version, operating system version and any tool that can be relevant.
  • [x] I've explained the steps to reproduce the error or the motivation/use case of the question/suggestion.
high medium queue feature look into

All 13 comments

Honestly, I have no idea about that bitcode but yes, sound like a subsetting of the Apple platforms where it exists. If any of you could investigate if it applies to all Apple platforms would be nice!

On this page, by looking at the Bitcode section:

For iOS apps, bitcode is the default, but optional. For watchOS and tvOS apps, bitcode is required. If you provide bitcode, all apps and frameworks in the app bundle (all targets in the project) need to include bitcode.

It does not seem to apply to macOS.

So, if for iOS apps is by default but optional:

I had to add Bitcode support, so I've added the corresponding compiler flags -fembed-bitcode.

Why did you need to add it?

For watchOS and tvOS it is required, so we can assume that the flag is currently set in all the generated packages, right? probably we don't need to add the subsetting in these platforms because it is not optional.

Not really, it is set by Xcode for iOS/watchOS/tvOS apps, but I have C++ dependencies that I compile beforehand.

And those were not compiled with Bitcode support (i.e. the apple-clang compiler does not set them by default)

There's two compiler flags I had to add:

  • -fembed-bitcode in Release mode
  • -fembed-bitcode-marker in Debug mode

In the end, the CI slave was still getting the old non-bitcode packages, so I removed every iOS package from our server and rebuilt everything.

Thanks, I get it.

Do you know if using directly the apple-clang you can target a tvOS or watchOS without using the flag? or it fails?

Running:

clang++ --sysroot `xcrun -sdk appletvos --show-sdk-path` main.cpp -lSystem -lc++ -arch arm64 -mappletvos-version-min=9.0

and the same command with the addition of -fembed-bitcode-marker gives the same output.

However, passing -fembed-bitcode (the release flag) yields a different output.

I've also tried to compile for macOS (i.e. clang++ main.cpp) with and without the -fembed-bitcode-marker flag, same thing...

I think the flag has to be set manually when compiling C/C++ packages.

It seems the -fembed-bitcode-marker only places an empty bitcode at the end of the binary.

See this SO post for more detail.

I wonder how it is useful in any way then...

Absolutely, it is very relevant to decide if we introduce a new sub setting, where and with which default value. Many thanks

In the end, my real issue was because of Xcode (not setting the poorly documented BITCODE_GENERATION_MODE xcodebuild flag), but I'm glad this issue was not for nothing.
The bitcode support would be a great addition :)

Hi @lasote and @danimtb,

Any plans for it can be used on conan without toolchain repository from @theodelrieu?

Thanks.

Hi @prsolucoes!

It is still not very clear for me that Conan should introduce a setting for that flag or just modify the build helpers to inject that flag when str(self.settings.os) in ['iOS', 'watchOS', 'tvOS']. But modifying the build helpers would be a breaking change so we cannot introduce it right now.

I think the best option could be using a profile for building for the Apple devices, with env vars CFLAGS and CXXFLAGS adjusting these flags.
I think adjusting that flag is more a "build system" responsibility than Conan responsibility, but sometimes the line is not clear.

Hi,

Forgot, i create my own toolchain:
https://github.com/ezored/conan-darwin-toolchain

We are using in our products without problems.

I put:

  • bitcode
  • arc
  • visibility

Thanks.

Was this page helpful?
0 / 5 - 0 ratings