Compile ardupilot 4.4.4 (copter sitl) on Mac M1 (Sonoma 14.4)

Hello everyone,

I’ve got an issue compiling copter sitl just recently after updating my mac m1 to Sonoma 14.4.
Before that like 1-2 months ago it successfully compiled the same codebase and there wasn’t any issue.

The following error is shown in console

Build failed
 -> task in 'bin/arducopter' failed (exit status 1):
	{task 4362910992: cxxprogram AP_Arming.cpp.50.o,AP_ExternalControl_Copter.cpp.50.o,AP_Rally.cpp.50.o,AP_State.cpp.50.o,Attitude.cpp.50.o,Copter.cpp.50.o,GCS_Copter.cpp.50.o,GCS_Mavlink.cpp.50.o,Log.cpp.50.o,Parameters.cpp.50.o,RC_Channel.cpp.50.o,UserCode.cpp.50.o,UserParameters.cpp.50.o,afs_copter.cpp.50.o,autoyaw.cpp.50.o,avoidance.cpp.50.o,avoidance_adsb.cpp.50.o,baro_ground_effect.cpp.50.o,commands.cpp.50.o,compassmot.cpp.50.o,crash_check.cpp.50.o,ekf_check.cpp.50.o,esc_calibration.cpp.50.o,events.cpp.50.o,failsafe.cpp.50.o,fence.cpp.50.o,heli.cpp.50.o,inertia.cpp.50.o,land_detector.cpp.50.o,landing_gear.cpp.50.o,mode.cpp.50.o,mode_acro.cpp.50.o,mode_acro_heli.cpp.50.o,mode_althold.cpp.50.o,mode_auto.cpp.50.o,mode_autorotate.cpp.50.o,mode_autotune.cpp.50.o,mode_avoid_adsb.cpp.50.o,mode_brake.cpp.50.o,mode_circle.cpp.50.o,mode_drift.cpp.50.o,mode_flip.cpp.50.o,mode_flowhold.cpp.50.o,mode_follow.cpp.50.o,mode_guided.cpp.50.o,mode_guided_nogps.cpp.50.o,mode_land.cpp.50.o,mode_loiter.cpp.50.o,mode_poshold.cpp.50.o,mode_rtl.cpp.50.o,mode_smart_rtl.cpp.50.o,mode_sport.cpp.50.o,mode_stabilize.cpp.50.o,mode_stabilize_heli.cpp.50.o,mode_systemid.cpp.50.o,mode_throw.cpp.50.o,mode_turtle.cpp.50.o,mode_zigzag.cpp.50.o,motor_test.cpp.50.o,motors.cpp.50.o,navigation.cpp.50.o,precision_landing.cpp.50.o,radio.cpp.50.o,sensors.cpp.50.o,standby.cpp.50.o,surface_tracking.cpp.50.o,system.cpp.50.o,takeoff.cpp.50.o,takeoff_check.cpp.50.o,terrain.cpp.50.o,toy_mode.cpp.50.o,tuning.cpp.50.o -> arducopter}
:
	{task 4362910992: cxxprogram AP_Arming.cpp.50.o,AP_ExternalControl_Copter.cpp.50.o,AP_Rally.cpp.50.o,AP_State.cpp.50.o,Attitude.cpp.50.o,Copter.cpp.50.o,GCS_Copter.cpp.50.o,GCS_Mavlink.cpp.50.o,Log.cpp.50.o,Parameters.cpp.50.o,RC_Channel.cpp.50.o,UserCode.cpp.50.o,UserParameters.cpp.50.o,afs_copter.cpp.50.o,autoyaw.cpp.50.o,avoidance.cpp.50.o,avoidance_adsb.cpp.50.o,baro_ground_effect.cpp.50.o,commands.cpp.50.o,compassmot.cpp.50.o,crash_check.cpp.50.o,ekf_check.cpp.50.o,esc_calibration.cpp.50.o,events.cpp.50.o,failsafe.cpp.50.o,fence.cpp.50.o,heli.cpp.50.o,inertia.cpp.50.o,land_detector.cpp.50.o,landing_gear.cpp.50.o,mode.cpp.50.o,mode_acro.cpp.50.o,mode_acro_heli.cpp.50.o,mode_althold.cpp.50.o,mode_auto.cpp.50.o,mode_autorotate.cpp.50.o,mode_autotune.cpp.50.o,mode_avoid_adsb.cpp.50.o,mode_brake.cpp.50.o,mode_circle.cpp.50.o,mode_drift.cpp.50.o,mode_flip.cpp.50.o,mode_flowhold.cpp.50.o,mode_follow.cpp.50.o,mode_guided.cpp.50.o,mode_guided_nogps.cpp.50.o,mode_land.cpp.50.o,mode_loiter.cpp.50.o,mode_poshold.cpp.50.o,mode_rtl.cpp.50.o,mode_smart_rtl.cpp.50.o,mode_sport.cpp.50.o,mode_stabilize.cpp.50.o,mode_stabilize_heli.cpp.50.o,mode_systemid.cpp.50.o,mode_throw.cpp.50.o,mode_turtle.cpp.50.o,mode_zigzag.cpp.50.o,motor_test.cpp.50.o,motors.cpp.50.o,navigation.cpp.50.o,precision_landing.cpp.50.o,radio.cpp.50.o,sensors.cpp.50.o,standby.cpp.50.o,surface_tracking.cpp.50.o,system.cpp.50.o,takeoff.cpp.50.o,takeoff_check.cpp.50.o,terrain.cpp.50.o,toy_mode.cpp.50.o,tuning.cpp.50.o -> arducopter}
