Internal Compiler Error

Im currently using Arduino 1.8.6 on windows 10. I have developed code to monitor a remote water sample collection unit in Arizona. The code has compiled and uploaded in the past but not it doesn't seem to work. I receive this internal compiler error:

lto1.exe: internal compiler error: in lto_output_varpool_node, at lto-cgraph.c:624

Please submit a full bug report,

with preprocessed source if appropriate.

See <http://gcc.gnu.org/bugs.html> for instructions.

lto-wrapper.exe: fatal error: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.14.0_x86__mdqgnx93n4wtt\hardware\tools\avr/bin/avr-gcc returned 1 exit status

compilation terminated.

c:/program files/windowsapps/arduinollc.arduinoide_1.8.14.0_x86__mdqgnx93n4wtt/hardware/tools/avr/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/ld.exe: error: lto-wrapper failed

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino/Genuino Uno.

I cant recall changing anything on my computer that would effect this. The code that has been causing this issue is attached.

I have tried the blink sketch and it will compile and upload to my board (Adafruit pro trinket 5V).

So i guess I dont understand why this sketch has worked in the past but now I receive this error. I have saved past versions of this program and those will not compile either.

I will attempt a different computer when I get the chance but is there any other advice for this?

ROCKBLOCK_REV3_AUTOSAMPLER_COMMENTED.ino (22.3 KB)

Have you updated your IDE and these programs were written/complied on earlier versions ?

You say you’ve not changed anything that would affect it - that can’t be true or it would work !!

collect2.exe: error: ld returned 1 exit status

The last part of the message show a linker error.

look in the "Avrdude, stk500, Bootloader issues" part of the forum, to start with.

Mark

Im getting the exact same error. My boards AVR boards manager updated to version 1.6.22 and everything down after that. I cant compile anycode other that what is already included with IDE.

I get the same compiler fatal error using IDE 1.8.6 (AVR core 1.6.22) that I downloaded yesterday. I still have the old IDE 1.8.5 (AVR core 1.6.21) installed, and things work fine there. Only some programs are affected, others are fine. I have not found a pattern yet. I'll see if I can create a minimal reproducible example.

IDE 1.8.6 upgraded the GCC compiler from 4.9.2-atmel3.5.4-arduino2 (AVR core 1.6.21) to 5.4.0-atmel3.6.1-arduino2 (AVR core 1.6.22), so that's probably the reason.

I found a reproducible example, and filed a ticket on AVR core. Basically, the compiler crashes when an F() string is assigned to a static variable within a function:

void setup() { }

void loop() {
  static const __FlashStringHelper* F_STRING = F("fstring");
  Serial.print(F_STRING);
}

Thanks bxparks, Ill comb over the code and see where I am assigning an F() string to a static variable within a function. I can only recall using the F() string for cases like serial.print(F("my string"))..... Could this be causing the crash too?

I appreciate all the help on this.

Using serial.print(F("my string")) will work just fine. It's only when it is assigned to a function-static variable that it blows up. As noted in that bug report, I found that I can workaround the problem by not using a function-static variable, like this:

void loop() {
  const __FlashStringHelper* const F_STRING = F("fstring");
  Serial.print(F_STRING);
}

which is what I actually intended in my real code, and it is arguable the better solution to what I wanted (which was to reuse the F() string to avoid duplicate copies in the PROGMEM, since the avr-gcc doesn't (didn't?) do merging of duplicate PROGMEM strings).

hammy:
Have you updated your IDE and these programs were written/complied on earlier versions ?

You say you’ve not changed anything that would affect it - that can’t be true or it would work !!

I was able to install IDE 1.8.5 and the program compiled with no modifications. So you were correct I must have updated my arduino IDE.

On another note I found the source of the bug in my code. It starts with this function being called from the IridiumSBD library found here: IridiumSBD/src/IridiumSBD.cpp at master · mikalhart/IridiumSBD · GitHub

The code

// Try sending a text if awoken okay
  if (isbd.begin() == ISBD_SUCCESS)
  { 
doSomthing(); 
}

Causes the bug. The ISBD_SUCCESS is defined in the library as 0. Changing isbd.begin() == 0 yields the same bug.

