-
-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR adds support for the Host Emulator to MacOS. See #2773. **64-bit only** Standard compiler is 'Apple Clang', supports only 64-bit builds: no 32-bit compatibility. GCC can be installed via `brew install gcc` and compiles as usual with the `-m32` flag. The GNU linker is absent from brew's `coreutils` package (see Homebrew/homebrew-core#17794) so the standard system linker must be used. This only supports 64-bit targets. Apple have removed 32-bit application support from their ecosystem. Advantages No need for 32-bit compatibibility libraries in GNU/Linux. For MacOS build and run host emulator using standard Apple tools, no GCC required. General improvements in portability, less tolerant of incorrect type usage. Disadvantages Types such as long, size_t now 64-bit, don't match target hardware Pointers are 64-bit so cannot be cast to 32-bit intrinsics. Code must use correct `intptr_t` types. Must use `ENABLE_STORAGE_SIZE64=1` as emulated flash addresses must be 64-bit. **Symbol wrapping** MacOS linker doesn't support symbol wrapping which is used by `malloc_count` Component to hook `malloc`, etc. Don't currently have a solution for this so malloc_count is disabled for MacOS. **CI builds** Added MacOS builds plus running tests. For esp32 only IDF 5.2 is tested. **Notes** MacOS identified in makefiles with `UNAME=Darwin`. In code, use `#ifdef __APPLE__` when running on apple toolchains. Also requires `#ifdef __aarch64__` for Apple Silicon. The `rbpf` library requires `bpf` target with clang. Not supported by apple clang - use brew clang. I managed to get MacOS Ventura running in Qemu via https://github.com/kholia/OSX-KVM. This runs in x86_64 mode, adequate for dev/testing. The github actions runner `macos-latest` uses arm64, so introduces a few extra quirks. **Tools** - Compiler. Standard compiler is 'Apple Clang', supports only 64-bit builds: no 32-bit compatibility. Doesn't support `alias` attribute so use linker to do that instead. - Archive. Standard `ar` does not support - Linker. GNU Linker not available. MacOS linker does not support symbol wrapping. - GDB. Can be installed with `brew` but requires some additional steps for security reasons. Separate `lldb` target added. - sed. GNU 'sed' tool has extensions which MacOS version does not support. Added `SED` build variable which should always point to GNU version `gsed`, but only for Darwin.
- Loading branch information
Showing
50 changed files
with
725 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Used for interrupt emulation | ||
process handle -p true -s false -n false SIGUSR1 SIGUSR2 | ||
|
||
# Display a welcome prompt | ||
script print("\nWelcome to SMING!\nType 'r' to run application\n\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.