['/usr/bin/clang++', '-Wl,-dead_strip', '-pthread', 'ArduCopter/AP_Arming.cpp.50.o', 'ArduCopter/AP_ExternalControl_Copter.cpp.50.o', 'ArduCopter/AP_Rally.cpp.50.o', 'ArduCopter/AP_State.cpp.50.o', 'ArduCopter/Attitude.cpp.50.o', 'ArduCopter/Copter.cpp.50.o', 'ArduCopter/GCS_Copter.cpp.50.o', 'ArduCopter/GCS_Mavlink.cpp.50.o', 'ArduCopter/Log.cpp.50.o', 'ArduCopter/Parameters.cpp.50.o', 'ArduCopter/RC_Channel.cpp.50.o', 'ArduCopter/UserCode.cpp.50.o', 'ArduCopter/UserParameters.cpp.50.o', 'ArduCopter/afs_copter.cpp.50.o', 'ArduCopter/autoyaw.cpp.50.o', 'ArduCopter/avoidance.cpp.50.o', 'ArduCopter/avoidance_adsb.cpp.50.o', 'ArduCopter/baro_ground_effect.cpp.50.o', 'ArduCopter/commands.cpp.50.o', 'ArduCopter/compassmot.cpp.50.o', 'ArduCopter/crash_check.cpp.50.o', 'ArduCopter/ekf_check.cpp.50.o', 'ArduCopter/esc_calibration.cpp.50.o', 'ArduCopter/events.cpp.50.o', 'ArduCopter/failsafe.cpp.50.o', 'ArduCopter/fence.cpp.50.o', 'ArduCopter/heli.cpp.50.o', 'ArduCopter/inertia.cpp.50.o', 'ArduCopter/land_detector.cpp.50.o', 'ArduCopter/landing_gear.cpp.50.o', 'ArduCopter/mode.cpp.50.o', 'ArduCopter/mode_acro.cpp.50.o', 'ArduCopter/mode_acro_heli.cpp.50.o', 'ArduCopter/mode_althold.cpp.50.o', 'ArduCopter/mode_auto.cpp.50.o', 'ArduCopter/mode_autorotate.cpp.50.o', 'ArduCopter/mode_autotune.cpp.50.o', 'ArduCopter/mode_avoid_adsb.cpp.50.o', 'ArduCopter/mode_brake.cpp.50.o', 'ArduCopter/mode_circle.cpp.50.o', 'ArduCopter/mode_drift.cpp.50.o', 'ArduCopter/mode_flip.cpp.50.o', 'ArduCopter/mode_flowhold.cpp.50.o', 'ArduCopter/mode_follow.cpp.50.o', 'ArduCopter/mode_guided.cpp.50.o', 'ArduCopter/mode_guided_nogps.cpp.50.o', 'ArduCopter/mode_land.cpp.50.o', 'ArduCopter/mode_loiter.cpp.50.o', 'ArduCopter/mode_poshold.cpp.50.o', 'ArduCopter/mode_rtl.cpp.50.o', 'ArduCopter/mode_smart_rtl.cpp.50.o', 'ArduCopter/mode_sport.cpp.50.o', 'ArduCopter/mode_stabilize.cpp.50.o', 'ArduCopter/mode_stabilize_heli.cpp.50.o', 'ArduCopter/mode_systemid.cpp.50.o', 'ArduCopter/mode_throw.cpp.50.o', 'ArduCopter/mode_turtle.cpp.50.o', 'ArduCopter/mode_zigzag.cpp.50.o', 'ArduCopter/motor_test.cpp.50.o', 'ArduCopter/motors.cpp.50.o', 'ArduCopter/navigation.cpp.50.o', 'ArduCopter/precision_landing.cpp.50.o', 'ArduCopter/radio.cpp.50.o', 'ArduCopter/sensors.cpp.50.o', 'ArduCopter/standby.cpp.50.o', 'ArduCopter/surface_tracking.cpp.50.o', 'ArduCopter/system.cpp.50.o', 'ArduCopter/takeoff.cpp.50.o', 'ArduCopter/takeoff_check.cpp.50.o', 'ArduCopter/terrain.cpp.50.o', 'ArduCopter/toy_mode.cpp.50.o', 'ArduCopter/tuning.cpp.50.o', '-obin/arducopter', '-Llib', '-lArduCopter_libs', '-lm']

