Compile on Mac M1 [SOLVED]

Please let me know how it goes.


With above workaround, SITL compilation and linking on M1 is successful. Here it is (8K):

SITL running on M1.
3D view captured from .bin log in M1.
QGC (female voice) on M1.
MP (male voice) on Windows PC (TCP).

All normal.

As seen, QGC has a very poor speech capability.

That is great, what did you do exactly to LogStructure.h ??



Only for SITL compilation:

#include <AP_AIS/LogStructure.h>
// structure used to define logging format
struct LogStructure {
uint8_t msg_type;

Only delete PACKED.

1 Like

Ok, thanks!!!


The whole struct to be deleted?

Looking at LogStructure.h and don’t understand what to edit. Can you please make it a bit clearer?

*** UPDATE *** Erased all occurencies of PACKED in LogStructure.h and now sitl compiles.

Thank you very much.

@Webillo now if i start python3 -v ArduCopter i get the following error:

ImportError: dlopen(/opt/homebrew/lib/python3.9/site-packages/, 0x0002): symbol not found in flat namespace ‘_add_history’

and it exits mavproxy. Is there a way to have sitl running as a separate object from mavproxy?

*** UPDATE *** started with option --no-mavproxy and it kind of started but than console is in following condition:

RiTW: Window access not found, logging to /tmp/ArduCopter.log
SIM_VEHICLE: Waiting for SITL to exit

I don’t think it is waiting for a connection…

For me it compiles and links deleting PACKED in that single line.

See this.
In my case I changed in gnureadline to readline (I think you can remove gnureadline module completely if you have it). If you cannot find it, try to upgrade, or use the one in GitHub.
If not, another stupid thing never tested in M1.

Ok, thank you for the explanations.


Is there a #define we could use so that this one thing could be compiled out only when building SITL on Mac?

I found that this breaks --speedup i.e. if I use this hack to get SITL to built then if I pass the --speedup option the SITL process will crash with an illegal hardware instruction error. If I don’t set speedup it works fine.

It’s nice to having it working but it seems a bit dodgy to me.


Could the --speedup issue be related to SITL: crash on Apple M1 when the simulator is compiled for arm64 and --speedup is not specified at startup · Issue #19588 · ArduPilot/ardupilot · GitHub and AP_Logger_File: fix a SITL crash on arm64 when no speedup was specified on the command line by ntamas · Pull Request #19717 · ArduPilot/ardupilot · GitHub ?

It could be @ntamas . I have to look at this more because “something changed” recently and I’m not having this problem now. I think I still use the hack (remove PACKED) - the code compiles and builds and I have managed to run the entire suite of test.Plane scripts which include lots of various speedup values, so it must be working.

Another workaround that does not seem to require the removal of PACKED is to compile the simulator for x86_64 and run it through Rosetta, i.e.:

CFLAGS="-arch x86_64" CXXFLAGS="-arch x86_64" LDFLAGS="-arch x86_64" \
./waf configure --board sitl --debug && ./waf copter

Okay, so it wasn’t clear for me from the previous posts so let me summarize my experiences:

  • Removing all occurrences of PACKED from LogStructure.h indeed works, but this breaks logging as sizeof(some_log_packet) does not match the size of the log packet inferred from the format string any more, and the simulator complains about that (it even sends STATUSTEXT messages about the invalid logging configuration periodically).

  • I figured out that it is enough to remove PACKED from one single place: struct PACKED LogStructure in LogStructure.h. All other instances of PACKED may remain there, and then the warnings are gone, the logging works again…

  • …or well, not exactly. Logging starts, and then I hit this issue again if I don’t specify a speedup value explicitly at startup (i.e. -S 1). Note that this happens only for a native arm64 binary; Intel binaries still work.

I’ve asked on the #simulation channel on Discord why struct LogStructure needs to be packed; if I get an answer and it doesn’t need to be packed, I’ll submit a PR to remove it.

1 Like

Yes, Rosetta works very well.

From here:
For me it compiles and links deleting PACKED in that single line.

I never experienced this problem, but have no idea why not.

There must be a subtle difference in Intel and M1 64bit arquitectures about this (no idea).

Do you use to start the SITL? If so, that’s the reason; seems to pass --speedup unconditionally.

Yes, thanks, now I see that the detailed execution command of an example with … (without speedup) is:
…ardupilot/build/sitl/bin/arducopter -S --model + --speedup 1 --defaults …