-
-
Notifications
You must be signed in to change notification settings - Fork 346
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
Can't build for SMING_ARCH=Host in Apple M1 Pro #2773
Comments
You have |
Actually, might not be this... Try posting a dump of |
@mikee47 thanks for your response... This is the log from command
|
So on your system running Sming requires GCC. Have a look at https://sming.readthedocs.io/en/latest/getting-started/macos/index.html for installation instructions. You can also try searching for 'installing gcc on macos`. It would be handy to have a MacOS system for testing, but they don't make it easy! |
You are right, I tried to install the GNU version but still doesn't work... As you can see I have installed the GNU versions for
And I set the env variables to define the right
I don't know what else I can do :-( |
I'm trying to get a VM installation of MacOS so I can help further. It's painful... In the meantime, you can edit |
This PR adds the `CLANG_BUILD` for host builds. The toolchain detection logic is in the main build.mk file as there might be future support for clang toolchains for actual devices. It's also a revision to the existing logic which checks GCC compiler version. Try it out using `make SMING_SOC=host CLANG_BUILD=1`. To build with a specific (installed) version of clang, for example clang-15, use `CLANG_BUILD=15` . Further customisation can be made by editing `Sming/Arch/Host/build.mk`. Clang-tidy support (#2648) is also improved as there are some compiler flag differences between GCC and clang which are now shared between CLANG_TIDY and CLANG_BUILD operation. An extra CI build has been added using clang. Further to #2773, the default toolchain for macos is a version of clang (Apple Clang). This PR doesn't quite support that because there are other issues to address, but it's a step in the right direction.
Update, I've been trying to get host builds for MacOS but even with GCC installed we still have to use the xcode linker. Bear with me, I'm sure we can get this working! |
Spoke too soon. The host emulator builds in 32-bit mode to reflect the devices being targeted. GCC and clang both allow building 32-bit binaries for 64-bit platforms. However, it looks like Apple won't support 32-bit applications at all. See https://support.apple.com/en-us/103076. Build fails at the link step because the linker refuses to recognise code compiled with the -m32 option. Revising the framework to support 64-bit builds is problematic because all pointers would become 64-bit. That could be worth investigating if only to allow more general use of the libraries. |
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.
@mtzfactory With latest develop you should now be able to progress with Host builds. |
@mikee47 thanks for your efforts in solving this... $ make V=1
PYTHON_VERSION = Python 3.12.4
Note: Building with Apple-clang 15.0.0.
Basic_Blink: Invoking 'all' for Host (debug) architecture
-- Parsing App
-- Parsing Sming
-- Parsing Storage
-- Parsing sming-arch
-- Parsing driver
-- Parsing arch_driver
-- Parsing SerialLib
-- Parsing esp_hal
-- Parsing gdbstub
-- Parsing heap
-- Parsing hostlib
-- Parsing libc
-- Parsing spi_flash
-- Parsing vflash
-- Parsing rboot
-- Parsing FlashString
-- Parsing Spiffs
-- Parsing IFS
-- Parsing SPI
-- Parsing terminal
SUBMODULES_FETCHED:
/Applications/Xcode.app/Contents/Developer/usr/bin/make components application
PYTHON_VERSION = Python 3.12.4
Note: Building with Apple-clang 15.0.0.
-- Parsing App
-- Parsing Sming
-- Parsing Storage
-- Parsing sming-arch
-- Parsing driver
-- Parsing arch_driver
-- Parsing SerialLib
-- Parsing esp_hal
-- Parsing gdbstub
-- Parsing heap
-- Parsing hostlib
-- Parsing libc
-- Parsing spi_flash
-- Parsing vflash
-- Parsing rboot
-- Parsing FlashString
-- Parsing Spiffs
-- Parsing IFS
-- Parsing SPI
-- Parsing terminal
Building /opt/sming/samples/Basic_Blink/out/Host/debug/lib/clib-App-4cd15fee126d2cfd58677a9b32b80d61.a
/Applications/Xcode.app/Contents/Developer/usr/bin/make -r -R --no-print-directory -C out/Host/debug/build/App/App-4cd15fee126d2cfd58677a9b32b80d61 -f /opt/sming/Sming/component-wrapper.mk COMPONENT_NAME=App COMPONENT_PATH=/opt/sming/samples/Basic_Blink COMPONENT_BUILD_BASE=out/Host/debug/build/App COMPONENT_LIBDIR=/opt/sming/samples/Basic_Blink/out/Host/debug/lib COMPONENT_LIBNAME=App COMPONENT_LIBHASH=4cd15fee126d2cfd58677a9b32b80d61 build
PYTHON_VERSION = Python 3.12.4
Note: Building with Apple-clang 15.0.0.
WriteConfig /opt/sming/samples/Basic_Blink/out/Host/debug/build/App/App-4cd15fee126d2cfd58677a9b32b80d61/build.cfg
make[2]: Nothing to be done for `build'.
touch -c "/opt/sming/samples/Basic_Blink/out/Host/debug/lib/clib-App-4cd15fee126d2cfd58677a9b32b80d61.a"
/Applications/Xcode.app/Contents/Developer/usr/bin/make --no-print-directory hwconfig-validate
PYTHON_VERSION = Python 3.12.4
Note: Building with Apple-clang 15.0.0.
-- Parsing App
-- Parsing Sming
-- Parsing Storage
-- Parsing sming-arch
-- Parsing driver
-- Parsing arch_driver
-- Parsing SerialLib
-- Parsing esp_hal
-- Parsing gdbstub
-- Parsing heap
-- Parsing hostlib
-- Parsing libc
-- Parsing spi_flash
-- Parsing vflash
-- Parsing rboot
-- Parsing FlashString
-- Parsing Spiffs
-- Parsing IFS
-- Parsing SPI
-- Parsing terminal
Validating hardware config 'standard'
SMING_HOME="/opt/sming/Sming" SMING_ARCH="Host" SMING_SOC="host" OUT_BASE="out/Host/debug" HWCONFIG_DIRS="/opt/sming/samples/Basic_Blink /opt/sming/Sming/Arch/Host /opt/sming/Sming" HWCONFIG_OPTS="" HWCONFIG_BUILDSPECS=" /opt/sming/Sming/Libraries/Spiffs/build.json /opt/sming/Sming/Components/IFS/build.json" HWCONFIG_SCHEMA="/opt/sming/Sming/Components/Storage/schema.json" /opt/homebrew/opt/python@3/bin/python3 /opt/sming/Sming/Components/Storage/Tools/hwconfig/hwconfig.py validate standard -
SMING_HOME="/opt/sming/Sming" SMING_ARCH="Host" SMING_SOC="host" OUT_BASE="out/Host/debug" HWCONFIG_DIRS="/opt/sming/samples/Basic_Blink /opt/sming/Sming/Arch/Host /opt/sming/Sming" HWCONFIG_OPTS="" HWCONFIG_BUILDSPECS=" /opt/sming/Sming/Libraries/Spiffs/build.json /opt/sming/Sming/Components/IFS/build.json" HWCONFIG_SCHEMA="/opt/sming/Sming/Components/Storage/schema.json" /opt/homebrew/opt/python@3/bin/python3 /opt/sming/Sming/Components/Storage/Tools/hwconfig/hwconfig.py partgen standard out/Host/debug/firmware/partitions.bin
Verifying partition table...
Writing to 'out/Host/debug/firmware/partitions.bin'
Basic_Blink: Linking out/Host/debug/firmware/app
WriteConfig out/Host/debug/firmware/app.cfg
g++ -Lout/Host/debug/lib -L/opt/sming/Sming/out/Host/debug/lib -Wl,-map,out/Host/debug/firmware/app.map -Wl,-w -Wl,-undefined,suppress -Wl,-flat_namespace /opt/sming/Sming/out/Host/debug/lib/clib-Sming-334d12a2e9d6d3b9f6d2b2601bd6efea.a /opt/sming/Sming/out/Host/debug/lib/clib-Storage-05facba2c21a7ea5f46aa64d5ad116ec.a /opt/sming/Sming/out/Host/debug/lib/clib-sming-arch-d7260691270308fc79c91ae769e365bc.a /opt/sming/Sming/out/Host/debug/lib/clib-FlashString.a /opt/sming/Sming/out/Host/debug/lib/clib-Spiffs-a7045ecdb428dae983d689bef7e1fc4c.a /opt/sming/Sming/out/Host/debug/lib/clib-IFS-b42a2400b5492f2c1c38a4bc6e072e6a.a /opt/sming/Sming/out/Host/debug/lib/clib-SPI-384cc4776fd3bb8b6a07b0af0600efef.a /opt/sming/Sming/out/Host/debug/lib/clib-driver-b74d2cc119e8d2ea1d9c8827b431c60c.a /opt/sming/Sming/out/Host/debug/lib/clib-esp_hal-b74d2cc119e8d2ea1d9c8827b431c60c.a /opt/sming/Sming/out/Host/debug/lib/clib-gdbstub.a /opt/sming/Sming/out/Host/debug/lib/clib-heap-1b8ef5aea84d9cd64812b71273db9aef.a /opt/sming/Sming/out/Host/debug/lib/clib-hostlib-6dc5eb31a811240991e92117f65caa64.a /opt/sming/Sming/out/Host/debug/lib/clib-libc.a /opt/sming/Sming/out/Host/debug/lib/clib-spi_flash-d7260691270308fc79c91ae769e365bc.a /opt/sming/Sming/out/Host/debug/lib/clib-rboot-c11442c8e56dc48c11f45db0277f4cab.a /opt/sming/Sming/out/Host/debug/lib/clib-arch_driver.a /opt/sming/Sming/out/Host/debug/lib/clib-SerialLib.a /opt/sming/samples/Basic_Blink/out/Host/debug/lib/clib-App-4cd15fee126d2cfd58677a9b32b80d61.a -lpthread -o out/Host/debug/firmware/app
ld: multiple errors: archive member '/' not a mach-o file in '/opt/sming/Sming/out/Host/debug/lib/clib-Storage-05facba2c21a7ea5f46aa64d5ad116ec.a'; archive member '/' not a mach-o file in '/opt/sming/Sming/out/Host/debug/lib/clib-FlashString.a'; archive member '/' not a mach-o file in '/opt/sming/Sming/out/Host/debug/lib/clib-Sming-334d12a2e9d6d3b9f6d2b2601bd6efea.a'; archive member '/' not a mach-o file in '/opt/sming/Sming/out/Host/debug/lib/clib-sming-arch-d7260691270308fc79c91ae769e365bc.a'; archive member '/' not a mach-o file in '/opt/sming/Sming/out/Host/debug/lib/clib-heap-1b8ef5aea84d9cd64812b71273db9aef.a'; archive member '/' not a mach-o file in '/opt/sming/Sming/out/Host/debug/lib/clib-hostlib-6dc5eb31a811240991e92117f65caa64.a'; archive member '/' not a mach-o file in '/opt/sming/Sming/out/Host/debug/lib/clib-gdbstub.a'; archive member '/' not a mach-o file in '/opt/sming/Sming/out/Host/debug/lib/clib-esp_hal-b74d2cc119e8d2ea1d9c8827b431c60c.a'; archive member '/' not a mach-o file in '/opt/sming/Sming/out/Host/debug/lib/clib-spi_flash-d7260691270308fc79c91ae769e365bc.a'; archive member '/' not a mach-o file in '/opt/sming/Sming/out/Host/debug/lib/clib-Spiffs-a7045ecdb428dae983d689bef7e1fc4c.a'; archive member '/' not a mach-o file in '/opt/sming/Sming/out/Host/debug/lib/clib-SPI-384cc4776fd3bb8b6a07b0af0600efef.a'; archive member '/' not a mach-o file in '/opt/sming/Sming/out/Host/debug/lib/clib-driver-b74d2cc119e8d2ea1d9c8827b431c60c.a'; archive member '/' not a mach-o file in '/opt/sming/Sming/out/Host/debug/lib/clib-libc.a'; archive member '/' not a mach-o file in '/opt/sming/Sming/out/Host/debug/lib/clib-rboot-c11442c8e56dc48c11f45db0277f4cab.a'; archive member '/' not a mach-o file in '/opt/sming/Sming/out/Host/debug/lib/clib-SerialLib.a'; archive member '/' not a mach-o file in '/opt/sming/Sming/out/Host/debug/lib/clib-arch_driver.a'; archive member '/' not a mach-o file in '/opt/sming/Sming/out/Host/debug/lib/clib-IFS-b42a2400b5492f2c1c38a4bc6e072e6a.a'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [out/Host/debug/firmware/app] Error 1
make: *** [all] Error 2 |
Can you try editing
|
or it might be line 34, maybe insert an override line 40. |
Re-formatting the errors more clearly:
|
@mikee47 it worked! Overriding at line 40 worked! Thank you very much! BTW: Now I'm able to debug with lldb and vscode |
I'm trying to build the basic blink example to debug it in my host machine (Apple M1 Pro) but it fails with the following error:
The text was updated successfully, but these errors were encountered: