Weird Compile Time Error for ATtiny

I have ATtiny84 and ATtiny85 chips. Using Arduino ISP, I have downloaded simple sketches on them with no problem.

Now, I have this code for a Simon game.

/*Simon Says game. Now with sound effects.
 
 Originaly made by Robert Spann
 Code trimmed and sound effects added by digimike
 
 Buttons are to be set on there designated pins without pull down resistors
 and connected to ground rather then +5.
 */
#define NOTE_C3 131
#define NOTE_D3 147
#define NOTE_E3 165
#define NOTE_F3 175
#define NOTE_G3 196
#define NOTE_A3 220
#define NOTE_B3 247
#define NOTE_C4 262
#define NOTE_D4 294
#define NOTE_E4 330
#define NOTE_F4 349
#define NOTE_G4 392
#define NOTE_A4 440
#define NOTE_B4 494
#define NOTE_C5 523

int starttune[] = {
  NOTE_C4, NOTE_F4, NOTE_C4, NOTE_F4, NOTE_C4, NOTE_F4, NOTE_C4, NOTE_F4, NOTE_G4, NOTE_F4, NOTE_E4, NOTE_F4, NOTE_G4};
int duration2[] = {
  100, 200, 100, 200, 100, 400, 100, 100, 100, 100, 200, 100, 500};
int note[] = {
  NOTE_C4, NOTE_C4, NOTE_G4, NOTE_C5, NOTE_G4, NOTE_C5};
int duration[] = {
  100, 100, 100, 300, 100, 300};
byte button[] = {
  9, 8, 7, 6}; //The four button input pins
byte ledpin[] = {
  2, 3, 4, 5};  // LED pins
int turn = 0;  // turn counter
int buttonstate = 0;  // button state checker
byte randomArray[100]; //Intentionally long to store up to 100 inputs (doubtful anyone will get this far)
byte inputArray[100]; 
int buzzer = 10;

void setup()
{
  pinMode(buzzer, OUTPUT);
  for(int x=0; x<4; x++)  // LED pins are outputs
  {
    pinMode(ledpin[x], OUTPUT);
  }

  for(int x=0; x<4; x++)
  {
    pinMode(button[x], INPUT);  // button pins are inputs
    digitalWrite(button[x], HIGH);  // enable internal pullup; buttons start in high position; logic reversed
  }

  randomSeed(analogRead(0)); //Added to generate "more randomness" with the randomArray for the output function
  startup();
  delay(1000);
}

void loop()
{  
  for (int y=0; y<=99; y++)
  {
    //function for generating the array to be matched by the player
    digitalWrite(ledpin[0], HIGH);
    digitalWrite(ledpin[1], HIGH);
    digitalWrite(ledpin[2], HIGH);
    digitalWrite(ledpin[3], HIGH);

    for (int thisNote = 0; thisNote < 6; thisNote ++) {
      // play the next note:
      playTone(note[thisNote], duration[thisNote]);
      delay(25);
    }

    digitalWrite(ledpin[0], LOW);
    digitalWrite(ledpin[1], LOW);
    digitalWrite(ledpin[2], LOW);
    digitalWrite(ledpin[3], LOW);
    delay(1000);

    for (int y=turn; y <= turn; y++)
    { //Limited by the turn variable
      randomArray[y] = random(1, 5); //Assigning a random number (1-4) to the randomArray[y], y being the turn count
      for (int x=0; x <= turn; x++)
      {

        for(int y=0; y<4; y++)
        {

          if (randomArray[x] == 1 && ledpin[y] == 8)
          {  //if statements to display the stored values in the array
            digitalWrite(ledpin[y], HIGH);
            playTone(NOTE_G3, 100);
            delay(400);
            digitalWrite(ledpin[y], LOW);
            delay(100);
          }

          if (randomArray[x] == 2 && ledpin[y] == 9)
          {
            digitalWrite(ledpin[y], HIGH);
            playTone(NOTE_A3, 100);
            delay(400);
            digitalWrite(ledpin[y], LOW);
            delay(100);
          }

          if (randomArray[x] == 3 && ledpin[y] == 10)
          {
            digitalWrite(ledpin[y], HIGH);
            playTone(NOTE_B3, 100);
            delay(400);
            digitalWrite(ledpin[y], LOW);
            delay(100);
          }

          if (randomArray[x] == 4 && ledpin[y] == 11)
          {
            digitalWrite(ledpin[y], HIGH);
            playTone(NOTE_C4, 100);
            delay(400);
            digitalWrite(ledpin[y], LOW);
            delay(100);
          }
        }
      }
    }
    input();
  }
}

