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

Support build on arm64 hosts (Apple M1) #44

Merged
merged 1 commit into from
May 10, 2022

Conversation

HexRabbit
Copy link
Contributor

  • add ARCH_ARM64 macro
  • use CMAKE_HOST_SYSTEM_PROCESSOR to detect host architecture

- add `ARCH_ARM64` macro
- use `CMAKE_HOST_SYSTEM_PROCESSOR` to detect host architecture
@0vercl0k
Copy link
Owner

0vercl0k commented May 7, 2022

Awesome! Do you happen to know the various different possible value for ${CMAKE_HOST_SYSTEM_PROCESSOR} by any chance? Cheers

@HexRabbit
Copy link
Contributor Author

HexRabbit commented May 9, 2022

Cmake's docs says that it use uname -m on GNU, Linux, Cygwin, Android, OpenBSD (arch is an alias) and macOS to get machine architecture.

Inside uname it's using glibc uname() wrapper which further invokes olduname or uname or newuname syscall on linux to get architecture, no matter which one glibc choose, user will get machine architecture from utsname()->machine which inherent from parent namespace.

In init_uts_ns, the machine field is initialized by UTS_MACHINE, it's defined in Makefile and equals to $ARCH, so the value could be any folder name under the arch/ of linux source code, however, some arch/<ARCH>/Makefile may overwrite the UTS_MACHINE value, and there's also COMPAT_UTS_MACHINE which overwrite the machine field before uname syscall returns.

So here's the list: (even though I cannot assure whether I'm right or not..lol)

  • aarch64
  • aarch64_be
  • alpha
  • arc
  • arm
  • arm64 (added from Apple M1)
  • armv8b
  • armv8l
  • csky
  • h8300
  • hexagon
  • i386
  • i686
  • ia64
  • m68k
  • microblaze
  • mips
  • mips64
  • nds32
  • nios2
  • openrisc
  • parisc
  • parisc64
  • powerpc
  • ppc
  • ppcle
  • riscv32
  • riscv64
  • s390
  • s390x
  • sh
  • sparc
  • sparc64
  • um
  • x86_64
  • xtensa

@HexRabbit HexRabbit changed the title Support build on arm64 hosts Support build on arm64 hosts (Apple M1) May 10, 2022
@HexRabbit
Copy link
Contributor Author

HexRabbit commented May 10, 2022

I'm curious is there any dependency that forces you to limit the host architecture?

@0vercl0k 0vercl0k merged commit 7a2ffb7 into 0vercl0k:master May 10, 2022
@0vercl0k
Copy link
Owner

Awesome! I don't think so at least for little endian architectures. I think this looks good, thank you for sending this out 🙏🏽

@HexRabbit
Copy link
Contributor Author

@0vercl0k if we check the endianness first, maybe we could take this out?

#error Platform not supported.

@0vercl0k
Copy link
Owner

0vercl0k commented May 10, 2022 via email

@HexRabbit
Copy link
Contributor Author

Yeah, you are right, without testing it could lead to bugs.

@mmxsrup mmxsrup mentioned this pull request Aug 8, 2023
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.

None yet

2 participants