This all depends on how well your dependencies are laid out in your Makefile. You have to be very careful and about specifying every dependency and not just rely on line order and coincidence.
I've had situations where the output of make -j2
worked just fine but make -j4
didn't, because one item was getting compiled before it should, but I hadn't been careful enough in specifying that. Similarly, I've had make -j4
appear to work, only to find that certain parts were compiling with stale code, meaning the final product would be different than I expected. I had to make sure to make clean
before any build before I found the dependency issue that allowed me to safely use make -j4
at will again.
Let me answer each of your questions:
- Is there any quick guideline for when it is safe to ask make to do
its work with multiple jobs?
Not in my book. If your dependencies are entirely correct, you are good to go. Otherwise, be careful.
- Is there some way to tell ahead of time if multiple jobs can or can't
be used with make?
I think the answer is the same as the previous item. I usually assume that it will work until I know it doesn't, and then I try to find the problem. That might not be a safe way to work, however. If you are noticing unexpected results, use make clean
and then make
without using multiple jobs, and see if that resolves the issue. If it does, you can reasonably assume your Makefile's dependencies are not correct.
You also have an implied question about the .so file format not recognized
issue. That sounds like the same issue. Specifically, perhaps the .so is getting built with the wrong dependencies, or the wrong .so is getting pulled in before the correct one is found or built, or the .so is an incomplete state when it is being called upon.