void playTone(int frequency, int duration) {
  double period = 1.0 / frequency * 1e6 / 2.0;
  for (long i = 0; i < duration * 1000L; i += period *2) {
    digitalWrite(buzzer, HIGH);
    delayMicroseconds((int)period);
    digitalWrite(buzzer, LOW);
    delayMicroseconds((int)period);
  }
}

void input() { //Function for allowing user input and checking input against the generated array
  for (int x=0; x <= turn;)
  { //Statement controlled by turn count

    for(int y=0; y<4; y++)
    {

      buttonstate = digitalRead(button[y]);

      if (buttonstate == LOW && y == 0)
      { //Checking for button push
        digitalWrite(ledpin[0], HIGH);
        playTone(NOTE_G3, 100);
        delay(200);
        digitalWrite(ledpin[0], LOW);
        inputArray[x] = 1;
        delay(250);
        if (inputArray[x] != randomArray[x]) { //Checks value input by user and checks it against
          fail();                              //the value in the same spot on the generated array
        }                                      //The fail function is called if it does not match
        x++;
      }
      if (buttonstate == LOW && y == 1)
      {
        digitalWrite(ledpin[1], HIGH);
        playTone(NOTE_A3, 100);
        delay(200);
        digitalWrite(ledpin[1], LOW);
        inputArray[x] = 2;
        delay(250);
        if (inputArray[x] != randomArray[x]) {
          fail();
        }
        x++;
      }

      if (buttonstate == LOW && y == 2)
      {
        digitalWrite(ledpin[2], HIGH);
        playTone(NOTE_B3, 100);
        delay(200);
        digitalWrite(ledpin[2], LOW);
        inputArray[x] = 3;
        delay(250);
        if (inputArray[x] != randomArray[x]) {
          fail();
        }
        x++;
      }

      if (buttonstate == LOW && y == 3)
      {
        digitalWrite(ledpin[3], HIGH);
        playTone(NOTE_C4, 100);
        delay(200);
        digitalWrite(ledpin[3], LOW);
        inputArray[x] = 4;
        delay(250);
        if (inputArray[x] != randomArray[x])
        {
          fail();
        }
        x++;
      }
    }
  }
  delay(500);
  turn++; //Increments the turn count, also the last action before starting the output function over again
}

void fail() { //Function used if the player fails to match the sequence

  for (int y=0; y<=2; y++)
  { //Flashes lights for failure

    digitalWrite(ledpin[0], HIGH);
    digitalWrite(ledpin[1], HIGH);
    digitalWrite(ledpin[2], HIGH);
    digitalWrite(ledpin[3], HIGH);
    playTone(NOTE_G3, 200);
    //delay(200);
    digitalWrite(ledpin[0], LOW);
    digitalWrite(ledpin[1], LOW);
    digitalWrite(ledpin[2], LOW);
    digitalWrite(ledpin[3], LOW);
    playTone(NOTE_C3, 200);
    //delay(200);
  }
  delay(500);
  turn = -1; //Resets turn value so the game starts over without need for a reset button
  startup();
}

void startup(){
  for (int thisNote = 0; thisNote < 13; thisNote ++) {
    // hold the note:
    if (thisNote==0 || thisNote==2 || thisNote==4 || thisNote== 6)
    {
      digitalWrite(ledpin[0], HIGH);
    }
    if (thisNote==1 || thisNote==3 || thisNote==5 || thisNote== 7 || thisNote==9 || thisNote==11)
    {
      digitalWrite(ledpin[1], HIGH);
    }
    if (thisNote==8 || thisNote==12)
    {
      digitalWrite(ledpin[2], HIGH);
    } 
    if (thisNote==10)
    {  
      digitalWrite(ledpin[3], HIGH);
    }
    // play the next note:
    playTone(starttune[thisNote], duration2[thisNote]);
    digitalWrite(ledpin[0], LOW);
    digitalWrite(ledpin[1], LOW);
    digitalWrite(ledpin[2], LOW);
    digitalWrite(ledpin[3], LOW);
    delay(25);
  }
}

If I have board selected as Arduino Uno, it compiles perfectly, uploads and functions exactly as intended.

However, if I select any of the ATtiny boards, such as ATtiny84 (internal 8 MHz clock), I get this compile time error.

