Compilation error: Unaligned opcodes detected in executable segment

Anyone else had this compilation error please?

It's a quite large project that used to compile with no problems, but now:

ccKdJqWc.s: Assembler messages
 
ccKdJqWc.s: Error: unaligned opcodes detected in executable segment
Error compiling project sources

I don't recognise the 'ccKdJqWc' name, so I assume it's mangled.

Jim

Purely a wild guess: try closing all Arduino IDE windows and then start the Arduino IDE. This will clear the cache, which would solve the problem if it was related to a corrupted cache.

Many thanks @pert.

I've cleared out 'Arduino Builds' and 'Users ... Temp' many times, but this one's proving quite sticky. It happens in both Arduino 1.8.9 and Visual Micro (Visual Studio 2019 latest).

The program needs 20K + static RAM, so I'm only trying to get it working for Arduino Due (compiles OK), Arduino MKR 1010 (this problem) and Adafruit Feather M0 (compiles OK).

I've tinkered with various '#ifdef' includes to try to narrow it down by changing which of my pieces is included, with no luck so far, and Google doesn't have much about this one.

Does your sketch contain a .S file?

@pert

Nope, just one .ino, and about 60 each of .h/.cpp.

Are you using any libraries?

@pert Thanks.

I'm 'potentially' using a few libraries like WiFiNINA, WFi101, SImpleDHT.

Sorry for the delay, I've been fruitlessly experimenting with various #ifdefs to exclude some classes, and in this way I think I'm also currently excluding all user-installed libraries.

The problem persists for the MKR1010 in both the Arduino IDE (latest) and VS2019 + Visual Micro (latest).

In VS:

Severity Code Description Project File Line Suppression State
Error Error: unaligned opcodes detected in executable segment C:\Users\Jim\AppData\Local\Temp\ccKxhFGz.s -1

BUT I'm getting two other compilation errors which I suspect are the cause:

Severity Code Description Project File Line Suppression State
Error (active) E0035 #error directive: "Unable to determine type definition of intptr_t" IoTJackAC1 C:\Users\Jim\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\sys\_intsup.h 68
Severity Code Description Project File Line Suppression State
Error (active) E0035 #error directive: "Unable to determine type definition of int32_t" IoTJackAC1 C:\Users\Jim\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\sys\_intsup.h 75

I'm not directly including '_intsup.h'.

The .s file referred to in the first error isn't present in the Temp folder.

Thanks,
Jim

And sometime I get this one - also a mystery to me:

Severity	Code	Description	Project	File	Line	Suppression State
Error (active)	E0338	more than one instance of overloaded function "itoa" has 'C' linkage	IoTJackAC1	C:\Users\Jim\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.3\cores\arduino\itoa.h	27

After a lot of work including/excluding various of my classes, and methods within classes, this seems to be due to a compiler oddity in a relatively straightforward utility method.

There are two switch statements based on the same 'int' variable, the order of which doesn't logically matter. If I comment out either switch or reverse the order, the error goes away.

One of the switch statements had 5 cases together (and no others), and I also found that splitting these cases into groups of 3 and 2 stopped the error.

There were no compiler errors or warnings for this method.

This was only a problem with MKR boards, and never occurred with Arduino Due, Feather M0, Sparkfun RedBoard Turbo or ESP32 DevKit V1, all of which compile, link and run OK.

Hope this helps someone, sometime!
Jim