ekam icon indicating copy to clipboard operation
ekam copied to clipboard

Ekam takes unnecessarily long for multi-step builds (almost all builds)

Open jyn514 opened this issue 2 years ago • 1 comments

Imagine a simple C++ project with main.c++ and helper.c++. One possible execution for Ekam is:

  1. Compile main.c++ -> main.o
  2. Attempt to link main.o -> main (since it has a main symbol). Fail, since helper.o isn't yet compiled.
  3. Compile helper.c++ -> helper.o. Notice that the new object file has symbols that were missing in step 2.
  4. Link main.o + helper.o -> main

Step 2 is unnecessary and slows down the build. This problem becomes worse as more steps are added (e.g. if some .c++ or .h files are generated by capnp or another tool).

One possible way to fix this is to allow .ekam-rule files to specify a priority, so that .capnp files are built before .c files, and .c before .o.

jyn514 avatar Oct 13 '21 19:10 jyn514

A simple priority doesn't work since to build a .capnp file you first need to build the capnp compiler tool which is itself compiled and linked from C++ source code. But with knowledge of the dependency tree from a previous run, we could be smarter about running things in the expected dependency order.

I'm not entirely convinced that Ekam actually wastes a whole lot of time on premature linking, though. The linker fails pretty quickly if symbols are missing. It would be nice to quantify this problem before spending time on it.

kentonv avatar Oct 15 '21 19:10 kentonv