magiclantern_simplified icon indicating copy to clipboard operation
magiclantern_simplified copied to clipboard

Modules can race to build object files

Open reticulatedpines opened this issue 1 year ago • 1 comments

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 avatar Aug 19 '23 23:08 reticulatedpines

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?

reticulatedpines avatar Aug 21 '23 00:08 reticulatedpines