c:/program files/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr25/crttn84.o:(.init9+0x2): relocation truncated to fit: R_AVR_13_PCREL against symbol `exit' defined in .fini9 section in c:/program files/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr25\libgcc.a(_exit.o)

I can't seem to pinpoint which part of the code is causing this. Any ideas?

What version of ide? That should have been fixed by new compiler version ages ago.

My IDE was 1.0.5. Right after I saw your reply, I upgraded to 1.8.5, but now I need to install new hardware files for ATtiny.

Update: after installing new hardware files from GitHub - SpenceKonde/ATTinyCore: Arduino core for ATtiny 1634, 828, x313, x4, x41, x5, x61, x7 and x8 I now have error message:

avrdude: Error: Could not find USBtiny device (0x2341/0x49)

I selected ArduinoISP as programmer and ATtiny24/44/84 with all default settings. Now I can't upload anything to the ATtiny.

Arduino as ISP (ATTinyCore) is probably what you want. ArduinoISP is a USBtiny clone.

A change (around the same time as the compiler update that added LTO, which you very much want, since it reduces the size of a compiled sketch by 10~20%) to avrdude made it pickier about which version of the drivers you have. Make sure you're using the right drivers for your USBTinyISP clone - Zadig is the tool to use to bully windows into using the version of drivers and the right USB library.

On the other hand, if you're using an Arduino running Arduino as ISP sketch, you need to use "Arduino as ISP" not "ArduinoISP"; the latter is a discontinued and unfortunately named product that is totally different from Arduino as ISP sketch. Also, when using my core, use the programmers marked (ATTinyCore); it doesn't matter for the tiny84/85, but the fancier attiny parts need it. (why? the avrdude.conf supplied with the IDE doesn't have entries for most of the attiny chips - just the most common ones, and a couple of those have bad entries. When using a custom core, if the programmer selected is not supplied with a custom core, the IDE will ignore the platform.txt recipes for upload supplied with that core and use the default ones (pointing to the default, bad, avrdude.conf) instead. I maintain that this is a bug, but apparently other people are depending on it)

1.0.x of the IDE doesn't work with ATTiny devices if you're using over 4k of flash; the specific bug is that the compiler doesn't know to use a negative offset RJMP to enable it to jump to any location in an 8kb flash device.

MIT High Low tech -- Arduino as ISP for ATtiny45/85.

You can get core files for loads more AVR's.

I have IDE version 1.8.5 right now (the latest update). I selected Arduino as ISP (ATTinyCore). I want to upload the sketch to my ATtiny84 specifically. I tried all serial port options but now there is a new error:

Arduino: 1.8.5 (Windows 10), Board: "ATtiny24/44/84, Disabled, ATtiny84, 8 MHz (internal), EEPROM retained, B.O.D. Disabled, Clockwise (like damellis core)"

Build options changed, rebuilding all
Sketch uses 4440 bytes (54%) of program storage space. Maximum is 8192 bytes.
Global variables use 304 bytes (59%) of dynamic memory, leaving 208 bytes for local variables. Maximum is 512 bytes.
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x81
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x81
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x81
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x81
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x81
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x81
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x81
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x81
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x81
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x81
Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

If my breadboard duino wiring was loose or wrong, I might expect to see some of those errors.

But you may be using the wrong core. I was looking for one and got interrupted.

Did you look at the MIT site? It shows basic Arduino as a Programmer.

And... I swear it used to be easier to find this very same stuff not 5 years ago.

I will edit in a link to an ATtiny84 (more pins than the 8 on an 85, IIRC) core.

Supported devices are listed in the AVR LibC Online manual: avr-libc: AVR Libc

Ahhhhh, got it! Arduino core for ATtiny 1634, 828, x313, x4, x41, x5, x61, x7 and x8
Yours is the x4.

The read.me shows below the file list.

I actually already have the files installed from the SpenceKonde thing. Is there something else I may be missing?

he Boards Manager 3rd party files json thing? But my guess is copy them to the right folder and it shows up but that may be obsolete, I've added core files for the 1284P just months ago.

Possibly your chip version/signature is not what your software expects even though it works.
Nick Gammon's chip signature blog shows the attiny84 he used and the output.

Is the chip blank? Then it should run 1MHz internal clock otherwise you may need a clock, one thing that Nick explains with pictures yet.

Don't bootload a tiny unless you have flash to spare. I haven't got to how to ISP a hex files w/o loading/having a bootloader.

Here's the MIT High/Low for Arduino 1.6.x update that may be compatible with 1.8.x. It works with the boards manager. The page also goes into wiring which should be translated to tiny84.

Can you get a link to a tiny84 json file at github? Does that cover tiny84A (the signatures thing)?

There are a limited number of things to get right and it should go. None of that stuff would work otherwise.