as well would be useful to know that failure happens only on latest step of compile

[1305/1305] Linking build/sitl/bin/arducopter
13:59:56 runner ['/usr/bin/clang++', '-Wl,-dead_strip', '-pthread', 'ArduCopter/AP_Arming.cpp.50.o', 'ArduCopter/AP_ExternalControl_Copter.cpp.50.o', 'ArduCopter/AP_Rally.cpp.50.o', 'ArduCopter/AP_State.cpp.50.o', 'ArduCopter/Attitude.cpp.50.o', 'ArduCopter/Copter.cpp.50.o', 'ArduCopter/GCS_Copter.cpp.50.o', 'ArduCopter/GCS_Mavlink.cpp.50.o', 'ArduCopter/Log.cpp.50.o', 'ArduCopter/Parameters.cpp.50.o', 'ArduCopter/RC_Channel.cpp.50.o', 'ArduCopter/UserCode.cpp.50.o', 'ArduCopter/UserParameters.cpp.50.o', 'ArduCopter/afs_copter.cpp.50.o', 'ArduCopter/autoyaw.cpp.50.o', 'ArduCopter/avoidance.cpp.50.o', 'ArduCopter/avoidance_adsb.cpp.50.o', 'ArduCopter/baro_ground_effect.cpp.50.o', 'ArduCopter/commands.cpp.50.o', 'ArduCopter/compassmot.cpp.50.o', 'ArduCopter/crash_check.cpp.50.o', 'ArduCopter/ekf_check.cpp.50.o', 'ArduCopter/esc_calibration.cpp.50.o', 'ArduCopter/events.cpp.50.o', 'ArduCopter/failsafe.cpp.50.o', 'ArduCopter/fence.cpp.50.o', 'ArduCopter/heli.cpp.50.o', 'ArduCopter/inertia.cpp.50.o', 'ArduCopter/land_detector.cpp.50.o', 'ArduCopter/landing_gear.cpp.50.o', 'ArduCopter/mode.cpp.50.o', 'ArduCopter/mode_acro.cpp.50.o', 'ArduCopter/mode_acro_heli.cpp.50.o', 'ArduCopter/mode_althold.cpp.50.o', 'ArduCopter/mode_auto.cpp.50.o', 'ArduCopter/mode_autorotate.cpp.50.o', 'ArduCopter/mode_autotune.cpp.50.o', 'ArduCopter/mode_avoid_adsb.cpp.50.o', 'ArduCopter/mode_brake.cpp.50.o', 'ArduCopter/mode_circle.cpp.50.o', 'ArduCopter/mode_drift.cpp.50.o', 'ArduCopter/mode_flip.cpp.50.o', 'ArduCopter/mode_flowhold.cpp.50.o', 'ArduCopter/mode_follow.cpp.50.o', 'ArduCopter/mode_guided.cpp.50.o', 'ArduCopter/mode_guided_nogps.cpp.50.o', 'ArduCopter/mode_land.cpp.50.o', 'ArduCopter/mode_loiter.cpp.50.o', 'ArduCopter/mode_poshold.cpp.50.o', 'ArduCopter/mode_rtl.cpp.50.o', 'ArduCopter/mode_smart_rtl.cpp.50.o', 'ArduCopter/mode_sport.cpp.50.o', 'ArduCopter/mode_stabilize.cpp.50.o', 'ArduCopter/mode_stabilize_heli.cpp.50.o', 'ArduCopter/mode_systemid.cpp.50.o', 'ArduCopter/mode_throw.cpp.50.o', 'ArduCopter/mode_turtle.cpp.50.o', 'ArduCopter/mode_zigzag.cpp.50.o', 'ArduCopter/motor_test.cpp.50.o', 'ArduCopter/motors.cpp.50.o', 'ArduCopter/navigation.cpp.50.o', 'ArduCopter/precision_landing.cpp.50.o', 'ArduCopter/radio.cpp.50.o', 'ArduCopter/sensors.cpp.50.o', 'ArduCopter/standby.cpp.50.o', 'ArduCopter/surface_tracking.cpp.50.o', 'ArduCopter/system.cpp.50.o', 'ArduCopter/takeoff.cpp.50.o', 'ArduCopter/takeoff_check.cpp.50.o', 'ArduCopter/terrain.cpp.50.o', 'ArduCopter/toy_mode.cpp.50.o', 'ArduCopter/tuning.cpp.50.o', '-obin/arducopter', '-Llib', '-lArduCopter_libs', '-lm']
ld: building fixups: pointer not aligned at __ZN12AP_FWVersion5fwverE+0x34 from /Users/r.koval/code/ardupilot/build/sitl/ArduCopter/Copter.cpp.50.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Meanwhile when I compile some other board, everything is finished without failure.

