reticulatedpines / magiclantern_simplified

A Git based version of Magic Lantern, for those unwilling or unable to work using Mercurial. The vast majority of branches have been removed, with those thought to be important brought in individually and merged.
GNU General Public License v2.0
142 stars 47 forks source link

Modules can race to build object files #112

Open reticulatedpines opened 10 months ago

reticulatedpines commented 10 months ago

Both mlv_lite and silent modules list lossless.o as a dependency. mlv_lite/Makefile has it like this:

MODULE_OBJS=mlv_lite.o ../mlv_rec/mlv.o ../silent/lossless.o

This means if lossless.o is first built during silent module, and mlv_lite happens to build later, mlv_lite will overwrite lossless.o, making the timestamp later than silent.mo. This leads to successive makes in the modules dir building silent module twice, which is at least wasteful. Maybe this causes real problems, too?

mlv_rec/mlv.o should suffer from the same problem.

It's not clear to me exactly how MODULE_OBJS leads to the build occuring at all, possibly implicit make rules, .o from .c of same name?

I'd guess the fix is to correctly list the shared dependency. With that done, parallel builds should know lossless.o must be built before either, and it should only get built once.

reticulatedpines commented 10 months ago

This pattern also means that multiple modules export the same symbols. E.g. because mlv_lite.o links in lossless.o, all the externally visible lossless.o symbols are provided by mlv_lite.mo and silent.mo. This complicates module autoloading and increases module size for no reason.

Maybe we want to split out the shared functions into another, non-user-visible module, and autoload that if either of silent or mlv_lite are enabled? Maybe we don't need to link against lossless.o for mlv_lite, if we have module autoloading?