Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sometimes mrblib.o is not merged into libmruby.a #136

Closed
iwadon opened this issue May 15, 2012 · 11 comments
Closed

sometimes mrblib.o is not merged into libmruby.a #136

iwadon opened this issue May 15, 2012 · 11 comments

Comments

@iwadon
Copy link
Contributor

iwadon commented May 15, 2012

When libmruby.a and mrblib.o have the same timestamp, it may skip that Make merges mrblib.o to libmruby.a.
https://gist.github.com/2700367

@iwadon
Copy link
Contributor Author

iwadon commented May 15, 2012

I am using GNU Make 3.81 on Mac OS X 10.7.4.

@matz
Copy link
Member

matz commented May 15, 2012

I am not sure but "comparison is always true" warning may prevent mrblib compilation.
I removed the warning in a3a9d13, please see if it works.

@iwadon
Copy link
Contributor Author

iwadon commented May 15, 2012

Thank you for removing the warning.
I updated the log: https://gist.github.com/2700367

@matz
Copy link
Member

matz commented May 15, 2012

I cannot reproduce the problem on the Linux box. I have no idea why make ignores creating mrblib.o and archiving it on your platform. Hmm.

@iwadon
Copy link
Contributor Author

iwadon commented May 15, 2012

Thank you very much for trying to reproduce this problem.
As the makeshift patch, I added .PHONY: $(LIBR) to mrblib/Makefile.
It works fine for me. But it always remakes libmruby.a.

@bovi
Copy link
Member

bovi commented May 15, 2012

I can reproduce it here too. Since the mrblib/Makefile changed (10 hour ago) it also doesn't build correctly anymore:

gcc -o ../../bin/mruby -g -O3 ../../src/../tools/mruby/mruby.o ../../lib/libmruby.a  -lm
Undefined symbols for architecture x86_64:
  "_mrb_init_mrblib", referenced from:
      _mrb_init_core in libmruby.a(init.o)
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[1]: *** [../../bin/mruby] Error 1
make: *** [all] Error 2

As iwado this is fixing it for me too:

diff --git a/mrblib/Makefile b/mrblib/Makefile
index 7129623..12ee23d 100644
--- a/mrblib/Makefile
+++ b/mrblib/Makefile
@@ -45,6 +45,8 @@ endif
 .PHONY : all
 all : $(LIBR)

+.PHONY : $(LIBR)
+
 # update libmruby.a
 $(LIBR) : $(MLIB)
        $(AR) r $(LIBR) $(MLIB)

@matz
Copy link
Member

matz commented May 15, 2012

I don't want phony that forces libmruby.a to be updated.

What I don't understand is the reason why "make mrblib" don't update libmruby.a.
Top-level make run "make src" then "make mrblib", so the timestamp of mrblib.o should be newer than libmruby.a. Is anyone able to guess the situation?

@iwadon
Copy link
Contributor Author

iwadon commented May 16, 2012

GNU make on Mac OS X uses low resolution timestamp, maybe.

http://www.doof.me.uk/2012/04/21/portable-high-resolution-timestamps-from-stat/

Mac OS X can use stat.st_mtimespec not stat.st_mtim.
But GNU make checks stat.st_mtim only for high resolution timestamp checking.
(see "whether to use high resolution file timestamps" in configure.in)

I am sorry that I have no idea for this issue.

@iwadon
Copy link
Contributor Author

iwadon commented May 16, 2012

This is the problem depending on the file system. GNU make is not guilty.

The date resolution of HFS+ and other more filesystems is 1 second.
http://en.wikipedia.org/wiki/HFS_Plus
http://en.wikipedia.org/wiki/Ext3

If the difference of the time when libmruby.a and mrblib.o are made becomes less than 1 second and the timestamps of both files are same, this problem will occur.

@mitchblank
Copy link
Contributor

Yeah, I've just hit this too.. I'm building on a fast OS/X machine with an SSD and I hit it almost every build. I've been doing:

$ make -j12 ; touch mrblib/mrblib.o ; make -j12

to get around it for now.

I think having multiple make rules updating "libmruby.a" is just never going to work 100% safely.. just too complicated since its effectively a circular dependency (libmruby.a -> mrbc -> libmruby.a) which is hard to get make to deal with correctly.

I think the best solution would be to just split this into two libraries (libmruby_nolib, libmruby) Doing the "ar" is fast, so doing that part twice won't affect the compile speed. This also will be needed when crosscompiling support is added (important for the embedded space!) since then you'll have to build the engine twice: once for the host processor to build the lib, and a second time for the target processor. Might as well start getting the distinction in place.

@matz
Copy link
Member

matz commented May 16, 2012

OK, splitting libmruby_nolib.a and libmruby.a sounds like a good idea.

@matz matz closed this as completed in 3e3a8c1 May 17, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants