Issue #12179 has been reported by Kazuki Yamaguchi.

----------------------------------------
Bug #12179: Build failure due to VPATH expansion
https://bugs.ruby-lang.org/issues/12179

* Author: Kazuki Yamaguchi
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: 
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
On my environment (GNU Make 4.1), I can reproduce in this way:

~~~sh
cd /tmp
svn co http://svn.ruby-lang.org/repos/ruby/trunk ruby-src
cd ruby-src
autoconf && ./configure
mkdir -p /tmp/.ext/.timestamp/
touch /tmp/.ext/.timestamp/.RUBYARCHDIR.-.-test-.-.fatal.time
make V=1
~~~

results in:

~~~
...
make[2]: Entering directory '/tmp/ruby-src/ext/-test-/fatal'
rm -f ../../../.ext/x86_64-linux/-test-/fatal/rb_fatal.so
gcc -shared -o ../../../.ext/x86_64-linux/-test-/fatal/rb_fatal.so rb_fatal.o -L. -L../../.. -L. -fstack-protector -rdynamic -Wl,-export-dynamic    -lpthread -lgmp -ldl -lcrypt -lm   -lc
/usr/bin/ld: cannot open output file ../../../.ext/x86_64-linux/-test-/fatal/rb_fatal.so: No such file or directory
collect2: error: ld returned 1 exit status
Makefile:260: recipe for target '../../../.ext/x86_64-linux/-test-/fatal/rb_fatal.so' failed
make[2]: *** [../../../.ext/x86_64-linux/-test-/fatal/rb_fatal.so] Error 1
make[2]: Leaving directory '/tmp/ruby-src/ext/-test-/fatal'
exts.mk:88: recipe for target 'ext/-test-/fatal/all' failed
...
~~~

This error happens because `/tmp/ruby-src/.ext/x86_64-linux/-test-/fatal` is not properly created.


This is because of the VPATH set in `ext/-test-/fatal/Makefile`:

~~~
srcdir = $(top_srcdir)/ext/-test-/fatal
topdir = ../../..
hdrdir = $(top_srcdir)/include
arch_hdrdir = $(extout)/include/$(arch)
VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby

extout = $(topdir)/.ext
TIMESTAMP_DIR = $(extout)/.timestamp

$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.fatal.time:
	$(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
	$(Q) $(TOUCH) $@

$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.fatal.time
	$(ECHO) linking shared-object -test-/fatal/$(DLLIB)
	...
~~~

`$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.fatal.time` target should create the directory prior to linking, but it doesn't work.
Since the Makefile has VPATH, make wrongly finds `$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.fatal.time` at `$(hdrdir)/ruby`, that is `/tmp/.ext/.timestamp/.RUBYARCHDIR.-.-test-.-.fatal.time`.




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>