@@ -89,60 +89,132 @@ Global ``.h`` file: ``LowWatermark.ino.globals.h``
89
89
90
90
#endif
91
91
92
- Aggressive Caching of `` core.a ``
92
+ Aggressively Cache Compiled core
93
93
================================
94
94
95
- The feature “Aggressive Caching of core.a” refers to sharing a single
96
- copy of ``core.a `` across all Arduino IDE Sketch windows. This feature
97
- is on by default. ``core.a `` is an archive file containing the compiled
98
- objects of ``./core/esp8266/* ``. Created after your 1ST successful
99
- compilation. All other open sketch builds use this shared file. When you
100
- close all Arduino IDE windows, the core archive file is deleted.
101
-
102
- Without mediation, using global defines or compiler command-line options
103
- could lead to bad builds when the “Aggressively cache compiled core”
104
- feature is enabled. When ``#define `` changes require rebuilding
105
- ``core.a `` and multiple Sketches are open, they can no longer reliably
106
- share one cached ``core.a ``. In a simple case: The 1st Sketch to be
107
- built has its version of ``core.a `` cached. Other sketches will use this
108
- cached version for their builds.
109
-
110
- When the “Aggressively cache compiled core” feature is enabled and a
95
+ This feature appeared with the release of Arduino IDE 1.8.2. The feature
96
+ “Aggressively Cache Compiled core” refers to sharing a single copy of
97
+ ``core.a `` across all Arduino IDE Sketch windows. This feature is on by
98
+ default. ``core.a `` is an archive file containing the compiled objects
99
+ of ``./core/esp8266/* ``. Created after your 1ST successful compilation.
100
+ All other open sketch builds use this shared file. When you close all
101
+ Arduino IDE windows, the core archive file is deleted.
102
+
103
+ This feature is not compatible with using global defines or compiler
104
+ command-line options. Without mediation, bad builds could result, when
105
+ left enabled. When ``#define `` changes require rebuilding ``core.a `` and
106
+ multiple Sketches are open, they can no longer reliably share one cached
107
+ ``core.a ``. In a simple case: The 1st Sketch to be built has its version
108
+ of ``core.a `` cached. Other sketches will use this cached version for
109
+ their builds.
110
+
111
+ There are two solutions to this issue: 1. Turn off the “Aggressively
112
+ Cache Compiled core” feature, by setting ``compiler.cache_core=false ``.
113
+ 2. Rely on the not ideal fail-safe, aggressive cache workaround built
114
+ into the script.
115
+
116
+ Using “compiler.cache_core=false”
117
+ ---------------------------------
118
+
119
+ There are two ways to turn off the “Aggressively Cache Compiled core”
120
+ feature: This can be done with the Arduino IDE command-line or a text
121
+ editor.
122
+
123
+ Using the Arduino IDE command-line from a system command line, enter the
124
+ following:
125
+
126
+ ::
127
+
128
+ arduino --pref compiler.cache_core=false --save-prefs
129
+
130
+ For the text editor, you need to find the location of
131
+ ``preferences.txt ``. From the Arduino IDE, go to *File->Preferences *.
132
+ Make note of the path to ``prefereces.txt ``. You *cannot * edit the file
133
+ while the Arduino IDE is running. Close all Arduino IDE windows and edit
134
+ the file ``preferences.txt ``. Change ``compiler.cache_core=true `` to
135
+ ``compiler.cache_core=false `` and save. Then each sketch will maintain
136
+ its *own * copy of ``core.a `` built with the customization expressed by
137
+ their respective ``build.opt `` file.
138
+
139
+ The “workaround”
140
+ ----------------
141
+
142
+ When the “Aggressively Cache Compiled core” feature is enabled and the
111
143
global define file is detected, a workaround will turn on and stay on.
112
144
When you switch between Sketch windows, core will be recompiled and the
113
145
cache updated. The workaround logic is reset when Arduino IDE is
114
- completely shutdown and restarted. Some operating systems are better at
115
- cleaning up their temp space than others at reboot after a crash. At
116
- least for Windows®, you may need to manually delete the Arduino temp
117
- files and directories after a crash. Otherwise, the workaround logic may
118
- be left on.
146
+ completely shutdown and restarted.
147
+
148
+ The workaround is not perfect. These issues may be of concern: 1. Dirty
149
+ temp space. Arduino build cache files left over from a previous run or
150
+ boot. 2. Arduino command-line options: \* override default
151
+ preferences.txt file. \* override a preference, specifically
152
+ ``compiler.cache_core ``. 3. Multiple versions of the Arduino IDE running
153
+
154
+ **Dirty temp space **
155
+
156
+ A minor concern, the workaround is always on. Not an issue for build
157
+ accuracy, but ``core.a `` maybe rebuild more often than necessary.
158
+
159
+ Some operating systems are better at cleaning up their temp space than
160
+ others at reboot after a crash. At least for Windows®, you may need to
161
+ manually delete the Arduino temp files and directories after a crash.
162
+ Otherwise, the workaround logic may be left on. There is no harm in the
163
+ workaround being stuck on, the build will be correct; however, the core
164
+ files will occasionally be recompiled when not needed.
119
165
120
166
For some Windows® systems the temp directory can be found near
121
167
``C:\Users\<user id>\AppData\Local\Temp\arduino* ``. Note ``AppData `` is
122
168
a hidden directory. For help with this do an Internet search on
123
169
``windows disk cleanup ``. Or, type ``disk cleanup `` in the Windows®
124
170
taskbar search box.
125
171
172
+ With Linux, this problem could occur after an Arduino IDE crash. The
173
+ problem would be cleared after a reboot. Or you can manually cleanup the
174
+ ``/tmp/ `` directory before restarting the Arduino IDE.
175
+
176
+ **Arduino command-line option overrides **
177
+
178
+ The script needs to know the working value of ``compiler.cache_core ``
179
+ that the Arduino IDE uses when building. This script can learn the state
180
+ through documented locations; however, the Arduino IDE has two
181
+ command-line options that can alter the results the Arduino IDE uses
182
+ internally. And, the Arduino IDE does not provide a means for a script
183
+ to learn the override value.
184
+
185
+ These two command-line options are the problem:
186
+
187
+ ::
188
+
189
+ ./arduino --preferences-file other-preferences.txt
190
+ ./arduino --pref compiler.cache_core=false
191
+
192
+ Hints for discovering the value of ``compiler.cache_core `` use can be
193
+ provided by specifying ``mkbuildoptglobals.extra_flags=... `` in
194
+ ``platform.local.txt ``.
195
+
196
+ Examples of hints:
197
+
198
+ ::
199
+
200
+ mkbuildoptglobals.extra_flags=--preferences_sketch # assume file preferences.txt in the sketch folder
201
+ mkbuildoptglobals.extra_flags=--preferences_sketch pref.txt # is relative to the sketch folder
202
+ mkbuildoptglobals.extra_flags=--no_cache_core
203
+ mkbuildoptglobals.extra_flags=--cache_core
204
+ mkbuildoptglobals.extra_flags=--preferences_file other-preferences.txt # relative to IDE or full path
205
+
206
+ **Multiple versions of the Arduino IDE running **
207
+
126
208
You can run multiple Arduino IDE windows as long as you run one version
127
209
of the Arduino IDE at a time. When testing different versions,
128
210
completely exit one before starting the next version. For example,
129
211
Arduino IDE 1.8.19 and Arduino IDE 2.0 work with different temp and
130
212
build paths. With this combination, the workaround logic sometimes fails
131
- to enable. At the time of this writing, when Arduino IDE 2.0 rc5 exits,
132
- it leaves the temp space dirty. This keeps the workaround active the
133
- next time the IDE is started. If this is an issue, manually delete the
134
- temp files.
135
-
136
- If you think your workflow performance would benefit from keeping a per
137
- Sketch copy of ``core.a ``, you can turn off the “Aggressively cache
138
- compiled core” feature. You need to find the location of
139
- ``preferences.txt ``. From the Arduino IDE, go to *File->Preferences *.
140
- Make note of the path to ``prefereces.txt ``. You cannot edit the file
141
- while the Arduino IDE is running. Close all Arduino IDE windows and edit
142
- the file ``preferences.txt ``. Change ``compiler.cache_core=true `` to
143
- ``compiler.cache_core=false `` and save. Then each sketch will maintain
144
- its *own * copy of ``core.a `` built with the customization expressed by
145
- their respective ``build.opt `` file.
213
+ to enable.
214
+
215
+ At the time of this writing, when Arduino IDE 2.0 rc5 exits, it leaves
216
+ the temp space dirty. This keeps the workaround active the next time the
217
+ IDE is started. If this is an issue, manually delete the temp files.
146
218
147
219
Other build confusion
148
220
=====================
0 commit comments