From bxparks observation about F() strings it seems that this part of the library is causing the error:

int IridiumSBD::begin()
{
   if (this->reentrant)
      return ISBD_REENTRANT;

   this->reentrant = true;
   int ret = internalBegin();
   this->reentrant = false;

   // Absent a successful startup, keep the device turned off
   if (ret != ISBD_SUCCESS)
      power(false);

   return ret;
}

and from there:

int IridiumSBD::internalBegin()
{
   diagprint(F("Calling internalBegin\r\n"));

   if (!this->asleep)
      return ISBD_ALREADY_AWAKE;

   power(true); // power on

   bool modemAlive = false;

   unsigned long startupTime = 500; //ms
   for (unsigned long start = millis(); millis() - start < startupTime;)
      if (cancelled())
         return ISBD_CANCELLED;

   // Turn on modem and wait for a response from "AT" command to begin
   for (unsigned long start = millis(); !modemAlive && millis() - start < 1000UL * ISBD_STARTUP_MAX_TIME;)
   {
      send(F("AT\r"));
      modemAlive = waitForATResponse();
      if (cancelled())
         return ISBD_CANCELLED;
   }

   if (!modemAlive)
   {
      diagprint(F("No modem detected.\r\n"));
      return ISBD_NO_MODEM_DETECTED;
   }

   // The usual initialization sequence
   FlashString strings[3] = { F("ATE1\r"), F("AT&D0\r"), F("AT&K0\r") };
   for (int i=0; i<3; ++i)
   {
      send(strings[i]); 
      if (!waitForATResponse())
         return cancelled() ? ISBD_CANCELLED : ISBD_PROTOCOL_ERROR;
   } ........

Where you can see the FlashStrings being declared. I do not feel comfortable modifying the library code to fix this problem because I don't understand the problem really. I only know that there is one!!!! Any guidance for a next step would be appreciated!

FlashString IridiumSBD_internalBegin_strings[3] = { F("ATE1\r"), F("AT&D0\r"), F("AT&K0\r") };  // <<<<<<<<<<

int IridiumSBD::internalBegin()
{
   diagprint(F("Calling internalBegin\r\n"));
...
   // The usual initialization sequence
   // remove this line FlashString strings[3] = { F("ATE1\r"), F("AT&D0\r"), F("AT&K0\r") };  <<<<<<<<<<
   for (int i=0; i<3; ++i)
   {
      send(IridiumSBD_internalBegin_strings[i]);  // <<<<<<<<<<
      if (!waitForATResponse())
         return cancelled() ? ISBD_CANCELLED : ISBD_PROTOCOL_ERROR;
   }
...

So, moving the initialization of strings[3] outside of the IridiumSBD::internalBegin() won't compile, because the F() macro works only inside a function context, and produces the following error message:

/home/brian/dev/arduino-1.8.6/hardware/arduino/avr/cores/arduino/WString.h:38:74: error: statement-expressions are not allowed outside functions nor in template-argument lists
 #define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal)))
                                                                          ^
/home/brian/dev/arduino/libraries/IridiumSBD/src/IridiumSBD.cpp:245:7: note: in expansion of macro 'F'
     { F("ATE1\r"), F("AT&D0\r"), F("AT&K0\r") };

Here is an alternative solution that does compile, but I cannot verify that the compiler actually produces the correct code, since I don't have the hardware for this library:

...
   // The usual initialization sequence
   const FlashString a = F("ATE1\r");
   const FlashString b = F("AT&D0\r");
   const FlashString c = F("AT&K0\r");
   const FlashString strings[3] = { a, b, c };
...

bxparks:
Here is an alternative solution that does compile, but I cannot verify that the compiler actually produces the correct code, since I don't have the hardware for this library:

...

// The usual initialization sequence
  const FlashString a = F("ATE1\r");
  const FlashString b = F("AT&D0\r");
  const FlashString c = F("AT&K0\r");
  const FlashString strings[3] = { a, b, c };
...

Thank you for this fix. It compiled and uploaded on IDE 1.8.6 and the hardware still works!!!!!!!!

I cant say how much I appreciate you taking the time to help me through this issue! Hopefully other people find it useful as well.