13

I'm using make to build a large project on OSX Lion. The scripts worked fine on OSX up to Snow Leopard, but now it fails.

What happens is that after building certain modules, I get an error similar to the following:

touch my.app/Contents/Resources
touch my.app
make[2]: write error
make[1]: *** [all] Error 1
make: *** [all] Error 1

If I then type make again it resumes from where it fails and builds successfully (until it hits another such error). It always happens for the same two modules of the project, and I can't for the life of me work out why.

Please let me know if there's any more information I can provide that would be helpful.

1st Update

Here's the output of make -d:

...
     Finished prerequisites of target file `DesktopConn.o'.
     Prerequisite `DesktopConn.cxx' is older than target `DesktopConn.o'.
    No need to remake target `DesktopConn.o'.
    Considering target file `List.o'.
     Looking for an implicit rule for `List.o'.
     Trying pattern rule with stem `List'.
     Trying implicit prerequisite `/bin/sh: line 1:  6733 Segmentation fault: 11  make all
Reaping losing child 0x102d0ae70 PID 6471 
make[1]: *** [all] Error 1
Removing child 0x102d0ae70 PID 6471 from chain.
Reaping losing child 0x10560ee20 PID 6342 
make: *** [all] Error 1
Removing child 0x10560ee20 PID 6342 from chain.

I've put the whole make -d output (extremely verbose) on pastebin.

2nd Update

I've uploaded the Makefile too.

3rd Update

I've downloaded the source for make, built from source on my machine. It still fails at the same point. I've also tried using the make binary from Snow Leopard.

Community
  • 1
  • 1
fredley
  • 32,953
  • 42
  • 145
  • 236
  • 1
    try `make -d`, it will enable the debug output of make. Or if your Makefile has a verbose mode (like `VERBOSE=1`), try that too, to see which command provokes the error. – Gui13 Nov 15 '11 at 10:11
  • Have you tried running `touch my.app` yourself? It might not be a problem with make. – Marcelo Cantos Nov 15 '11 at 10:13
  • @MarceloCantos Yes, it's fine, and from the above output that doesn't seem to be the problem. – fredley Nov 15 '11 at 10:26
  • Since it builds successfully upon re-making, have you tried `make --keep-going`? (`--ignore-errors` is probably undesirable) No satisfaction from knowing what's wrong, but it might work fine. – blahdiblah Jan 11 '12 at 00:43
  • @blahdiblah That doesn't help (I'd be surprised if it did, as make is segfaulting!) – fredley Jan 11 '12 at 10:00
  • 1
    Is make itself segfaulting, or is a subcommand the problem? Since it looks like an implicit prereq is at fault, what's the output of `make -p`? – blahdiblah Jan 11 '12 at 22:05
  • make itself is segfaulting. It does so immediately after finishing compilation of a module (expected behaviour: move out of current directory and into another to compile that module). – fredley Jan 12 '12 at 10:15
  • Try running make with `make -j 1` to stop it executing in parallel, just in case the problem is a race condition somewhere... clutching at straws perhaps but worth a try! – snim2 Jan 16 '12 at 22:06
  • I'd say the missing ingredient for getting a solution is your Makefile, paste bin that and I'll be happy to debug it. – synthesizerpatel Jan 16 '12 at 22:06
  • The pastebin link for your Makefile doesn't work. – eriktous Jan 18 '12 at 14:15
  • Did you ever break down and debug `make`? I've broken various pieces of the GNU toolchain over time, but never `make` so I'm a little envious. :) – Kyle Jones Jan 25 '12 at 03:31
  • No. Work on fixing it has been suspended for a while since it's going to be a long time until we need to build on Lion. We still build on Leopard at the moment! – fredley Jan 25 '12 at 09:59

2 Answers2

1

Try taking the SEGV at face value. make is either dereferencing an out-of-bounds pointer, or trying to write memory somewhere out of bounds, or it is trying to extend the stack beyond the process stack size limit. There's nothing you can do about the first two without debugging GNU make, but you can increase the stack limit. Using bash:

ulimit -s hard

raises the soft limit to the hard limit, giving you as much stack space as possible. Try it and see if make can run to completion without crashing.

Kyle Jones
  • 5,492
  • 1
  • 21
  • 30
0

llvm is the default compiler in Lion, I believe, but was not in previous versions you mentioned. Occam's razor says try it using:

CC=gcc make

Edit: Found this, which I think is related. See answer #1, 3 edits: here. It refers to building Ruby, but I think the underlying issue is the same. It's possible you'll need to download a different version of GCC if this is the issue.

Community
  • 1
  • 1
Rab
  • 2,806
  • 2
  • 16
  • 20
  • 1
    I have tried using gcc and clang, neither fix the problem, it's something in `make` itself, not the compiler it's using. – fredley Jan 17 '12 at 09:56