Any help is appreciated.

Thanks!

1 Like

Not sure, would have to try

I am getting the same identical error when compiling Plane! I initially thought it was just a problem of my machine but apparently it’s not

Thanks @andyp1per!

May we expect some date when you may look at this?

I can’t reproduce this on either x86 or M2Pro on Sonoma 14.4.1. Did you update xcode? I am using clang 15

Adding my data point: M1Pro, Sonoma 14.2.1, clang 15.0.0, trying to compile ArduCopter 4.4.4 and the issue is there. Updating to 14.4.1 now and also updating XCode Command Line Tools to see if this solves the problem.

Issue still persists after the upgrade. Now I’m on Sonoma 14.4.1 and I’m trying to compile Copter 4.4.4, git revision db53a28f.

Output of clang -v is as follows:

Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Also, I’ve confirmed that ./waf configure picks up /usr/bin/clang and /usr/bin/clang++.

Yeah, same on my laptop.

I just updated to Sonoma 14.4.1 on my M1Pro and getting the same problem - compiling master for SITL

[1308/1308] Linking build/sitl/bin/arducopter
ld: building fixups: pointer not aligned at __ZN12AP_FWVersion5fwverE+0x34 from /Users/tim/ArduPilot/ardupilot/build/sitl/ArduCopter/Copter.cpp.50.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I found something that seems to work - installing an older version of Xcode.

I followed the instructions here: Working with Multiple Versions of Xcode | by Geoff Hackworth | Medium

I went for 15.0.1. Don’t forget this step in the terminal window where you are running waf:
sudo xcode-select -s /Applications/Xcode-15.0.1.app/Contents/Developer

Now the linker alignment issue is only a warning not an error and the build completes.

1 Like

What version of XCode were you using? I had thought I was using the latest

Hi @rkoval, it looks like the issue is a change in the default linker in Xcode 15.3. This PR offers a fix: Tools: ardupilotwaf: use classic clang linker when compiling on macOS by srmainwaring · Pull Request #26700 · ArduPilot/ardupilot · GitHub

2 Likes

Thanks for your investigation and finding some workaround.

Awesome! You fixed it.

Would be nice to get it merged @andyp1per.

Thanks

pkgutil --pkg-info=com.apple.pkg.CLTools_Executables
package-id: com.apple.pkg.CLTools_Executables
version: 15.3.0.0.1.1708646388
volume: /
location: /
install-time: 1711468767

I get no results for that. Maybe something to do with using ccache. According to XCode itself I have command line tools 15.3 installed.

What does:

xcode-select -v

give you?

xcode-select -v
xcode-select version 2406.

I have the same and no build problems, so I think the problem is more subtle unless xcode is lying

1 Like

I dont’ think that’s telling you anything. I get the same result (2406) whether I have 15.3 or 15.0.1 “selected”. 15.0.1 will build and link, 15.3 will fail.

sudo xcode-select -s /Applications/Xcode-15.0.1.app/Contents/Developer
will build and link - but will report version 2406
sudo Xcode-select -r
(which selects 15.3) will fail. but will also report version 2406

I think Xcode-select -v is just giving you the version of Xcode-select itself, not the Xcode “package”