LGVLDemo recompiles libraries every time

I am an experienced embedded programmer, but I am new to Arduino and have just got an Arduino GIGA R1 WiFi and GIGA Display Shield bundle.
In my Windows 10 laptop I have installed:
Arduino IDE 2.3.2 (64 bit)
Arduino Mbed OS GIGA Boards 4.1.4
Arduino_GigaDisplayTouch 1.0.1
lvgl by kisvegabor 9.1.0
I select Examples/Arduino_H7_Video/LGVLDemo
I press save so it is stored locally on my C-drive (an SSD)
I can compile and upload and the example works fine on the display - great!
Without changing anything in the example code successive compile or upload always compiles all libraries. At least it looks like that becasuse the verbose compile output shows it runs arm-none-eabi-gcc or arm-none-eabi-g++ for all files every time (and it takes about 9 minutes every time).
What shall I do to avoid that libraries are not rebuilt every time ?

That is normal.

Give Linux a try, you can load a demo without changing your system. Mint Cinnamon would probably the best for you.

Hi @hakan_dicander.

Arduino IDE caches the compiled core and library objects. After that, the cache is used if applicable.

If you enable verbose compilation output in the Arduino IDE preferences (File > Preferences), on the first compilation you will see things like this in the output:

[...]

Compiling library "Arduino_H7_Video"
"C:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\7-2017q4/bin/arm-none-eabi-g++" -c -Wall -Wextra -g3 -nostdlib "@C:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed_giga\\4.1.5\\variants\\GIGA/defines.txt" "@C:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed_giga\\4.1.5\\variants\\GIGA/cxxflags.txt" -MMD -mcpu=cortex-m7 -mfloat-abi=softfp -mfpu=fpv5-d16 -DARDUINO=10607 -DARDUINO_GIGA -DARDUINO_ARCH_MBED_GIGA -DARDUINO_ARCH_MBED -DARDUINO_LIBRARY_DISCOVERY_PHASE=0 "-IC:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed_giga\\4.1.5\\cores\\arduino" "-IC:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed_giga\\4.1.5\\variants\\GIGA" "-IC:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed_giga\\4.1.5\\libraries\\Arduino_H7_Video\\src" "-Ic:\\Users\\per\\Documents\\Arduino\\libraries\\Arduino_GigaDisplayTouch\\src" "-IC:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed_giga\\4.1.5\\libraries\\Wire" "-Ic:\\Users\\per\\Documents\\Arduino\\libraries\\lvgl\\src" "-IC:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed_giga\\4.1.5\\libraries\\Portenta_SDRAM\\src" "-IC:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed_giga\\4.1.5\\libraries\\ea_malloc" -DCM4_BINARY_START=0x60000000 -DCM4_BINARY_END=0x60040000 -DCM4_RAM_END=0x60080000 "-IC:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed_giga\\4.1.5\\cores\\arduino/api/deprecated" "-IC:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed_giga\\4.1.5\\cores\\arduino/api/deprecated-avr-comp" "-iprefixC:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed_giga\\4.1.5\\cores\\arduino" "@C:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed_giga\\4.1.5\\variants\\GIGA/../GIGA/includes.txt" "C:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed_giga\\4.1.5\\libraries\\Arduino_H7_Video\\src\\Arduino_H7_Video.cpp" -o "C:\\Users\\per\\AppData\\Local\\Temp\\arduino\\sketches\\84B99407149D83FF34DBE35096C8142B\\libraries\\Arduino_H7_Video\\Arduino_H7_Video.cpp.o"

[...]

On subsequent compilations, you will instead see this:

[...]

Compiling library "Arduino_H7_Video"
Using previously compiled file: C:\Users\per\AppData\Local\Temp\arduino\sketches\84B99407149D83FF34DBE35096C8142B\libraries\Arduino_H7_Video\video_modes.c.o

[...]

Do you not see that in your output?


