Backport #6424
closedmkmf generates incorrect Makefile
Description
The code to reproduce the bug:
--- begin of extconf.rb ---
require 'mkmf'
create_makefile('test')
--- end of extconf.rb ---
--- begin of test.c ---
/* empty ruby module */
--- end of test.c ---
The steps to reproduce and error log:
$ ruby extconf.rb
$ make -j2 install DESTDIR=/tmp MAKEDIRS="sleep 1; echo do_mkdir; mkdir -p"
sleep 1; echo do_mkdir; mkdir -p /tmp/usr/local/lib/site_ruby/1.8/x86_64-linux
gcc -I. -I/usr/lib/ruby/1.8/x86_64-linux -I/usr/lib/ruby/1.8/x86_64-linux -I. -D_FORTIFY_SOURCE=2 -fPIC -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -Wall -fno-strict-aliasing -g -g -O2 -fPIC -c test.c
gcc -shared -o test.so test.o -L. -L/tmp/usr/lib -L. -Wl,-z,relro -rdynamic -Wl,-export-dynamic -lruby1.8 -lpthread -lrt -ldl -lcrypt -lm -lc
/usr/bin/install -c -m 0755 test.so /tmp/usr/local/lib/site_ruby/1.8/x86_64-linux
/usr/bin/install: cannot create regular file `/tmp/usr/local/lib/site_ruby/1.8/x86_64-linux': No such file or directory
make: *** [/tmp/usr/local/lib/site_ruby/1.8/x86_64-linux/test.so] Error 1
make: *** Waiting for unfinished jobs....
do_mkdir
Expected: no error shall occur. The $(MAKEDIRS) mkdir command must be executed alwais before installing *.so file.
Note: I've specified MAKEDIRS command with 'sleep' only to reproduce the concurrency bug.
Originally it occurred on busy Debian build-server, running make -j2 install
(in 2 parallel threads).
The cause of the bug is incorrect dependency of 'install-so' in Makefile:
--- part of generated Makefile ---
install: install-so install-rb
install-so: $(RUBYARCHDIR)
install-so: $(RUBYARCHDIR)/$(DLLIB)
$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
...
$(RUBYARCHDIR):
$(MAKEDIRS) $@
--- end of part of generated Makefile ---
Updated by jeremyevans0 (Jeremy Evans) over 4 years ago
- Tracker changed from Bug to Backport
- Project changed from Ruby 1.8 to Backport187
- Status changed from Open to Closed
- ruby -v deleted (
ruby 1.8.7 (2012-02-08 patchlevel 358) [x86_64-linux])