Building Arduino IDE from source, Linux works, MacOS and Windows do not

Hi,

I've made a modification to the HardwareSerial code (9-bit support), in order to do so I cloned the Arduino repo from Github and made a new branch.

When I start it on my linux machine:

cd Arduino/build
sudo ant
sudo ant run

Everything works as expected, I can upload a test program and the Boards serial port behaves as expected after my modifications.

Unfortunately on MacOS things go diffrent, I can start the IDE the same way I did on Windows, but when I try to compile the exact same sketch, the result is an exit status 1:

Arduino: 1.8.2 (Mac OS X), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

/Users/Shaune/Arduino/build/macosx/work/Arduino.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware /Users/Shaune/Arduino/build/macosx/work/Arduino.app/Contents/Java/hardware -tools /Users/Shaune/Arduino/build/macosx/work/Arduino.app/Contents/Java/tools-builder -tools /Users/Shaune/Arduino/build/macosx/work/Arduino.app/Contents/Java/hardware/tools/avr -built-in-libraries /Users/Shaune/Arduino/build/macosx/work/Arduino.app/Contents/Java/libraries -libraries /var/root/sketchbook/libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -vid-pid=0X2341_0X0042 -ide-version=10802 -build-path /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/arduino_build_869521 -warnings=none -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=/Users/Shaune/Arduino/build/macosx/work/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avr-gcc.path=/Users/Shaune/Arduino/build/macosx/work/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.arduinoOTA.path=/Users/Shaune/Arduino/build/macosx/work/Arduino.app/Contents/Java/hardware/tools/avr -verbose /private/var/root/sketchbook/sketch_mar26a/sketch_mar26a.ino
/Users/Shaune/Arduino/build/macosx/work/Arduino.app/Contents/Java/arduino-builder -compile -logger=machine -hardware /Users/Shaune/Arduino/build/macosx/work/Arduino.app/Contents/Java/hardware -tools /Users/Shaune/Arduino/build/macosx/work/Arduino.app/Contents/Java/tools-builder -tools /Users/Shaune/Arduino/build/macosx/work/Arduino.app/Contents/Java/hardware/tools/avr -built-in-libraries /Users/Shaune/Arduino/build/macosx/work/Arduino.app/Contents/Java/libraries -libraries /var/root/sketchbook/libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -vid-pid=0X2341_0X0042 -ide-version=10802 -build-path /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/arduino_build_869521 -warnings=none -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=/Users/Shaune/Arduino/build/macosx/work/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.avr-gcc.path=/Users/Shaune/Arduino/build/macosx/work/Arduino.app/Contents/Java/hardware/tools/avr -prefs=runtime.tools.arduinoOTA.path=/Users/Shaune/Arduino/build/macosx/work/Arduino.app/Contents/Java/hardware/tools/avr -verbose /private/var/root/sketchbook/sketch_mar26a/sketch_mar26a.ino
Using board 'mega' from platform in folder: /Users/Shaune/Arduino/build/macosx/work/Arduino.app/Contents/Java/hardware/arduino/avr
Using core 'arduino' from platform in folder: /Users/Shaune/Arduino/build/macosx/work/Arduino.app/Contents/Java/hardware/arduino/avr
Detecting libraries used...
"/Users/Shaune/Arduino/build/macosx/work/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR   "-I/Users/Shaune/Arduino/build/macosx/work/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" "-I/Users/Shaune/Arduino/build/macosx/work/Arduino.app/Contents/Java/hardware/arduino/avr/variants/mega" "/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/arduino_build_869521/sketch/sketch_mar26a.ino.cpp" -o "/dev/null"
Generating function prototypes...
"/Users/Shaune/Arduino/build/macosx/work/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR   "-I/Users/Shaune/Arduino/build/macosx/work/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" "-I/Users/Shaune/Arduino/build/macosx/work/Arduino.app/Contents/Java/hardware/arduino/avr/variants/mega" "/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/arduino_build_869521/sketch/sketch_mar26a.ino.cpp" -o "/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/arduino_build_869521/preproc/ctags_target_for_gcc_minus_e.cpp"
"/Users/Shaune/Arduino/build/macosx/work/Arduino.app/Contents/Java/tools-builder/ctags/5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/arduino_build_869521/preproc/ctags_target_for_gcc_minus_e.cpp"
exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

On Windows the IDE crashes on start but that's maybe a Java issue not relevant to me at the moment.

I can't see whats causing the error, so maybe someone can point out to me what I'm doing wrong.

Why are you using sudo? It is not necessary for building or running the IDE.

The cause of the failure is that ctags does not work if $TMPDIR is not defined (sudo undefines it):

ctags: cannot open temporary file : No such file or directory