Skip to content

Archive compiled core and use on subsequent compilations #213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Mar 20, 2017

Conversation

facchinm
Copy link
Member

@facchinm facchinm commented Feb 9, 2017

Very WIP but almost working good

}

func GetCoreArchivePath(fqbnToUnderscore string) string {
return os.TempDir() + "/core_" + fqbnToUnderscore + ".a"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a good idea to put these files directly in the tempdir? Also, shouldn't these files be cleaned up at some point (e.g. when the IDE exits)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only a temporary way to store them 😄 A proper db (or folder structure) is surely the way to go

@@ -258,6 +289,24 @@ func nonEmptyString(s string) bool {
return s != constants.EMPTY_STRING
}

func CheckIfRecompileIsAvoidable(corePath string, archiveFile string) bool {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this not also archive and check the build options used? It's a bit of a corner case, but if the platform.txt is now changed (or any other source of compile options), the old .a file is still used. I guess this could happen when updating the core through the boards manager. The sketch itself is rebuilt ("Build options changed, rebuilding all..." or something like that), but I think this is bypassed by this archiving.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, the timestamps are only extracted from core subfolder, while they should be applied to the whole folder. I'm pushing another commit to fix this

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this interplay with referenced cores? E.g. when a platform has a platform.txt but does not contain the actual core, but instead references (e.g.) the arduino core? I believe compilation options could then come from either platform?

In general, I wonder if this can be more thoroughly covered? Ideally, a compiled core would keep a file (like the .d files for each .o file) that shows what files were used to create the .a file, so these could all be checked for modifications, as well as noting the compile options / build properties used to build the core. Even more general would be to log the complete compiler commands executed to build a .a file, and then compare that to the commands that would be executed on a subsequent run, and only use them if the commands are exactly equal? This is a bit similar to the caching for include detection that is now used.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some tricky details, indeed, which should be tackled in a saner way. The inter-dependencies problem is one (and could be solved by tracking also the parent core). Note that the current builder does not wipe the environment if platform.txt changes (because it's not part of the .d dance). Tracking dependencies via .d files is really handy for libraries or mutable code, while the core is not really mutable (in Create it's even "static"). To be even more conservative, one could track all the modification dates on all core folders and wipe if even one file is newer than the precompiled core (this could be time consuming in case of slow disks or lots of cores).

@@ -70,6 +70,7 @@ func (s *SetupBuildProperties) Run(ctx *types.Context) error {
buildProperties[constants.BUILD_PROPERTIES_RUNTIME_PLATFORM_PATH] = targetPlatform.Folder
buildProperties[constants.BUILD_PROPERTIES_RUNTIME_HARDWARE_PATH] = filepath.Join(targetPlatform.Folder, "..")
buildProperties[constants.BUILD_PROPERTIES_RUNTIME_IDE_VERSION] = ctx.ArduinoAPIVersion
buildProperties[constants.BUILD_PROPERTIES_FQBN] = strings.Replace(ctx.FQBN, ":", "_", -1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this replacement done? If it is so that it can occur in a filename, I think the property name should reflect that and the FQBN property should just contain the original, unmodified fqbn, to prevent confusion.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, buildProperties[constants.BUILD_PROPERTIES_FQBN] should contain the actual fqbn, however I'm going to apply the substitution later to make sure the filename is valid on all OS

@PaulStoffregen
Copy link

Is there an @ArduinoBot build? I'd like to give this a try here, but I don't have the Go stuff set up.

On Teensy, I make much more use of defining things from boards.txt and the custom menus, which are then referenced by platform.txt. The entire core library really needs to be rebuilt when those change. I know most 3rd party boards just copy platform.txt with only minimal changes, so maybe this is a corner case... but I'm pretty concerned about core.a not rebuilding...

@facchinm
Copy link
Member Author

facchinm commented Feb 10, 2017

The bot is still in a coma, I'm pasting here the link for the artefacts
http://downloads.arduino.cc/PR/arduino-builder/arduino-builder-213.zip

@facchinm
Copy link
Member Author

@PaulStoffregen if the custom menus selection changes the fqbn (like mega:cpu=2560) it won't use the archived core, otherwise it will (at the moment)

@facchinm
Copy link
Member Author

@ArduinoBot build this please.

cmaglie and others added 11 commits March 1, 2017 15:07
Signed-off-by: Cristian Maglie <c.maglie@arduino.cc>
Some tests require that the core object files are recreated,
but it doesn't happen when the prebuilt core is used.
Wipe the workspace if any of the core files has changed; this solves a long-standing
problem for core developers about changes in platform.txt requiring a manual wipe to be correctly applied
Signed-off-by: Cristian Maglie <c.maglie@arduino.cc>
Signed-off-by: Cristian Maglie <c.maglie@arduino.cc>
Signed-off-by: Cristian Maglie <c.maglie@arduino.cc>
…tion

Signed-off-by: Cristian Maglie <c.maglie@arduino.cc>
Now that caching is optional old tests may run as before (without
the need to cleanup cache).

Signed-off-by: Cristian Maglie <c.maglie@arduino.cc>
@cmaglie cmaglie force-pushed the archiveCompiledCore branch from b99aae5 to 4591ba3 Compare March 3, 2017 13:59
Build options json is not the optimal way to discover if something has changed in the build. Commit arduino@19751fe#diff-f796a16acff0c78b88ffe6618745edc6R67 enforces the check and also wipes if the core has changed "in place".

Wiping more often gives better confidence that the actual compliation results reflect the backing storage situation.
@ArduinoBot
Copy link
Contributor

✅ Build completed.

⬇️ Build URL: http://downloads.arduino.cc/PR/arduino-builder/arduino-builder-213.zip

ℹ️ To test this build:

  1. Replace arduino-builder binary (you can find it where you installed the IDE) with the provided one

@cmaglie cmaglie merged commit 059c5f8 into arduino:master Mar 20, 2017
@cmaglie cmaglie deleted the archiveCompiledCore branch January 11, 2018 10:09
@cmaglie cmaglie added this to the 1.3.25 milestone Sep 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants