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

Fix cross-compilation on macOS x86_64 CPUs with target CPU arm64 #823

Merged
merged 1 commit into from
Feb 29, 2024

Conversation

shpala
Copy link
Contributor

@shpala shpala commented Jan 27, 2024

Fix cross-compilation on macOS x86_64 CPUs with target CPU arm64 by manually setting CMAKE_SYSTEM_PROCESSOR to the cross-compilation target whenever CMAKE_SYSTEM_PROCESSOR doesn't match CMAKE_OSX_ARCHITECTURES after project() call. This is probably a Cmake bug that happens on macOS. (#822).

The issue happens when SpeeDB is built using the follwoing command:
cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_PROCESSOR=arm64 ..
The build itself succeeds, but because Cmake wrongly sets CMAKE_SYSTEM_PROCESSOR to x86_64 instead of arm64 and causes crc32c_arm64.cc not to be compiled.
This in turn makes the project fails any linking with SpeeDB:

Undefined symbols for architecture arm64:
"crc32c_arm64(unsigned int, unsigned char const*, unsigned long)", referenced from:
speedb::crc32c::ExtendARMImpl(unsigned int, char const*, unsigned long) in libspeedb.a(crc32c.cc.o)

@ofriedma ofriedma self-requested a review January 28, 2024 11:19
@ofriedma ofriedma added the bug fix Fixes a known bug label Jan 28, 2024
CMakeLists.txt Outdated Show resolved Hide resolved
@CLAassistant
Copy link

CLAassistant commented Feb 1, 2024

CLA assistant check
All committers have signed the CLA.

@jhult
Copy link

jhult commented Feb 18, 2024

@shpala, any updates on this? I think there are just 2 small changes required (and the CLA).

@shpala shpala force-pushed the pavel/fix_macos_cross_compilation branch 2 times, most recently from 06974ca to cf7440e Compare February 23, 2024 11:33
@shpala
Copy link
Contributor Author

shpala commented Feb 23, 2024

Done.
Though there's a git error on the build server.
The reason this happened is that I've rebased my branch over latest origin/main in order to be in sync with the current branch and I've force pushed my commit as if it was a new commit in a new branch.
You need to run "git fetch --all" in order to build successfully.

@ofriedma @jhult do you want me to close this PR and reopen with the same changes?

@shpala shpala force-pushed the pavel/fix_macos_cross_compilation branch 2 times, most recently from d1ef98a to d656890 Compare February 23, 2024 13:49
by manually setting CMAKE_SYSTEM_PROCESSOR to the cross-compilation target
whenever CMAKE_SYSTEM_PROCESSOR doesn't match CMAKE_OSX_ARCHITECTURES after project() call.
This is probably a Cmake bug that happens on macOS.
(speedb-io#822)
@shpala shpala force-pushed the pavel/fix_macos_cross_compilation branch from d656890 to b18fd45 Compare February 28, 2024 11:36
@ofriedma
Copy link
Contributor

Compilation succeed for linux arm

@ofriedma ofriedma merged commit 154b89b into speedb-io:main Feb 29, 2024
18 of 19 checks passed
@ofriedma
Copy link
Contributor

@shpala Merged, Thank you for your contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fix Fixes a known bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants