1

Is there any quick guideline for when it is safe to ask make to do its work with multiple jobs?

I ask because, in the past, it usually seemed to work fine for me but recently it was persistently causing troubles.

I did a "make -j8" (use eight jobs to speed the building) and kept getting:

".so file format not recognized" on one of the shared libraries that was being generated. This was even after cleaning the shared library out (make clean successfully did remove it, but once I also did the unnecessary step of manually removing that) and starting again.

After seeing the problem I'm now leery to use multiple jobs at all. Is there some way to tell ahead of time if multiple jobs can or can't be used with make?

4

1 回答 1

0

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.

于 2013-09-12T13:37:00.040 回答