Skip to content

COMP: Forward CMAKE_APPLE_SILICON_PROCESSOR#2409

Merged
thewtex merged 1 commit intoInsightSoftwareConsortium:masterfrom
issakomi:m1
Mar 18, 2021
Merged

COMP: Forward CMAKE_APPLE_SILICON_PROCESSOR#2409
thewtex merged 1 commit intoInsightSoftwareConsortium:masterfrom
issakomi:m1

Conversation

@issakomi
Copy link
Copy Markdown
Member

@issakomi issakomi commented Mar 15, 2021

Forward CMAKE_APPLE_SILICON_PROCESSOR variable to external cmake configuration commands (Eigen3 and FFTW).
This fixes configuration for x86_64 on Apple Silicon, if CMAKE_APPLE_SILICON_PROCESSOR variable was set by user (value should be x86_64 or arm64).

Theoretically, for cross-compile setups, specially on other architectures, more variables should be forwarded, IMHO, but Eigen3 is header library, this is required only to pass correct architecture to "try compile" cmake's tests, AFAIK. And internal FFTW build is marked as non-production experimental build, so probably it is OK. Note: i didn't test FFTW build on Apple Silicon, but i think it is straightforward.

Let me know if you think CMAKE_OSX_ARCHITECTURES or other variables should be added too, so temporary set WIP.

S. comments to #2391

CC @seanm

Edit:
have tried "internal" FFTW builds (both variants, float and double) with CMAKE_APPLE_SILICON_PROCESSOR x86_64 on Apple Silicon, they are OK.

This variable exists in Cmake >= 3.19.2, BTW.

@dzenanz dzenanz requested a review from phcerdan March 16, 2021 00:27
Copy link
Copy Markdown
Member

@thewtex thewtex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @issakomi !

@issakomi issakomi changed the title WIP: COMP: Forward CMAKE_APPLE_SILICON_PROCESSOR COMP: Forward CMAKE_APPLE_SILICON_PROCESSOR Mar 16, 2021
@seanm
Copy link
Copy Markdown
Contributor

seanm commented Mar 16, 2021

Not sure I get the point of the existence of CMAKE_APPLE_SILICON_PROCESSOR, but it exists, so passing it down the line seems fine.

@issakomi
Copy link
Copy Markdown
Member Author

issakomi commented Mar 17, 2021

Not sure I get the point of the existence of CMAKE_APPLE_SILICON_PROCESSOR, but it exists, so passing it down the line seems fine.

Here https://cmake.org/cmake/help/v3.19/release/3.19.html is some information:

Apple Silicon is now supported (since CMake 3.19.2):

3.19.2

  • Apple Silicon host architecture selection support was updated. CMake 3.19.0 and 3.19.1 always chose arm64 as the host architecture. CMake 3.19.2 returns to using uname -m as CMake 3.18 and below did. Since this may vary based on CMake’s own architecture and that of the invoking process tree, the CMAKE_APPLE_SILICON_PROCESSOR variable or CMAKE_APPLE_SILICON_PROCESSOR environment variable may be set to specify a host architecture explicitly.

@issakomi
Copy link
Copy Markdown
Member Author

@seanm

#include <cstdlib>
int main(int, char**)
{
	system("uname -a");
	return 0;
}

mi@mis-Mac-mini ~ % clang++ --target="x86_64-apple-macos10.14" test1.cpp
mi@mis-Mac-mini ~ % ./a.out
Darwin mis-Mac-mini.fritz.box 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:06:51 PST 2021; root:xnu-7195.81.3~1/RELEASE_ARM64_T8101 x86_64

mi@mis-Mac-mini ~ % clang++ test1.cpp
mi@mis-Mac-mini ~ % ./a.out
Darwin mis-Mac-mini.fritz.box 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:06:51 PST 2021; root:xnu-7195.81.3~1/RELEASE_ARM64_T8101 arm64

@seanm
Copy link
Copy Markdown
Contributor

seanm commented Mar 17, 2021

Ah, so uname gives different results running in rosetta or not. Makes sense I guess. It's after all trying to emulate an x86_64 and software that introspects uname results might expect to detect x86_64.

@thewtex thewtex merged commit ad4880d into InsightSoftwareConsortium:master Mar 18, 2021
@issakomi issakomi deleted the m1 branch March 18, 2021 14:43
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.

5 participants