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

Release build for mac will enable bitcode #1261

Open
shiena opened this issue Sep 16, 2024 · 4 comments
Open

Release build for mac will enable bitcode #1261

shiena opened this issue Sep 16, 2024 · 4 comments

Comments

@shiena
Copy link

shiena commented Sep 16, 2024

In Release/Distribution builds for macOS/iOS/visionOS, INTERPROCEDURAL_OPTIMIZATION is ON so bitcode is enabled.
I would like to see bitcode disabled by default as it has been deprecated since Xcode14.
Also, there are cases where bitcode is required for older models, so I think it would be better to be able to enable it as an option.

Probably related to the following issue and pull req.
#418
#357

@mihe
Copy link
Contributor

mihe commented Sep 16, 2024

What errors/warnings are you seeing exactly?

Distributing (and thus building for) bitcode is indeed deprecated, and while LTO/IPO in LLVM does similarly emit LLVM bitcode into the object files in order to optimize across them, I see no mention of LTO in AppleClang being deprecated along with it, and frankly I have a hard time seeing that being the case.

@shiena
Copy link
Author

shiena commented Sep 16, 2024

INTERPROCEDURAL_OPTIMIZATION causes the -flto=thin option to the compiler and generates an object file with bitcode output.
This causes an Unknown header: 0xb17c0de error when creating the xcframework from the .a file.
If INTERPROCEDURAL_OPTIMIZATION is turned off, bitcode is not output.

@mihe
Copy link
Contributor

mihe commented Sep 17, 2024

I assume then that you're not generating/building your Xcode project with CMake (and referencing the Jolt CMake target as part of that) but instead manually bundling the statically linked XCFramework?

If that's the case, I suppose there is some argument for disabling LTO by default when targeting Apple platforms, since there's the possibility of the static libraries being bundled into an XCFramework bundle. It could also be conditionally disabled only when PROJECT_IS_TOP_LEVEL is true and BUILD_SHARED_LIBS is false, in order to cater to FetchContent and shared libraries, but I'm not sure it's worth the hassle.

Frankly I'm not seeing much of a difference at all in PerformanceTest on my M2 Mac Mini with or without LTO, for reasons I can't quite understand, so that would seem to make this decision a lot simpler. I don't have an x86 Mac to test with anymore though, but those are quickly becoming irrelevant anyway I guess.

@jrouwe
Copy link
Owner

jrouwe commented Sep 28, 2024

I'm not really sure what to do with this. The way I read the release notes from Apple is that they remove bitcode from apps uploaded to the store. The reasoning seems to be that the binary format of bitcode changes too often, meaning it cannot be reliable used to recompile the same code for different architectures. Besides they got rid of all other architectures anyway, so they don't need it anymore.

The LTO flags haven't been removed, and can still be useful when you want to get more optimized code in case you link the static library into your code. In the case of an xcframework, they're probably not desired as they potentially break with every new clang release.

Since it is really easy to turn LTO off for an xcframework (set the project setting ``INTERPROCEDURAL_OPTIMIZATION` to off) and FetchContent compiles and links the static library every build, the breaking format changes are not an issue. So I'm tempted to leave things as they are (possibly adding some extra information to the build docs on what to do if you receive the error).

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

3 participants