We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4379

Summary: fix parallel build with slibtool
Product: SDL Reporter: orbea
Component: buildAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: orbea
Version: 2.0.9   
Hardware: x86_64   
OS: Linux   
Attachments: Makefile.in: Add a missing build directory dependency.
Makefile.in: Depend on a file instead of directory.

Description orbea 2018-11-13 14:51:50 UTC
Created attachment 3487 [details]
Makefile.in: Add a missing build directory dependency.

I am having a parallel build problem with -j3 or higher using the autotools build and slibtool instead of GNU libtool. Basically slibtool is faster than GNU libtool and it will start working before mkdir starts or finishes creating the build/ directory.  As "objects = build" I found I can add "$(objects)" as a dependency to the "Makefile" build target and this ensures the directory exists when its needed.

I've attached a patch that fixes this, can this be applied in the master too?
Comment 1 Sam Lantinga 2018-11-13 16:11:02 UTC
Looking at the dependency graph, I don't think this guarantees that the build directory will be created before the compiling begins. I think you're just getting lucky with this new dependency set, the same way I was with the old one. Is that right?
Comment 2 orbea 2018-11-13 16:18:45 UTC
I can't discount that possibility, my experience with Makefiles is not that great. Just that SDL2 now builds here with both GNU libtool and slibtool using my normal -j6 consistently.

Any working alternative solutions would be fine too.
Comment 3 orbea 2018-12-06 22:51:29 UTC
Created attachment 3537 [details]
Makefile.in: Depend on a file instead of directory.
Comment 4 orbea 2018-12-06 22:52:12 UTC
Hi Sam,

I took another look at this and made an alternative solution which depends on a build.tag file instead of the build directory. I ran several builds at -j6 with both libtool and slibtool and was unable to reproduce any build errors. What do you think about this solution?

Here is some documentation on the solution.

https://stackoverflow.com/questions/4440500/depending-on-directories-in-make/4614143#4614143

The patch should be attached.
Comment 5 Sam Lantinga 2018-12-08 19:23:22 UTC
Okay, this is fixed. I changed your patch so that the sentinel file was in the build subdirectory so that if somebody removed the build directory it would be recreated. I also changed it so that Makefile didn't depend on it, so that if somebody removed the build directory the Makefile wouldn't be regenerated. Instead I made it so each object depended on it, which seems to work well:

$ make -j
/bin/sh ../build-scripts/updaterev.sh
/bin/sh ../build-scripts/mkinstalldirs build
mkdir build
touch build/.created
  CC     build/SDL_assert.lo
  CC     build/SDL_dataqueue.lo
  CC     build/SDL_error.lo
  CC     build/SDL_log.lo

The change is committed now for you to try out:
https://hg.libsdl.org/SDL/rev/99d8b18acf8a

Thanks!
Comment 6 orbea 2018-12-08 19:38:56 UTC
Thanks! I tested your solution and it works consistently here with -j6. :)
Comment 7 Sam Lantinga 2018-12-10 05:20:17 UTC
Great! :)