Skip to content

Instantly share code, notes, and snippets.

@johnboiles
Last active December 19, 2015 04:39
Show Gist options
  • Save johnboiles/5898311 to your computer and use it in GitHub Desktop.
Save johnboiles/5898311 to your computer and use it in GitHub Desktop.
Patch for that allows compiling SITL version of ArduPilot on OSX (tested on 10.8.4). This makes the following changes * MSG_NOSIGNAL doesn't exist on OSX, instead it requires SO_NOSIGPIPE * The included assembler (as) and linker (ld) flags aren't supported on OSX versions of as and ld. This removes the flags if the uname is Darwin.
diff --git a/libraries/AP_HAL_AVR_SITL/UARTDriver.cpp b/libraries/AP_HAL_AVR_SITL/UARTDriver.cpp
index f99bb2f..3d9ff4e 100644
--- a/libraries/AP_HAL_AVR_SITL/UARTDriver.cpp
+++ b/libraries/AP_HAL_AVR_SITL/UARTDriver.cpp
@@ -33,6 +33,14 @@ using namespace AVR_SITL;
#define LISTEN_BASE_PORT 5760
+// On OSX, MSG_NOSIGNAL doesn't exist. The equivalent is to set SO_NOSIGPIPE
+// in setsockopt for the socket. However, if we just skip that, and don't use
+// MSG_NOSIGNAL, everything seems to work fine and SIGPIPE doesn't seem to be
+// generated.
+#ifdef __APPLE__
+#define MSG_NOSIGNAL 0
+#endif
+
bool SITLUARTDriver::_console;
/* UARTDriver method implementations */
diff --git a/mk/board_avr_sitl.mk b/mk/board_avr_sitl.mk
index c5074e7..fc1094d 100644
--- a/mk/board_avr_sitl.mk
+++ b/mk/board_avr_sitl.mk
@@ -18,7 +18,10 @@ CXXOPTS = -ffunction-sections -fdata-sections -fno-exceptions -fsigned
COPTS = -ffunction-sections -fdata-sections -fsigned-char
ASOPTS = -x assembler-with-cpp
+
+ifneq ($(SYSTYPE),Darwin)
LISTOPTS = -adhlns=$(@:.o=.lst)
+endif
CPUFLAGS = -D_GNU_SOURCE
CPULDFLAGS = -g
@@ -31,7 +34,10 @@ CFLAGS += $(WARNFLAGS) $(DEPFLAGS) $(COPTS)
ASFLAGS = -g $(CPUFLAGS) $(DEFINES) -Wa,$(LISTOPTS) $(DEPFLAGS)
ASFLAGS += $(ASOPTS)
LDFLAGS = -g $(CPUFLAGS) $(OPTFLAGS) $(WARNFLAGS)
+
+ifneq ($(SYSTYPE),Darwin)
LDFLAGS += -Wl,--gc-sections -Wl,-Map -Wl,$(SKETCHMAP)
+endif
LIBS = -lm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment