Skip to contentSkip to conversation

docker: Don't use eval trick on Makefile

PATCH Applied Eduardo Habkost 3 participants 5 messages Jun 6, 2016 – Jun 8, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 docker: Don't use eval trick on Makefile

The eval trick for defining DOCKER_SRC_COPY doesn't do anything useful, as DOCKER_SRC_COPY is immediately expanded just after it is defined, and CUR_TIME is already defined using ":=". Simply define it using ":=" so it is evaluated only once.

The eval trick was also triggering an weird error on Travis builds:
qemu/tests/docker/Makefile.include:34: *** unterminated variable reference. Stop.

The issue is not easily reproducible (maybe it's a bug in some versions of Make), but it is avoided if removing the eval trick.

---
 tests/docker/Makefile.include | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tests/docker/Makefile.include +1 -2
index 2fd2ca3..134dc6f 100644
@@ -28,8 +28,7 @@ make-archive-maybe = $(if $(wildcard $1/*), \
 		"  ARCHIVE $(notdir $2)"))
 
 CUR_TIME := $(shell date +%Y-%m-%d-%H.%M.%S.$$$$)
-# Makes the definition constant after the first expansion
-DOCKER_SRC_COPY = $(eval DOCKER_SRC_COPY := docker-src.$(CUR_TIME))$(DOCKER_SRC_COPY)
+DOCKER_SRC_COPY := docker-src.$(CUR_TIME)
 
 $(DOCKER_SRC_COPY):
 	@mkdir $@
Signature · 1 line
2.5.5
Applied
#1 lore raw
Quoted 33 lines · Eduardo Habkost

The eval trick for defining DOCKER_SRC_COPY doesn't do anything useful, as DOCKER_SRC_COPY is immediately expanded just after it is defined, and CUR_TIME is already defined using ":=". Simply define it using ":=" so it is evaluated only once.

The eval trick was also triggering an weird error on Travis builds:
qemu/tests/docker/Makefile.include:34: *** unterminated variable reference. Stop.

The issue is not easily reproducible (maybe it's a bug in some versions of Make), but it is avoided if removing the eval trick.

---
 tests/docker/Makefile.include | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tests/docker/Makefile.include +1 -2
index 2fd2ca3..134dc6f 100644
@@ -28,8 +28,7 @@ make-archive-maybe = $(if $(wildcard $1/*), \
 		"  ARCHIVE $(notdir $2)"))
 
 CUR_TIME := $(shell date +%Y-%m-%d-%H.%M.%S.$$$$)
-# Makes the definition constant after the first expansion
-DOCKER_SRC_COPY = $(eval DOCKER_SRC_COPY := docker-src.$(CUR_TIME))$(DOCKER_SRC_COPY)
+DOCKER_SRC_COPY := docker-src.$(CUR_TIME)
 
 $(DOCKER_SRC_COPY):
 	@mkdir $@
Signature · 1 line
2.5.5

Applied, thanks.

Fam

#2 lore raw
Quoted 29 lines · Fam Zheng
Quoted 28 lines · Eduardo Habkost

The eval trick for defining DOCKER_SRC_COPY doesn't do anything useful, as DOCKER_SRC_COPY is immediately expanded just after it is defined, and CUR_TIME is already defined using ":=". Simply define it using ":=" so it is evaluated only once.

The eval trick was also triggering an weird error on Travis builds:
qemu/tests/docker/Makefile.include:34: *** unterminated variable reference. Stop.

The issue is not easily reproducible (maybe it's a bug in some versions of Make), but it is avoided if removing the eval trick.

---
 tests/docker/Makefile.include | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tests/docker/Makefile.include +1 -2
index 2fd2ca3..134dc6f 100644
@@ -28,8 +28,7 @@ make-archive-maybe = $(if $(wildcard $1/*), \
              "  ARCHIVE $(notdir $2)"))
 
 CUR_TIME := $(shell date +%Y-%m-%d-%H.%M.%S.$$$$)
-# Makes the definition constant after the first expansion
-DOCKER_SRC_COPY = $(eval DOCKER_SRC_COPY := docker-src.$(CUR_TIME))$(DOCKER_SRC_COPY)
+DOCKER_SRC_COPY := docker-src.$(CUR_TIME)
 
Quoted 7 lines
Quoted 5 lines
tests/docker/Makefile.include +0 -1
 $(DOCKER_SRC_COPY):
      @mkdir $@
--

2.5.5

Applied, thanks.

Hi; I'd like to apply this direct to master, because one of my build test machines hits this error intermittently, and so without the fix I can't reliably process any other pull requests.

thanks
-- PMM

#3 lore raw
Quoted 10 lines · Peter Maydell
Quoted 9 lines · Fam Zheng
Quoted 8 lines · Eduardo Habkost

The eval trick for defining DOCKER_SRC_COPY doesn't do anything useful, as DOCKER_SRC_COPY is immediately expanded just after it is defined, and CUR_TIME is already defined using ":=". Simply define it using ":=" so it is evaluated only once.

The eval trick was also triggering an weird error on Travis builds:
qemu/tests/docker/Makefile.include:34: *** unterminated variable reference. Stop.

Quoted 6 lines
Quoted 2 lines
Quoted 2 lines

The issue is not easily reproducible (maybe it's a bug in some versions of Make), but it is avoided if removing the eval trick.

Hi; I'd like to apply this direct to master, because one of my build test machines hits this error intermittently, and so without the fix I can't reliably process any other pull requests.

Now applied, thanks.

-- PMM

#4 lore raw
Quoted 11 lines · Peter Maydell
Quoted 10 lines · Peter Maydell
Quoted 9 lines · Fam Zheng
Quoted 8 lines · Eduardo Habkost

The eval trick for defining DOCKER_SRC_COPY doesn't do anything useful, as DOCKER_SRC_COPY is immediately expanded just after it is defined, and CUR_TIME is already defined using ":=". Simply define it using ":=" so it is evaluated only once.

The eval trick was also triggering an weird error on Travis builds:
qemu/tests/docker/Makefile.include:34: *** unterminated variable reference. Stop.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines

The issue is not easily reproducible (maybe it's a bug in some versions of Make), but it is avoided if removing the eval trick.

Hi; I'd like to apply this direct to master, because one of my build test machines hits this error intermittently, and so without the fix I can't reliably process any other pull requests.

Now applied, thanks.

No problem, sorry for the trouble!

Fam