jeremysrand/Apple2GSBuildPipeline

Can this build process use -jN to use all cores on computer?

Closed this issue · 3 comments

Is there a way to cause the compilation step to use all the cores in my computer? Orca/C is very slow and my project is very big with 89 source files and rebuilding it even on a modern machine is still quite slow.

I just noticed that in a different project, I could type make -j16 and the full rebuild process just screamed by in a few seconds. However, I cannot do that with this for some reason (I'm not a GNU make expert).

I am running Linux and GoldenGate, and everything works, so I'm happy, but am I missing something to accelerate the process?

I think I have broken parallel make by not doing sub make correctly. I think changing the lines which say:

all:
        $(MKDIR) $(OBJDIR) $(GENDIR) $(TARGETDIR)
        @make -f $(firstword $(MAKEFILE_LIST)) gen
        @make -f $(firstword $(MAKEFILE_LIST)) build

To:

all:
        $(MKDIR) $(OBJDIR) $(GENDIR) $(TARGETDIR)
        @$(MAKE) -f $(firstword $(MAKEFILE_LIST)) gen
        @$(MAKE) -f $(firstword $(MAKEFILE_LIST)) build

in make/head.mk, it may fix your problem. Specifically, these two lines in the rule are changing an explicit "make" command to the "$(MAKE)" variable. That should allow the parent make to see that it is doing a sub make and the job server should be available to that sub make. Also, if your make binary happens to not be called "make", this should also ensure that it works. So, it is the right thing to do no matter what.

I have done some testing on my Mac and I don't see any problems with this change but it hard for me to confirm that parallelism is correctly enabled in the sub make. I think it should but I would appreciate your feedback on that.

You can also try to force the -j argument for the build target (which is where all the compiles happen so what you care about) by changing the rule from:

@$(MAKE) -f $(firstword $(MAKEFILE_LIST)) build

to:

@$(MAKE) -j16 -f $(firstword $(MAKEFILE_LIST)) build

Now, this is the wrong thing to do longterm because it breaks the job server connection between the parent make and the sub make. But you should find that you do get parallel builds if you force it this way.

The next thing will be whether I have all of the right dependencies to ensure that parallel builds are stable. But that may be the next issue raised...

Hope this helps and if so, let me know and I will update the project accordingly.

Woohoo! That was it! Your first suggestion totally fixed the parallel build and now I can rebuild everything in about 6 seconds with -j16 😊👏 I didn't have to force the -j argument, it just worked.

This is running Linux, just for the record.

Great news! I will look at committing a fix for this and issuing a release update soon. And it is good to hear that the makefiles still work on Linux. I don’t actively test regularly but it is nice to have some cross platform support.