Error compiling my sketch for arduino uno board

G'day,
I have written a program for a controller to put on an electric bike. There are several sections to the code for each separate function. It has been working fine, compiling, uploading, allowing me to look at my data, fix or change things and repeat. Up until tday when I started getting the same error message every time I tried to upload or just compile my sketch. recent attempts I did not have the board connected to computor but was only compiling sketch. Other times the board was plugged into my laptop and 9V battery source as it was an on the go check up.
Most of the code works, I just wanted to make a few alterations to it but the error message appears.

My code is below, I really am stumped and would greatly appreciate a reply ASAP as the code needs to be good for my EV competition tomorrow.
Cheers for the help.

#include <Servo.h> // Include Servo Motor Code

Servo servo;

#define trigPin 13 // Trigger Pin
#define echoPin 12 // Echo Pin
#define rLEDPin 11 // Red LED Pin
#define ndtrigPin 10 // Second Trigger pin
#define ndechoPin 8 // Second Echo Pin 
#define ndrLEDPin 7 // Second Red LED Pin
#define bLEDPin 6 // Blue LED Pin
#define ndbLEDPin 5 // Second Blue LED Pin

int maximumRange = 400; // Maximum range needed
int minimumRange = 0; // Minimum range needed
long duration, distance; // Duration used to calculate Distance
int ndmaximumRange = 400; // Maximum range needed for Second UC Sensor
int ndminimumRange = 0; // Minimum range needed for Second UC Sensor
long ndduration, nddistance; // Second Duration used to calculate Second Distance

int angle; // Analog title for Tilt Switch

long startTime = 0;
int state, prevState = 0;
int sensor = 0; // Hall sensor
long counter = 0; // Pulse rate counter
long RPM = 0; // RPM of rear wheel
long Speed = 0; // Speed of rear wheel
unsigned int min_speed = 0; // Minimum speed achievable of rear wheel
unsigned int max_speed = 50; // Maximum speed achievable of rear wheel

void setup() 
{ 
  Serial.begin(9600); // Baud rate set to 9600bps

  servo.write(0);
  servo.attach(9); // Servo Motor Pin
  
  pinMode(trigPin,OUTPUT); // Trigger set as Output
  pinMode(echoPin,INPUT); // Echo set as Input
  pinMode(rLEDPin,OUTPUT); // Red LED set as Output
  pinMode(ndtrigPin,OUTPUT); // Second Trigger set as Output
  pinMode(ndechoPin,INPUT); // Second Echo set as Input
  pinMode(ndrLEDPin,OUTPUT); // Second Red LED set as Output
  pinMode(bLEDPin,OUTPUT); // Blue LED set as Output
  pinMode(ndbLEDPin,OUTPUT); // Second Blue LED set as Output

  pinMode(A1,OUTPUT); // Analog pin 1 Set as Output - Hall Sensor 
  
} 
void loop() 
{ 
    // Hall Sensor Tachometer & Servo Motor Speedometer Programme

 //Reset all variables
 sensor = 0;
 state = 0;
 prevState = 0;
 counter = 0;
 RPM = 0;
 Speed = 0;
 startTime = millis();


 digitalWrite(A1,HIGH); //Turn on sensor and begin dysplaying data onscreen
 Serial.write(12); Serial.print("Measuring...");

 while((millis() - startTime) < 1000) //Loop for duration of 1 second)
 {
  sensor = analogRead(0);
   if (sensor > 750)
    state = 1;
    else
    state = 0;
    
    //On change of state increment counter.
    //A change in state twice represents one revolution
    if(state != prevState)
    {
      counter++;
      prevState = state;
    }
  }
  
  RPM = counter * 30;
  
  Speed = RPM * 60 * ((2.0 * 3.14 * 0.068) / 1000);
Serial.print("RPM = "); Serial.print(RPM);

  int pos = map(Speed, min_speed, max_speed, 180, 0); // Converts speed to angle for servo motor
  servo.write(pos); // Turn servo
  
 
    // Ultrasonic Sensor Programme 
 digitalWrite(trigPin, LOW); 
 delayMicroseconds(2); 

 digitalWrite(trigPin, HIGH);
 delayMicroseconds(10); 
 digitalWrite(trigPin, LOW);
 duration = pulseIn(echoPin, HIGH);
 
 distance = duration/58.2; //Calculate the distance (in cm) based on the speed of sound.
 
 if (distance >= maximumRange || distance <= minimumRange){
 digitalWrite(rLEDPin, LOW); 
 }
 else {
 digitalWrite(rLEDPin, HIGH); 
 }
 //Programme for second Ultrasonic Sensor
 digitalWrite(ndtrigPin, LOW); 
 delayMicroseconds(2); 

 digitalWrite(ndtrigPin, HIGH);
 delayMicroseconds(10); 
 digitalWrite(ndtrigPin, LOW);
 ndduration = pulseIn(ndechoPin, HIGH);

 nddistance = ndduration/58.2; //Calculate the distance (in cm) based on the speed of sound.
 
 if (nddistance >= ndmaximumRange || nddistance <= ndminimumRange){
 digitalWrite(ndrLEDPin, LOW); 
 }
 else {
 digitalWrite(ndrLEDPin, HIGH); 
 }

 
    // Tilt Switch Programme 
 angle=analogRead(5); // Read the voltage value of analog pin 5 
 if(angle>512) // If larger than 512(2.5V) 
 { 
 digitalWrite(bLEDPin,LOW); // Turn off Blue LED 
 } 
 else // Otherwise 
 { 
 digitalWrite(bLEDPin,HIGH); // Turn on Blue LED 
 }
 angle=analogRead(4); // Read the voltage value of analog pin 5 
 if(angle>512) // If larger than 512(2.5V)  
 { 
 digitalWrite(ndbLEDPin,LOW); // Turn off Second Blue LED 
 } 
 else // Otherwise 
 { 
 digitalWrite(ndbLEDPin,HIGH); // Turn on Second Blue LED 
 }
}

Exact error:

Arduino: 1.8.7 (Windows Store 1.8.15.0) (Windows 10), Board: "Arduino/Genuino Uno"

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.15.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino\HardwareSerial.cpp: In member function 'availableForWrite':

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.15.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino\HardwareSerial.cpp:203:1: internal compiler error: Segmentation fault

}

^

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.15.0_x86__mdqgnx93n4wtt\hardware\tools\avr/bin/avr-gcc returned 1 exit status

compilation terminated.

c:/program files/windowsapps/arduinollc.arduinoide_1.8.15.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.

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

I'm baffled. It compiles fine for me on 1.8.7 (I'm on MacOS though)

What version of the servo library do you have?

Check out this post. pert details the issue and provides a workaround