The sketch code is recompiled on every compilation (after all, why would you compile again if it hadn't changed?), and there are quite a few processes required to discover the sketch program's library dependencies and link everything together. So you will still see the use of the GCC toolchain during every compilation.

Even though the use of the cache does significantly reduce the duration of subsequent compilations, they do still take some time, especially with a very complex program like this one and when running on a computer with lower specs.

However, a 9 minute compilation duration is quite exceptional (we would expect it to be on the order of tens of seconds on any reasonable computer).

When people report exceptionally slow compilations, we often find that it was caused by security/antivirus software on the user's computer. Arduino IDE creates a large number of short duration processes during the compilation. Some antiviruses do "real-time"/"on access" scanning of processes. The process is blocked until the scan is completed. The added time for each scan is quite significant in relation to the duration of the process, so the total impact of the many scans is a great increase in the length of the compilation.

As an experiment, you can try :warning: TEMPORARILY :warning: disabling the security software/antivirus on your computer for a single compilation to see if the problem goes away:

  1. Disable the security software/antivirus software.
  2. Compile the sketch, just as you did before.
  3. Wait for the compilation to finish.
  4. Immediately enable the security software/antivirus software again.

If the problem doesn't occur when you tried a compilation while the security software was disabled, you will need to adjust the settings of your antivirus to put the appropriate file, folder, or process on the "allowlist" so it doesn't interfere with compilation.

:warning: Please be cautious about working with the security software disabled. This is only about temporarily disabling it for a quick test. If you don't feel comfortable doing that, fine. You can try going straight to configuring the security software so that it does not interfere with the Arduino software.

Thanks for replies.

Before I issued my topic , I did scan other relating topics and saw previous answers that compiled files should be cached. That was also why I enabled verbose compiling and carefully inspected the compile output. I have prepared an output file of a subsequent compile where this can be seen, but as a new user I am not allowed to upload it.

For the LGVLDemo the compile output have never given the text: "Using previously compiled file", so there is definately something fishy here. One line does however say "Using precompiled core", but never anything regaring libraries. I have tried to uninstall and delete .arduinoIDE and .../AppData/Local/Arduino15, and then install the IDE only for my user (first install I made available for all users). I have also tried a reboot, but no difference.

Regarding the speed I have also seen those posts and googled on how to deactivate things in Windows Defender, as well as trying with Defender disabled. Currently I have disabled all Arduino-related folders for real time scanning, and I have also disabled all Arduino-related processes both the Arduino IDE and also all the gcc and g++ programs. CPU is about 50% loaded during the build. My laptop is have i7-5500U CPU @ 2.40GHz with 16 GB RAM and SSD. It is more than 6 years old so I don't expect it to be as fast as a modern desktop. I don't think 9 minutes to build all large libraries is an issue, if it is only done once. A new empty sketch with no libraries uses precompiled core and it takes about 20 seconds to build, even if it could be faster it is acceptable.

The problem is that there is no caching of libraries going on, either there is an issue with the particular LGVLDemo or it is some other problem. Is it sensitive in which order the libraries are installed ?

Do you have non-ASCII or other potentially problematic characters in your Windows username or elsewhere in the path under which the libraries are installed?

Are you using Microsoft OneDrive?

My real name is "Håkan", and that is the Windows user name, it is also the administrative account on the computer.
So yes, there are non-ASCII characters in the paths.
I don't find a way to change the name of the Håkan user folder or account, so if you have any tip on what to do it would be great.

Everything should be local on the C-drive.
There is a OneDrive, but I avoid using it, my Documents folder is mapped to C drive. I now checked, and there are no arduino folders or files on OneDrive.

I found something regarding compatibility issues of lgvl library so I downgraded the lgvl to 8.3.11, no improvment, all libraries always recompiled.

I see. Obviously any valid path should be supported, but unfortunately there is a recently discovered bug that causes the library caching system to not work if they are installed under a path that contains non-ASCII characters:

Please try this:

  1. Select File > Preferences... from the Arduino IDE menus.
    The "Preferences" dialog will open.
  2. Take note of the path shown in the "Sketchbook location" field of the dialog.
  3. Change the path in the "Sketchbook location" field of the dialog so any convenient path that only contains ASCII characters.
  4. Click the "OK" button.
    The "Preferences" dialog will close.
  5. Copy the contents of the folder at the path you noted in step (2) of the instructions to the folder at the path you set at step (3) of the instructions.

Now try compiling the sketch again, just as you did before. It is expected that the first compilation will be a full one, but this time the subsequent compilations should use the cache.

Thanks

Unfortunately to only move the Sketchbook location did not work for me. There are more things that the IDE stores based on the user name, like Users\Håkan.arduinoIDE, Users\Håkan\AppData\Local\Arduino15, and perhaps also files in Users\Håkan\Local\Temp.

I tried to map Documents to an pure-ASCII directory, delete everything and reinstall. The sketchbook directory then ended up in the non-ASCII directory, but the directories above are still recreated in the Håkan path, and cached files are not used.

I created a new user with pure ASCII in the name and installed Arduino IDE there. That works, cached files are used and then time drops from 9 to 1 minutes.

So it is definately the non-ASCII that is the problem. Is there some file or environment variables that can be configured to define all folder paths that the IDE shall use ?

I'm sorry to hear that. I feared this might be the case, but did a quick experiment and found that it was sufficient for me to change only the path under which the library was installed in order to cause caching to start working.

However, when I looked further, I discovered there is actually a bug that caused the compiled library objects to be cached under the normal location on my computer (which has only ASCII characters, i.e., C:\Users\per\AppData\Local\Temp\arduino\sketches\4E2908E4C1148D6298CFEB982686794F\libraries) rather than the custom location I had configured (which has non-ASCII characters, i.e., C:\Håkan\sketches\4E2908E4C1148D6298CFEB982686794F\libraries). That threw off the results of my experiment.

You can configure the location of Users\Håkan\AppData\Local\Arduino15 and I'd be happy to provide instructions for doing that.

However, I don't think it will help at all because I found that the caching is still broken even if only the path under which the cache is stored (e.g., Users\Håkan\Local\Temp) contains non-ASCII characters.

Work is in progress now to make that cache path configurable, but the version of Arduino IDE you are using doesn't have such a configuration capability so there is no way for you to easily fix the problem through Arduino IDE configuration currently. The only way to do it would be to change the location of the system temporary folder in the Windows configuration but I don't know how or if such a thing could be done.