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

Add support for macOS Universal dylib cross-compilation #65

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

preland
Copy link

@preland preland commented Jul 25, 2024

This PR introduces a series of bash scripts and modified CMakeLists.txt files that allows for a universal MacOS dylib (libmonero-cpp.dylib) to be cross-compiled.

This has only been tested on Debian 12, with all the dependencies required to build monero-project and monero-cpp installed. There might've been some other system-side changes introduced in order to get it to build properly, I am currently unsure.

The build.sh located in macos_universal (directory name pending), if ran nominally, will complete the build from beginning to end, without the need to run any other scripts beforehand. (ie you can just clone the repo, navigate to the directory, and run the script).

This also has the side effect of creating statically built libmonero-cpp dylibs for the individual macOS platforms. These can be found in macos_universal/{arm||x86}/build. The universal binary is placed in macos_universal/universal/build.

This PR is related to this issue, though it should be noted that the universal dylib itself likely won't be used; rather, the individual static libmonero-cpp dylibs will be used to create their java equivalents. These will then be combined in a similar manner to libmonero-cpp.

(Quick P.S: I'll squash commits once the PR is closer to finalization)

@woodser
Copy link
Owner

woodser commented Aug 9, 2024

I'm not able to build successfully from macOS for some reason:

woodser@woodsers-MBP-2 macos_universal % ./build.sh 
Submodule path 'external/monero-project': checked out '81d4db08eb75ce5392c65ca6571e7b08e41b7c95'
Submodule path 'external/monero-project/external/miniupnp': checked out '544e6fcc73c5ad9af48a8985c94f0f1d742ef2e0'
Submodule path 'external/monero-project/external/randomx': checked out '102f8acf90a7649ada410de5499a7ec62e49e1da'
Submodule path 'external/monero-project/external/rapidjson': checked out '129d19ba7f496df5e33658527a7158c79b99c21c'
Submodule path 'external/monero-project/external/rapidjson/thirdparty/gtest': checked out '0a439623f75c029912728d80cb7f1b8b48739ca4'
Submodule path 'external/monero-project/external/supercop': checked out '633500ad8c8759995049ccd022107d1fa8a1bbc9'
Submodule path 'external/monero-project/external/trezor-common': checked out 'bff7fdfe436c727982cc553bdfb29a9021b423b0'
Submodule path 'external/monero-project/external/trezor-common/defs/ethereum/tokens': checked out '88414ef852e21279f217d2f3f8fd439cd7c5fd9f'
Switched to branch 'master'
From https://github.com/monero-project/monero
 * branch                master     -> FETCH_HEAD
fatal: Not possible to fast-forward, aborting.
ls: .git/config: Not a directory
cd contrib/depends && /Applications/Xcode.app/Contents/Developer/usr/bin/make HOST=x86_64-apple-darwin11 && cd ../.. && mkdir -p build/x86_64-apple-darwin11/release
Configuring boost...
Building Boost.Build engine with toolset darwin... 
Failed to build Boost.Build build engine
Consult 'bootstrap.log' for more details
make[1]: *** [/Users/woodser/git/monero-java/external/monero-cpp/external/monero-project/contrib/depends/work/build/x86_64-apple-darwin11/boost/1_64_0-f8953e197b4/./.stamp_configured] Error 1
make: *** [depends] Error 2
ls: .git/config: Not a directory
cd contrib/depends && /Applications/Xcode.app/Contents/Developer/usr/bin/make HOST=aarch64-apple-darwin11 && cd ../.. && mkdir -p build/aarch64-apple-darwin11/release
Configuring boost...
Building Boost.Build engine with toolset darwin... 
Failed to build Boost.Build build engine
Consult 'bootstrap.log' for more details
make[1]: *** [/Users/woodser/git/monero-java/external/monero-cpp/external/monero-project/contrib/depends/work/build/aarch64-apple-darwin11/boost/1_64_0-f8953e197b4/./.stamp_configured] Error 1
make: *** [depends] Error 2
./clean.sh: line 2: cd: build: No such file or directory
./clean.sh: line 2: cd: build: No such file or directory
./combine.sh: line 2: cd: build: No such file or directory
woodser@woodsers-MBP-2 macos_universal % 

I assume it should work from macOS and not just from Debian?

Then I can continue reviewing, but just preliminary feedback:

  • Scripts should be in ./bin/ for consistency.
  • Wondering if we can avoid duplicating so much from CMakeLists.txt with only minor modifications (the code duplication flags are going off in my mind).
  • Then we can clean up instructions.

@preland
Copy link
Author

preland commented Aug 9, 2024

Looks like a boost error; not surprising to me unfortunately

I can begin work on integrating the changes more cohesively; I only did it the way I did because I had to keep making large changes to the pipeline to address issues

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

Successfully merging this pull request may close these issues.

2 participants