Arduino 1.8.1 not compiling for Mac OS X 10.7.5

I hope someone will be able to help me with this problem, posted errors below:

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

/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ar: WInterrupts.c.o: plugin needed to handle lto object
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ar: hooks.c.o: plugin needed to handle lto object
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ar: wiring.c.o: plugin needed to handle lto object
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ar: wiring_analog.c.o: plugin needed to handle lto object
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ar: wiring_digital.c.o: plugin needed to handle lto object
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ar: wiring_pulse.c.o: plugin needed to handle lto object
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ar: wiring_shift.c.o: plugin needed to handle lto object
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ar: CDC.cpp.o: plugin needed to handle lto object
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ar: HardwareSerial.cpp.o: plugin needed to handle lto object
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ar: HardwareSerial0.cpp.o: plugin needed to handle lto object
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ar: HardwareSerial1.cpp.o: plugin needed to handle lto object
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ar: HardwareSerial2.cpp.o: plugin needed to handle lto object
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ar: HardwareSerial3.cpp.o: plugin needed to handle lto object
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ar: IPAddress.cpp.o: plugin needed to handle lto object
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ar: PluggableUSB.cpp.o: plugin needed to handle lto object
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ar: Print.cpp.o: plugin needed to handle lto object
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ar: Stream.cpp.o: plugin needed to handle lto object
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ar: Tone.cpp.o: plugin needed to handle lto object
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ar: USBCore.cpp.o: plugin needed to handle lto object
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ar: WMath.cpp.o: plugin needed to handle lto object
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ar: WString.cpp.o: plugin needed to handle lto object
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ar: abi.cpp.o: plugin needed to handle lto object
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ar: main.cpp.o: plugin needed to handle lto object
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ar: /var/folders/v0/6lkhqk4n7nsglhjsnxp5tl9r0000gp/T/arduino_build_227055/core/new.cpp.o: plugin needed to handle lto object
Linking everything together...
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-gcc" -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections,--relax -mmcu=atmega2560 -o "/var/folders/v0/6lkhqk4n7nsglhjsnxp5tl9r0000gp/T/arduino_build_227055/blink.ino.elf" "/var/folders/v0/6lkhqk4n7nsglhjsnxp5tl9r0000gp/T/arduino_build_227055/sketch/blink.ino.cpp.o" "/var/folders/v0/6lkhqk4n7nsglhjsnxp5tl9r0000gp/T/arduino_build_227055/core/core.a" "-L/var/folders/v0/6lkhqk4n7nsglhjsnxp5tl9r0000gp/T/arduino_build_227055" -lm
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ld: /Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../libexec/gcc/avr/4.9.2/liblto_plugin.so: error loading plugin: dlopen(/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../libexec/gcc/avr/4.9.2/liblto_plugin.so, 2): Symbol not found: _environ
Referenced from: /Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../libexec/gcc/avr/4.9.2/liblto_plugin.so
Expected in: /usr/lib/libSystem.B.dylib

collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

Problem was solved by using an older version of the arduino software