Build failure on mingw
v0.11.0-rc0-1630-g51cc2e7 fails to build on mingw with gcc version 3.4.5 (mingw32 special) and GNU Make version 3.79.1.
gcc -I/home/sh/vm/qemu/v0.11.0-rc0-1630-g51cc2e7/slirp -Wold-style-definition -I. -I/home/sh/vm/qemu/v0.11.0-rc0-1630-g51cc2e7 -U_FORTIFY_SOURCE -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -m32 -DWIN32_LEAN_AND_MEAN -DWINVER=0x501
-MMD -MP -MT audio/mixeng.o -O2 -g -c -o audio/mixeng.o audio/mixeng.c
gcc -I/home/sh/vm/qemu/v0.11.0-rc0-1630-g51cc2e7/slirp -Wold-style-definition -I. -I/home/sh/vm/qemu/v0.11.0-rc0-1630-g51cc2e7 -U_FORTIFY_SOURCE -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -m32 -DWIN32_LEAN_AND_MEAN -DWINVER=0x501
-MMD -MP -MT -I/mingw/include/SDL -D_GNU_SOURCE=1 -Dmain=SDL_main -O2 -g -c -o audio/sdlaudio.o audio/sdlaudio.c audio/sdlaudio.c:24:17: warning: SDL.h: No such file or directoryaudio/sdlaudio.c:25:24: warning: SDL_thread.h: No such file or directory
Notice the missing parameter for "-MT" with sdlaudio, but not mixeng. Before commit 02d5467e9f43dac05f04999e387108ca4c8ba140 "-MT" was followed by "-U_FORTIFY_SOURCE", but now it's "-I/mingw/include/SDL" which gets swallowed.
- Sebastian
Quoted 27 lines · malc
Quoted 25 lines · Sebastian Herbszt
v0.11.0-rc0-1630-g51cc2e7 fails to build on mingw with gcc version 3.4.5 (mingw32 special)
and GNU Make version 3.79.1.gcc -I/home/sh/vm/qemu/v0.11.0-rc0-1630-g51cc2e7/slirp -Wold-style-definition
(quoted diff) +0
-7-I. -I/home/sh/vm/qemu/v0.11.0-rc0-1630-g51cc2e7 -U_FORTIFY_SOURCE -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -m32 -DWIN32_LEAN_AND_MEAN -DWINVER=0x501 -MMD -MP -MT audio/mixeng.o -O2 -g -c -o audio/mixeng.o audio/mixeng.cgcc -I/home/sh/vm/qemu/v0.11.0-rc0-1630-g51cc2e7/slirp -Wold-style-definition
(quoted diff) +0
-7-I. -I/home/sh/vm/qemu/v0.11.0-rc0-1630-g51cc2e7 -U_FORTIFY_SOURCE -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -m32 -DWIN32_LEAN_AND_MEAN -DWINVER=0x501 -MMD -MP -MT -I/mingw/include/SDL -D_GNU_SOURCE=1 -Dmain=SDL_main -O2 -g -c -o
audio/sdlaudio.oaudio/sdlaudio.caudio/sdlaudio.c:24:17: warning:SDL.h: No such file or directoryaudio/sdlaudio.c:25:24: warning:SDL_thread.h: No such file or directory
Quoted 8 lines
Quoted 5 lines
Notice the missing parameter for "-MT" with sdlaudio, but not mixeng. Before commit
02d5467e9f43dac05f04999e387108ca4c8ba140"-MT" was followed by "-U_FORTIFY_SOURCE", but now it's "-I/mingw/include/SDL"
which gets swallowed.Neither is/was correct, does escaping $@ in rules make (i.e. \$@) have any effect?
Changing it to \$@ makes it compile again:
$ grep MMD rules.mak QEMU_CFLAGS += -MMD -MP -MT \$@
gcc -I/home/sh/vm/qemu/v0.11.0-rc0-1630-g51cc2e7-nox-fixed/slirp -Wold-style-definition -I. -I/home/sh/vm/qemu/v0.11.0-rc0-1630-g51cc2e7-nox-fixed -U_FORTIFY_SOURCE -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -m32 -DWIN32_LEAN_AND_MEAN -DWINVER=0x501 -MMD -MP -MT audio/mixeng.o -O2 -g -c -o audio/mixeng.o audio/mixeng.c
gcc -I/home/sh/vm/qemu/v0.11.0-rc0-1630-g51cc2e7-nox-fixed/slirp -Wold-style-definition -I. -I/home/sh/vm/qemu/v0.11.0-rc0-1630-g51cc2e7-nox-fixed -U_FORTIFY_SOURCE -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -m32 -DWIN32_LEAN_AND_MEAN
-DWINVER=0x501 -MMD -MP -MT -I/mingw/include/SDL -D_GNU_SOURCE=1
-Dmain=SDL_main -O2 -g -c -o audio/sdlaudio.o audio/sdlaudio.c
gcc -I/home/sh/vm/qemu/v0.11.0-rc0-1630-g51cc2e7-nox-fixed/slirp -Wold-style-definition -I. -I/home/sh/vm/qemu/v0.11.0-rc0-1630-g51cc2e7-nox-fixed -U_FORTIFY_SOURCE -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -m32 -DWIN32_LEAN_AND_MEAN -DWINVER=0x501 -MMD -MP -MT audio/winwaveaudio.o -O2 -g -c
-o audio/winwaveaudio.o audio/winwaveaudio.c
The only difference i notice are more spaces:
-MMD -MP -MT -I/mingw/include/SDL
vs.
-MMD -MP -MT -I/mingw/include/SDL
- Sebastian
Quoted 2 lines · Sebastian Herbszt
Quoted 1 line · malc
On Sat, 14 Nov 2009, Sebastian Herbszt wrote:
[..snip..]
Quoted 7 lines
Quoted 3 lines
Neither is/was correct, does escaping $@ in rules make (i.e. \$@) have any effect?
Changing it to \$@ makes it compile again:
$ grep MMD rules.mak QEMU_CFLAGS += -MMD -MP -MT \$@
[..snip..]
Quoted 9 lines
gcc -I/home/sh/vm/qemu/v0.11.0-rc0-1630-g51cc2e7-nox-fixed/slirp
(quoted diff) +0
-8-Wold-style-definition -I. -I/home/sh/vm/qemu/v0.11.0-rc0-1630-g51cc2e7-nox-fixed -U_FORTIFY_SOURCE -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -m32 -DWIN32_LEAN_AND_MEAN -DWINVER=0x501 -MMD -MP -MT -I/mingw/include/SDL -D_GNU_SOURCE=1 -Dmain=SDL_main -O2 -g -c -o audio/sdlaudio.o audio/sdlaudio.c
[..snip..]
Quoted 6 lines
The only difference i notice are more spaces:
-MMD -MP -MT -I/mingw/include/SDL
vs.
-MMD -MP -MT -I/mingw/include/SDL
Makefile has this:
sdl.o audio/sdlaudio.o sdl_zoom.o baum.o: QEMU_CFLAGS += $(SDL_CFLAGS)
Which, i guess, doesn't play well with expansion of $@ in rules.mak. I wonder what changes you will see by adding following to the rules.mak.
QEMU_CFLAGS := $(QEMU_CFLAGS) -MMD -MP -MT $@
Signature · 1 line
mailto:[email protected]
Quoted 8 lines · malc
Makefilehas this:sdl.o
audio/sdlaudio.osdl_zoom.o baum.o:QEMU_CFLAGS+= $(SDL_CFLAGS)Which, i guess, doesn't play well with expansion of $@ in rules.mak. I wonder what changes you will see by adding following to the rules.mak.
QEMU_CFLAGS:= $(QEMU_CFLAGS) -MMD -MP -MT $@
$ grep MMD rules.mak QEMU_CFLAGS := $(QEMU_CFLAGS) -MMD -MP -MT $@
gcc -I/home/sh/vm/qemu/v0.11.0-rc0-1630-g51cc2e7-nox-fixed/slirp -Wold-style-definition -I. -I/home/sh/vm/qemu/v0.11.0-rc0-1630-g51cc2e7-nox-fixed -U_FORTIFY_SOURCE -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -m32 -DWIN32_LEAN_AND_MEAN -DWINVER=0x501
-MMD -MP -MT -O2 -g -c -o audio/mixeng.o audio/mixeng.c
gcc -I/home/sh/vm/qemu/v0.11.0-rc0-1630-g51cc2e7-nox-fixed/slirp -Wold-style-definition -I. -I/home/sh/vm/qemu/v0.11.0-rc0-1630-g51cc2e7-nox-fixed -U_FORTIFY_SOURCE -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -m32 -DWIN32_LEAN_AND_MEAN -DWINVER=0x501
-MMD -MP -MT -I/mingw/include/SDL -D_GNU_SOURCE=1 -Dmain=SDL_main -O2 -g -c -o audio/sdlaudio.o audio/sdlaudio.caudio/sdlaudio.c:24:17: warning: SDL.h: No such file or directory
- Sebastian
PATCH 1/1 Fix build for mingw32 on windows ($@ in macro)
Make using mingw32 on windows does not preserve $@ in macros when they are modified using this pattern:
target: macro += something
This behaviour results in an error when QEMU_CFLAGS containing "-MMD -MP -MT $@" is modified for compilation of source files which use SDL: $@ will expand to nothing, -MT no longer has the correct argument (it will take the next one from the command line) and the build will fail or run with a wrong command line.
The problem is fixed by using a new macro QEMU_DGFLAGS which is not modified by a target rule.
--- rules.mak | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)
rules.mak +5 -4
@@ -11,16 +11,17 @@ MAKEFLAGS += -rR %.m: %.mak: -QEMU_CFLAGS += -MMD -MP -MT $@ +# Flags for dependency generation +QEMU_DGFLAGS += -MMD -MP -MT $@ %.o: %.c $(GENERATED_HEADERS) - $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) -c -o $@ $<," CC $(TARGET_DIR)$@") + $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," CC $(TARGET_DIR)$@") %.o: %.S - $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) -c -o $@ $<," AS $(TARGET_DIR)$@") + $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," AS $(TARGET_DIR)$@") %.o: %.m - $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) -c -o $@ $<," OBJC $(TARGET_DIR)$@") + $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," OBJC $(TARGET_DIR)$@") LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(1) $(ARLIBS_BEGIN) $(ARLIBS) $(ARLIBS_END) $(LIBS)," LINK $(TARGET_DIR)$@")
Signature · 1 line
1.5.6.5
[Qemu-devel] Re: [PATCH] Fix build for mingw32 on windows ($@ in macro)
Quoted 10 lines · Stefan Weil
Make using mingw32 on windows does not preserve $@ in macros when they are modified using this pattern:
target: macro += somethingThis behaviour results in an error when
QEMU_CFLAGScontaining "-MMD -MP -MT $@" is modified for compilation of source files which use SDL: $@ will expand to nothing, -MT no longer has the correct argument (it will take the next one from the command line) and the build will fail or run with a wrong command line.
Quoted 4 lines
The problem is fixed by using a new macro
QEMU_DGFLAGSwhich is not modified by a target rule.Signed-off-by Stefan Weil <[email protected]>
[Qemu-devel] Re: [PATCH] Fix build for mingw32 on windows ($@ in macro)
In reply to Stefan WeilQuoted 4 lines · Stefan Weil
Make using mingw32 on windows does not preserve $@ in macros when they are modified using this pattern:
target: macro += something
Quoted 8 lines
This behaviour results in an error when
QEMU_CFLAGScontaining "-MMD -MP -MT $@" is modified for compilation of source files which use SDL: $@ will expand to nothing, -MT no longer has the correct argument (it will take the next one from the command line) and the build will fail or run with a wrong command line.The problem is fixed by using a new macro
QEMU_DGFLAGSwhich is not modified by a target rule.
Why not just stuff `-MMD -MP -MT $@' into the rules?
[..snip..]
Signature · 1 line
mailto:[email protected]
Re: [Qemu-devel] [PATCH] Fix build for mingw32 on windows ($@ in macro)
In reply to Stefan WeilQuoted 3 lines · Stefan Weil
Make using mingw32 on windows does not preserve $@ in macros when they are modified using this pattern:
target: macro += something
Is it not using GNU Make, or is it some ancient version? ("make --version" shows the version, if it's GNU Make).
-- Jamie
[Qemu-devel] Re: [PATCH] Fix build for mingw32 on windows ($@ in macro)
In reply to malcQuoted 12 lines · malc
Quoted 10 lines · Stefan Weil
Make using mingw32 on windows does not preserve $@ in macros when they are modified using this pattern:
target: macro += somethingThis behaviour results in an error when
QEMU_CFLAGScontaining "-MMD -MP -MT $@" is modified for compilation of source files which use SDL: $@ will expand to nothing, -MT no longer has the correct argument (it will take the next one from the command line) and the build will fail or run with a wrong command line.
Quoted 6 lines
Quoted 2 lines
The problem is fixed by using a new macro
QEMU_DGFLAGSwhich is not modified by a target rule.Why not just stuff `-MMD -MP -MT $@' into the rules?
[..snip..]
As in most cases, there are many ways to do something...
During my test, I had the dependency flags in the rules.
I decided to use a macro to allow people running make without dependency generation (make QEMU_DGFLAGS=).
Stefan
Re: [Qemu-devel] [PATCH] Fix build for mingw32 on windows ($@ in macro)
In reply to Jamie LokierQuoted 7 lines · Jamie Lokier
Quoted 4 lines · Stefan Weil
Make using mingw32 on windows does not preserve $@ in macros when they are modified using this pattern:
target: macro += something
Quoted 6 lines
Is it not using GNU Make, or is it some ancient version? ("make --version" shows the version, if it's GNU Make).
-- Jamie
GNU make 3.79.1 (2004)
-- Stefan
Re: [Qemu-devel] [PATCH] Fix build for mingw32 on windows ($@ in macro)
Quoted 8 lines · Stefan Weil
Quoted 7 lines · Jamie Lokier
Quoted 4 lines · Stefan Weil
Make using mingw32 on windows does not preserve $@ in macros when they are modified using this pattern:
target: macro += something
Quoted 6 lines
Quoted 4 lines
Is it not using GNU Make, or is it some ancient version? ("make --version" shows the version, if it's GNU Make).
-- Jamie
GNU make 3.79.1 (2004)
3.79.1 is ancient, the GNU version being released in June 2000 :-)
The behaviour of
target: macro += something
appears to be fixed in GNU make 3.80, which was released in October 2002. (I've just tested 3.79.1 and 3.80 from GNU's ftp site).
Is there not an update for mingw32 for a more recent make?
-- Jamie
Re: [Qemu-devel] [PATCH] Fix build for mingw32 on windows ($@ in macro)
In reply to Jamie LokierQuoted 9 lines · Jamie Lokier
Quoted 3 lines · Stefan Weil
Make using mingw32 on windows does not preserve $@ in macros when they are modified using this pattern:
target: macro += somethingIs it not using GNU Make, or is it some ancient version? ("make --version" shows the version, if it's GNU Make).
-- Jamie
$ make --version GNU Make version 3.79.1, by Richard Stallman and Roland McGrath. Built for i686-pc-msys
- Sebastian
Re: [Qemu-devel] [PATCH] Fix build for mingw32 on windows ($@ in macro)
In reply to Jamie LokierQuoted 18 lines · Jamie Lokier
Quoted 7 lines · Stefan Weil
Quoted 6 lines · Jamie Lokier
Quoted 4 lines · Stefan Weil
Make using mingw32 on windows does not preserve $@ in macros when they are modified using this pattern:
target: macro += somethingQuoted 5 lines
Quoted 4 lines
Is it not using GNU Make, or is it some ancient version? ("make --version" shows the version, if it's GNU Make).
-- Jamie
GNU make 3.79.1 (2004)
3.79.1 is ancient, the GNU version being released in June 2000 :-)
The behaviour of
Quoted 8 lines
target: macro += something
appears to be fixed in GNU make 3.80, which was released in October 2002. (I've just tested 3.79.1 and 3.80 from GNU's ftp site).
Is there not an update for mingw32 for a more recent make?
-- Jamie
Of course it's ancient, but from the timestamp (if it was correct) I'd estimate that it takes 3 to 4 years to get a GNU release to windows :-)
MSYS make 3.81-2 is available (and there is also a MinGW make, a make using MSVCRT). The MinGW update tool does not update MSYS make automatically (at least in my installation), and I rarely compile using mingw32 on windows (cross compilation from linux works better). So keeping MinGW/MSYS up-to-date is a little difficult.
-- Stefan