apotocki / boost-iosx

Builds Boost C++ libraries and packages them as XCFrameworks for iOS (simulator and device), visionOS (simulator and device), macOS, and Mac Catalyst (Intel & Apple Silicon M1).
Boost Software License 1.0
59 stars 17 forks source link

how to add manual flags (eg. `-std=gnu++98 -stdlib=libc++ -fembed-bitcode`) #15

Open mesqueeb opened 2 months ago

mesqueeb commented 2 months ago

Hello! I need to add these manual flags to the boost build script to make my cpp code compatible. -std=gnu++98 -stdlib=libc++ -fembed-bitcode How to best add these ?

mesqueeb commented 2 months ago

Could you kindly check for me if these changes to the build script are correct in your eyes? https://github.com/mesqueeb/boost-iosx/pull/1/files

I feel like I did something wrong though because the build script stops midway with

iosx/product/frameworks/icudata.xcframework/macos-arm64/libicudata.a: No such file or directory

and re-trying gives the same

empidornis@Empidornis ~/g/g/m/F/boost (FuegoOnAppleSilicon)> ./scripts/build.sh
~/ghq/github.com/mesqueeb/FuegoOnAppleSilicon/boost/boost ~/ghq/github.com/mesqueeb/FuegoOnAppleSilicon/boost
patching boost...
patching file 'tools/build/src/tools/gcc.jam'
patching file 'tools/build/src/tools/features/instruction-set-feature.jam'
patching file 'tools/build/src/build/configure.jam'
cp: /Users/empidornis/ghq/github.com/mesqueeb/FuegoOnAppleSilicon/boost/scripts/Pods/icu4c-iosx/product/frameworks/icudata.xcframework/macos-arm64/libicudata.a: No such file or directory
mesqueeb commented 2 months ago

After browsing through the other issues, I

  1. recloned my fork
  2. deleted the folder at ~/Library/Caches/CocoaPods/Pods/Release/icu4c-iosx
  3. tried ./scripts/boost.sh again, but same issue:
Integrating target `icu4c-iosx`
    Adding Build Phase '[CP] Copy XCFrameworks' to project.
  - Generating deterministic UUIDs
  - Stabilizing target UUIDs
  - Running post install hooks
  - Writing Xcode project file to `Pods/Pods.xcodeproj`
  Cleaning up sandbox directory

Integrating client project

[!] Please close any current Xcode sessions and use `ICUdep.xcworkspace` for this project from now on.

Integrating target `Pods-ICUdep` (`ICUdep.xcodeproj` project)
  Adding Build Phase '[CP] Check Pods Manifest.lock' to project.
  - Running post integrate hooks
  - Writing Lockfile in `Podfile.lock`
  - Writing Manifest in `Pods/Manifest.lock`
  CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only performed in repo update

-> Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.

[!] The Podfile contains command line tool target(s) (ICUdep) which are attempting to integrate dynamic frameworks or libraries.
This may not behave as expected, because command line tools are usually distributed as a single binary and cannot contain their own dynamic dependencies.
~/ghq/github.com/mesqueeb/FuegoOnAppleSilicon/boost
~/ghq/github.com/mesqueeb/FuegoOnAppleSilicon/boost/boost ~/ghq/github.com/mesqueeb/FuegoOnAppleSilicon/boost
patching boost...
patching file 'tools/build/src/tools/gcc.jam'
patching file 'tools/build/src/tools/features/instruction-set-feature.jam'
patching file 'tools/build/src/build/configure.jam'
cp: /Users/empidornis/ghq/github.com/mesqueeb/FuegoOnAppleSilicon/boost/scripts/Pods/icu4c-iosx/product/frameworks/icudata.xcframework/macos-arm64/libicudata.a: No such file or directory

So I think it might really have something to do with my changes of the build script here...? 🤔

apotocki commented 2 months ago

I really doubt that you need these flags. -std=gnu++98 I think most boost libraries will not even compile with this. -stdlib=libc++ On systems where libc++ is the default library used, such as MacOS and FreeBSD, this flag is not needed. -fembed-bitcode It's already included for device builds and -fembed-bitcode-marker for all simulators.

mesqueeb commented 2 months ago

@apotocki thank you for your help. I realised my fork works when executing ./scripts/build.sh directly in the fork clone.

But when installing it as a git-submodule in another repo, for whatever reason it fails. Even if I first do cd ./boost and do it from there. 🤔 Is there anything that could cause this?

-std=gnu++98 is required for some cpp code to compile. I am basing the build settings on those here: https://github.com/herzbube/fuego-on-ios/blob/fuego-on-ios/boost/boost.sh

I tried with all other standard libraries, but only -std=gnu++98 will work with the cpp code I'm trying to build.

The issue with that version is that it won't compile to visionOS :sob:

apotocki commented 2 months ago

I have no idea why you can't run the build from the submodule. These are completely unrelated things. The 98 standard is absolutely obsolete these days. You're better off fixing your C++ code than trying to build modern libraries with gnu++98 and link them.

mesqueeb commented 2 months ago

@apotocki thanks. While I was able to get boost 1.75.0 to build with my fork that sets it to gnu++98, I still can't compile the Fuego c++ code.

I wonder, is there a way if boost was correctly compiled and is actually using gnu++98?

You're better off fixing your C++ code than trying to build modern libraries with gnu++98 and link them.

You're absolutely right :P But I don't know C++ and Fuego is an 11 y.o. unmaintained library... 🤦🏻 Do you wanna help modernise it? : P do you freelance? Add me on Discord! ;)

apotocki commented 2 months ago

I've sent e-mail

mesqueeb commented 2 months ago

I've sent e-mail

I didn't receive it 😲

apotocki commented 2 months ago

I sent it to luca@cycraft.co

apotocki commented 2 months ago

Oh, sorry. I just found your email in my spam folder. :) I'll resend my letter to that email.