Avoid recompiling with nonzero processing using a forked development model

I use Mercurial to develop a fairly large C ++ project that takes about 30 minutes to build from scratch (while incremental builds are very fast).

Usually I try to implement each new function in a new branch (using "hg clone"), and I can have several new functions developed during the day, and it quickly becomes very boring to wait for a new branch of functions to be built in.

Are there any recipes for reusing object files from other already built branches?

PS in git there are branch names in one repository that make it possible to reuse existing object files for the build system, however, I prefer a simpler model of individual branches of Mercury ...

+4
source share
6 answers

My Localbranch extension was developed in part around this use case. It uses one working directory, but I think it is simpler than git. This is essentially a mechanism for supporting multiple repository clones in a single working directory, where only one is active at a given time.

+2
source

I suggest using ccache as a way to speed up the compilation of (basically) the same tree code. Principle of operation:

  • You determine the location that will be used as the cache (and the maximum cache size) using the CCACHE_DIR environment CCACHE_DIR
  • Your compiler must be installed in ccache ${CC} or ccache ${CXX}

ccache accepts the output of ${CC} -E and compilation flags and uses this as the basis for its hash. As long as the compiler flags, source file and headers are not changed, the file object will be taken out of the cache, saving valuable compilation time.

Note that this method speeds up compilation of any source file that ultimately creates the same hash. If you share source files by project, ccache also processes them.

If you are already using distcc and want to use it with ccache, set the CCACHE_PREFIX environment CCACHE_PREFIX to distcc .

Using ccache accelerated the assembly of the source tree by about ten times.

+4
source

An easy way to speed up assembly is to use the local "assembly directory" on your disk. So you can check this directory and start building. The first time it takes all the time, but after that it (hopefully) only rebuilds the files in which the source code has changed.

+3
source

Words, I missed your PS where you don't like having multiple named branches in the same repo and that you prefer individual clones .. sorry for that.

I also have several large C ++ projects, and the workflow for working with clones doesn't work very well for me. Firstly, I had to close the Vim session and then reopen (many of the same) files as soon as I created the clone. Secondly, as you said, a lot of code needs to be recompiled without need. Thirdly, I have to keep track of where I pushed and pulled out - it becomes confusing when you start a new function, and then get distracted by a new one. Before you know this, you have many clones and are not sure which ones you need to drop to your primary.

You definitely do not want to use the named branches (as I am sure you know) to handle this, since they are pretty constant.

You need bookmarks: https://www.mercurial-scm.org/wiki/BookmarksExtension

Bookmarks allow you to create light (and otherwise anonymous) branches for each function, simplifying the names of goals in your repo. Typically, these chapters do not have a title, and you will need to look at the output of "hg log" or use some kind of graphical tool to find the version numbers for the tip of your branch. With bookmarks, you can call them descriptive names, such as "my-cool-feature" or "bugfix-392."

If you like the idea of โ€‹โ€‹bookmarks, I also recommend my own extension called "tasks": http://bitbucket.org/alu/hgtasks . This extension works like bookmarks, but adds a few more features. It allows you to create functional branches (now called tasks) and suppress the repulsion of incomplete tasks. This is useful when you have several function branches at once. You may not be ready to click your "my-cool-feature" task, but "bugfix-392" is ready to go. Because tasks track a set of change sets (and not just one set of tips), there are some things you can do with tasks that you cannot bookmark. The following is an example workflow: http://x.zpuppet.org/2009/03/09/mercurial-tasks-extension/ . Strike>

+2
source

Mercurial also has local branches named, see the hg branch command.

If you insist on using the hg clone for branched development, I think you could try creating a link to the folder (shortcut under windows) in your repo to the obj shared folder. This will work with the hg clone, but I'm not sure if your build tool will pick it up.

Otherwise, you will probably save all your repositories in one folder - just put your obj folder (it should not be under source control in any case, imo). Use relative paths to reference it.

+1
source

Warning word: many .o (or equivalent) symbol tables contain the full path name of the source file. If this other file changes (or if the path does not appear in the new directory), you may run into weirdness when debugging.

0
source

All Articles