* [Qemu-devel] CMSG_SPACE() causing compile time error on Mac OS X @ 2016-01-17 22:23 Programmingkid 2016-01-17 23:22 ` Paolo Bonzini 2016-01-18 9:58 ` Daniel P. Berrange 0 siblings, 2 replies; 15+ messages in thread From: Programmingkid @ 2016-01-17 22:23 UTC (permalink / raw) To: Peter Maydell; +Cc: qemu-devel qemu-devel I was wondering if you had problems compiling QEMU on Mac OS X recently. On my system, the channel-socket.c file causes this error: io/channel-socket.c: In function 'qio_channel_socket_writev': io/channel-socket.c:497:18: error: variable-sized object may not be initialized char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)] = { 0 }; As a test I made this simple program: #include <sys/socket.h> #include <stdio.h> int main (int argc, char * const argv[]) { printf("GCC version = %d.%d.%d\n", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); char control[CMSG_SPACE(sizeof(int) * 16)] = { 0 }; control[0] = 'a'; // just to eliminate a warning return 0; } When compiling under Xcode, the program does compile and run. It prints "GCC version = 4.2.1". When I try to compile it under gcc 4.2.1 using just the terminal, I see this error message: main.cpp: In function ‘int main(int, char* const*)’: main.cpp:6: error: size of array ‘control’ is not an integral constant-expression Why there is a difference between XCode and the terminal I have no idea. When compiling it under gcc 4.9.2, it compiles and runs without problem. I have set the configure option for cc to gcc-4.9 with this "-cc=gcc-4.9". So the error message makes me believe that the wrong compiler is being used. This is the full configure command options I used: ./configure --cxx=gcc-4.9 --cc=gcc-4.9 --objcc=gcc-4.9 --disable-gtk --disable-sdl --target-list=ppc-softmmu,i386-softmmu Any insight as to what could be wrong? ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] CMSG_SPACE() causing compile time error on Mac OS X 2016-01-17 22:23 [Qemu-devel] CMSG_SPACE() causing compile time error on Mac OS X Programmingkid @ 2016-01-17 23:22 ` Paolo Bonzini 2016-01-17 23:45 ` Programmingkid 2016-01-18 9:58 ` Daniel P. Berrange 1 sibling, 1 reply; 15+ messages in thread From: Paolo Bonzini @ 2016-01-17 23:22 UTC (permalink / raw) To: Programmingkid, Peter Maydell; +Cc: qemu-devel qemu-devel On 17/01/2016 23:23, Programmingkid wrote: > When compiling under Xcode, the program does compile and run. It prints "GCC version = 4.2.1". > > When I try to compile it under gcc 4.2.1 using just the terminal, I see this error message: > main.cpp: In function ‘int main(int, char* const*)’: > main.cpp:6: error: size of array ‘control’ is not an integral constant-expression > > Why there is a difference between XCode and the terminal I have no idea. > > When compiling it under gcc 4.9.2, it compiles and runs without problem. > > I have set the configure option for cc to gcc-4.9 with this "-cc=gcc-4.9". So the error message makes me believe that the wrong compiler is being used. > > This is the full configure command options I used: > ./configure --cxx=gcc-4.9 --cc=gcc-4.9 --objcc=gcc-4.9 --disable-gtk --disable-sdl --target-list=ppc-softmmu,i386-softmmu > > Any insight as to what could be wrong? What's the definition of the CMSG_SPACE macro under OS X? Paolo ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] CMSG_SPACE() causing compile time error on Mac OS X 2016-01-17 23:22 ` Paolo Bonzini @ 2016-01-17 23:45 ` Programmingkid 2016-01-18 17:45 ` Eric Blake 0 siblings, 1 reply; 15+ messages in thread From: Programmingkid @ 2016-01-17 23:45 UTC (permalink / raw) To: Paolo Bonzini; +Cc: Peter Maydell, qemu-devel qemu-devel On Jan 17, 2016, at 6:22 PM, Paolo Bonzini wrote: > > > On 17/01/2016 23:23, Programmingkid wrote: >> When compiling under Xcode, the program does compile and run. It prints "GCC version = 4.2.1". >> >> When I try to compile it under gcc 4.2.1 using just the terminal, I see this error message: >> main.cpp: In function ‘int main(int, char* const*)’: >> main.cpp:6: error: size of array ‘control’ is not an integral constant-expression >> >> Why there is a difference between XCode and the terminal I have no idea. >> >> When compiling it under gcc 4.9.2, it compiles and runs without problem. >> >> I have set the configure option for cc to gcc-4.9 with this "-cc=gcc-4.9". So the error message makes me believe that the wrong compiler is being used. >> >> This is the full configure command options I used: >> ./configure --cxx=gcc-4.9 --cc=gcc-4.9 --objcc=gcc-4.9 --disable-gtk --disable-sdl --target-list=ppc-softmmu,i386-softmmu >> >> Any insight as to what could be wrong? > > What's the definition of the CMSG_SPACE macro under OS X? > > Paolo #define CMSG_SPACE(l) (__DARWIN_ALIGN32(sizeof(struct cmsghdr)) + __DARWIN_ALIGN32(l)) Hope this helps. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] CMSG_SPACE() causing compile time error on Mac OS X 2016-01-17 23:45 ` Programmingkid @ 2016-01-18 17:45 ` Eric Blake 2016-01-18 17:59 ` Peter Maydell 2016-01-18 19:50 ` Programmingkid 0 siblings, 2 replies; 15+ messages in thread From: Eric Blake @ 2016-01-18 17:45 UTC (permalink / raw) To: Programmingkid, Paolo Bonzini; +Cc: Peter Maydell, qemu-devel qemu-devel [-- Attachment #1: Type: text/plain, Size: 666 bytes --] On 01/17/2016 04:45 PM, Programmingkid wrote: >> What's the definition of the CMSG_SPACE macro under OS X? >> >> Paolo > > #define CMSG_SPACE(l) (__DARWIN_ALIGN32(sizeof(struct cmsghdr)) + __DARWIN_ALIGN32(l)) And the definition of __DARWIN_ALIGN32()? It looks like the definition is not properly resulting in a compile-time constant, and therefore the warning about the initializer is resulting because you can't initialize a dynamically-sized array. But you still haven't shown us why the headers are resulting in a non-constant size. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 604 bytes --] ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] CMSG_SPACE() causing compile time error on Mac OS X 2016-01-18 17:45 ` Eric Blake @ 2016-01-18 17:59 ` Peter Maydell 2016-01-18 19:46 ` Programmingkid 2016-01-18 19:50 ` Programmingkid 1 sibling, 1 reply; 15+ messages in thread From: Peter Maydell @ 2016-01-18 17:59 UTC (permalink / raw) To: Eric Blake; +Cc: Programmingkid, qemu-devel qemu-devel, Paolo Bonzini On 18 January 2016 at 17:45, Eric Blake <eblake@redhat.com> wrote: > On 01/17/2016 04:45 PM, Programmingkid wrote: >>> What's the definition of the CMSG_SPACE macro under OS X? >>> >>> Paolo >> >> #define CMSG_SPACE(l) (__DARWIN_ALIGN32(sizeof(struct cmsghdr)) + __DARWIN_ALIGN32(l)) > > And the definition of __DARWIN_ALIGN32()? > > It looks like the definition is not properly resulting in a compile-time > constant, and therefore the warning about the initializer is resulting > because you can't initialize a dynamically-sized array. But you still > haven't shown us why the headers are resulting in a non-constant size. FWIW, on my OSX system (OSX 10.10.5, Xcode 7.1), compiling the test program with gcc -Wall -E -o /tmp/varray.S /tmp/varray.c shows that the array definition expands to char control[(((__darwin_size_t)((char *)(__darwin_size_t)(sizeof(struct cmsghdr)) + (sizeof(__uint32_t) - 1)) &~ (sizeof(__uint32_t) - 1)) + ((__darwin_size_t)((char *)(__darwin_size_t)(sizeof(int) * 16) + (sizeof(__uint32_t) - 1)) &~ (sizeof(__uint32_t) - 1)))] = { 0 }; the relevant macro definitions being #define __DARWIN_ALIGNBYTES (sizeof(__darwin_size_t) - 1) #define __DARWIN_ALIGN32(p) ((__darwin_size_t)((char *)(__darwin_size_t)(p) + __DARWIN_ALIGNBYTES32) &~ __DARWIN_ALIGNBYTES32) this is with a 'gcc' that gcc --version reports as Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 7.0.0 (clang-700.1.76) Target: x86_64-apple-darwin14.5.0 Thread model: posix and which claims itself to be 4.2.1 by the printout from the test program (ie it's clang under the hood). I don't get any compiler warnings from gcc -Wall -O2 -o /tmp/varray /tmp/varray.c I don't know what the difference between my setup and John's is (likely an older clang version). thanks -- PMM ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] CMSG_SPACE() causing compile time error on Mac OS X 2016-01-18 17:59 ` Peter Maydell @ 2016-01-18 19:46 ` Programmingkid 0 siblings, 0 replies; 15+ messages in thread From: Programmingkid @ 2016-01-18 19:46 UTC (permalink / raw) To: Peter Maydell, Eric Blake; +Cc: Paolo Bonzini, qemu-devel qemu-devel On Jan 18, 2016, at 12:59 PM, Peter Maydell wrote: > On 18 January 2016 at 17:45, Eric Blake <eblake@redhat.com> wrote: >> On 01/17/2016 04:45 PM, Programmingkid wrote: >>>> What's the definition of the CMSG_SPACE macro under OS X? >>>> >>>> Paolo >>> >>> #define CMSG_SPACE(l) (__DARWIN_ALIGN32(sizeof(struct cmsghdr)) + __DARWIN_ALIGN32(l)) >> >> And the definition of __DARWIN_ALIGN32()? >> >> It looks like the definition is not properly resulting in a compile-time >> constant, and therefore the warning about the initializer is resulting >> because you can't initialize a dynamically-sized array. But you still >> haven't shown us why the headers are resulting in a non-constant size. > > FWIW, on my OSX system (OSX 10.10.5, Xcode 7.1), compiling the test > program with > > gcc -Wall -E -o /tmp/varray.S /tmp/varray.c > > shows that the array definition expands to > > char control[(((__darwin_size_t)((char > *)(__darwin_size_t)(sizeof(struct cmsghdr)) + (sizeof(__uint32_t) - > 1)) &~ (sizeof(__uint32_t) - 1)) + ((__darwin_size_t)((char > *)(__darwin_size_t)(sizeof(int) * 16) + (sizeof(__uint32_t) - 1)) &~ > (sizeof(__uint32_t) - 1)))] = { 0 }; > > the relevant macro definitions being > #define __DARWIN_ALIGNBYTES (sizeof(__darwin_size_t) - 1) > #define __DARWIN_ALIGN32(p) ((__darwin_size_t)((char > *)(__darwin_size_t)(p) + __DARWIN_ALIGNBYTES32) &~ > __DARWIN_ALIGNBYTES32) > > > this is with a 'gcc' that gcc --version reports as > Configured with: > --prefix=/Applications/Xcode.app/Contents/Developer/usr > --with-gxx-include-dir=/usr/include/c++/4.2.1 > Apple LLVM version 7.0.0 (clang-700.1.76) > Target: x86_64-apple-darwin14.5.0 > Thread model: posix > > and which claims itself to be 4.2.1 by the printout from the test > program (ie it's clang under the hood). That is interesting. I would have thought Apple would have upgrade their GCC compatibility version by now. > > I don't get any compiler warnings from > gcc -Wall -O2 -o /tmp/varray /tmp/varray.c > > I don't know what the difference between my setup and John's is > (likely an older clang version). > > thanks > -- PMM A patch by Daniel P. Berrange successfully fixes this problem. http://patchwork.ozlabs.org/patch/569500/ diff --git a/io/channel-socket.c b/io/channel-socket.c index eaa411f..bc117b1 100644 --- a/io/channel-socket.c +++ b/io/channel-socket.c @@ -493,10 +495,12 @@ static ssize_t qio_channel_socket_writev(QIOChannel *ioc, QIOChannelSocket *sioc = QIO_CHANNEL_SOCKET(ioc); ssize_t ret; struct msghdr msg = { NULL, }; - char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)] = { 0 }; + char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)]; size_t fdsize = sizeof(int) * nfds; struct cmsghdr *cmsg; + memset(control, 0, CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)); + msg.msg_iov = (struct iovec *)iov; msg.msg_iovlen = niov; ^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] CMSG_SPACE() causing compile time error on Mac OS X 2016-01-18 17:45 ` Eric Blake 2016-01-18 17:59 ` Peter Maydell @ 2016-01-18 19:50 ` Programmingkid 2016-01-18 20:49 ` Peter Maydell 1 sibling, 1 reply; 15+ messages in thread From: Programmingkid @ 2016-01-18 19:50 UTC (permalink / raw) To: Eric Blake, Peter Maydell, Paolo Bonzini; +Cc: qemu-devel qemu-devel On Jan 18, 2016, at 12:45 PM, Eric Blake wrote: > On 01/17/2016 04:45 PM, Programmingkid wrote: >>> What's the definition of the CMSG_SPACE macro under OS X? >>> >>> Paolo >> >> #define CMSG_SPACE(l) (__DARWIN_ALIGN32(sizeof(struct cmsghdr)) + __DARWIN_ALIGN32(l)) > > And the definition of __DARWIN_ALIGN32()? > > It looks like the definition is not properly resulting in a compile-time > constant, and therefore the warning about the initializer is resulting > because you can't initialize a dynamically-sized array. But you still > haven't shown us why the headers are resulting in a non-constant size. I tried what Peter Maydell did and here are the results: typedef __darwin_size_t size_t; char control[(((__darwin_size_t)((char *)(__darwin_size_t)(sizeof(struct cmsghdr)) + (sizeof(__uint32_t) - 1)) &~ (sizeof(__uint32_t) - 1)) + ((__darwin_size_t)((char *)(__darwin_size_t)(sizeof(int) * 16) + (sizeof(__uint32_t) - 1)) &~ (sizeof(__uint32_t) - 1)))] = { 0 }; It looks like the problem was actually with this part: = { 0 }; ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] CMSG_SPACE() causing compile time error on Mac OS X 2016-01-18 19:50 ` Programmingkid @ 2016-01-18 20:49 ` Peter Maydell 2016-01-18 21:09 ` Programmingkid 0 siblings, 1 reply; 15+ messages in thread From: Peter Maydell @ 2016-01-18 20:49 UTC (permalink / raw) To: Programmingkid; +Cc: Paolo Bonzini, qemu-devel qemu-devel On 18 January 2016 at 19:50, Programmingkid <programmingkidx@gmail.com> wrote: > I tried what Peter Maydell did and here are the results: > > typedef __darwin_size_t size_t; > > char control[(((__darwin_size_t)((char *)(__darwin_size_t)(sizeof(struct cmsghdr)) + (sizeof(__uint32_t) - 1)) &~ (sizeof(__uint32_t) - 1)) + ((__darwin_size_t)((char *)(__darwin_size_t)(sizeof(int) * 16) + (sizeof(__uint32_t) - 1)) &~ (sizeof(__uint32_t) - 1)))] = { 0 }; > > It looks like the problem was actually with this part: = { 0 }; No, the problem is that the compiler seems to think the bit in [] is not compile time constant (the = { 0 } initializer syntax is valid if and only if it is compile-time-constant). Can you say what 'gcc --version' prints for you? That will tell us the clang version number, which is more interesting than what clang claims its gcc-compatibility is. I'm leaning towards this being a compiler bug fixed in a later version of clang, because that [] expression looks like it should be constant to me, and it's constant as far as my clang version thinks. thanks -- PMM ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] CMSG_SPACE() causing compile time error on Mac OS X 2016-01-18 20:49 ` Peter Maydell @ 2016-01-18 21:09 ` Programmingkid 2016-01-18 22:09 ` Peter Maydell 0 siblings, 1 reply; 15+ messages in thread From: Programmingkid @ 2016-01-18 21:09 UTC (permalink / raw) To: Peter Maydell; +Cc: Paolo Bonzini, qemu-devel qemu-devel On Jan 18, 2016, at 3:49 PM, Peter Maydell wrote: > On 18 January 2016 at 19:50, Programmingkid <programmingkidx@gmail.com> wrote: >> I tried what Peter Maydell did and here are the results: >> >> typedef __darwin_size_t size_t; >> >> char control[(((__darwin_size_t)((char *)(__darwin_size_t)(sizeof(struct cmsghdr)) + (sizeof(__uint32_t) - 1)) &~ (sizeof(__uint32_t) - 1)) + ((__darwin_size_t)((char *)(__darwin_size_t)(sizeof(int) * 16) + (sizeof(__uint32_t) - 1)) &~ (sizeof(__uint32_t) - 1)))] = { 0 }; >> >> It looks like the problem was actually with this part: = { 0 }; > > No, the problem is that the compiler seems to think the bit in [] > is not compile time constant (the = { 0 } initializer syntax > is valid if and only if it is compile-time-constant). > > Can you say what 'gcc --version' prints for you? That will > tell us the clang version number, which is more interesting > than what clang claims its gcc-compatibility is. $ gcc-4.9 --version gcc-4.9 (Homebrew gcc49 4.9.2_1) 4.9.2 Copyright (C) 2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > I'm leaning towards this being a compiler bug fixed in > a later version of clang, because that [] expression looks > like it should be constant to me, and it's constant as > far as my clang version thinks. A bug could be the case. I use gcc 4.9.2 to compile QEMU. I don't use the clang compiler. Just in case here is the info from Apple's clang compiler on my system: $ gcc --version i686-apple-darwin10-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00) Copyright (C) 2007 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] CMSG_SPACE() causing compile time error on Mac OS X 2016-01-18 21:09 ` Programmingkid @ 2016-01-18 22:09 ` Peter Maydell 2016-01-19 1:23 ` Programmingkid 0 siblings, 1 reply; 15+ messages in thread From: Peter Maydell @ 2016-01-18 22:09 UTC (permalink / raw) To: Programmingkid; +Cc: Paolo Bonzini, qemu-devel qemu-devel On 18 January 2016 at 21:09, Programmingkid <programmingkidx@gmail.com> wrote: > > On Jan 18, 2016, at 3:49 PM, Peter Maydell wrote: >> Can you say what 'gcc --version' prints for you? That will >> tell us the clang version number, which is more interesting >> than what clang claims its gcc-compatibility is. > > $ gcc-4.9 --version > gcc-4.9 (Homebrew gcc49 4.9.2_1) 4.9.2 > Copyright (C) 2014 Free Software Foundation, Inc. > This is free software; see the source for copying conditions. There is NO > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Ah, I misread your earlier message and I thought you said that gcc-4.9 worked ok and it was plain 'gcc' that caused the warning. Is that expansion of the macro the one produced by gcc-4.9, then? Also, you're right that we should figure out why it seems to be using the wrong C compiler. Can you use 'V=1' to look at what command line make is using to compile this file, please? (you'll probably want to dump the whole make output to a file and then search through it). Also: * what does your config-host.mak say (in particular about what it's set CC, HOST_CC, CXX, etc to)? * can you check your environment doesn't have CC set to anything? ("env | grep CC" should tell you if it is) thanks -- PMM ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] CMSG_SPACE() causing compile time error on Mac OS X 2016-01-18 22:09 ` Peter Maydell @ 2016-01-19 1:23 ` Programmingkid 2016-01-19 23:49 ` Programmingkid 0 siblings, 1 reply; 15+ messages in thread From: Programmingkid @ 2016-01-19 1:23 UTC (permalink / raw) To: Peter Maydell; +Cc: Paolo Bonzini, qemu-devel qemu-devel On Jan 18, 2016, at 5:09 PM, Peter Maydell wrote: > On 18 January 2016 at 21:09, Programmingkid <programmingkidx@gmail.com> wrote: >> >> On Jan 18, 2016, at 3:49 PM, Peter Maydell wrote: >>> Can you say what 'gcc --version' prints for you? That will >>> tell us the clang version number, which is more interesting >>> than what clang claims its gcc-compatibility is. >> >> $ gcc-4.9 --version >> gcc-4.9 (Homebrew gcc49 4.9.2_1) 4.9.2 >> Copyright (C) 2014 Free Software Foundation, Inc. >> This is free software; see the source for copying conditions. There is NO >> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > > Ah, I misread your earlier message and I thought you said that > gcc-4.9 worked ok and it was plain 'gcc' that caused the warning. > Is that expansion of the macro the one produced by gcc-4.9, then? Actually it should have but wasn't. It is of gcc 4.2.1. Here is gcc 4.9.2's output: char control[(((__darwin_size_t)((char *)(__darwin_size_t)(sizeof(struct cmsghdr)) + (sizeof(__uint32_t) - 1)) &~ (sizeof(__uint32_t) - 1)) + ((__darwin_size_t)((char *)(__darwin_size_t)(sizeof(int) * 16) + (sizeof(__uint32_t) - 1)) &~ (sizeof(__uint32_t) - 1)))] = { 0 }; This is gcc 4.2.1's output: char control[(((__darwin_size_t)((char *)(__darwin_size_t)(sizeof(struct cmsghdr)) + (sizeof(__uint32_t) - 1)) &~ (sizeof(__uint32_t) - 1)) + ((__darwin_size_t)((char *)(__darwin_size_t)(sizeof(int) * 16) + (sizeof(__uint32_t) - 1)) &~ (sizeof(__uint32_t) - 1)))] = { 0 }; They appear to be identical. > > Also, you're right that we should figure out why it seems to > be using the wrong C compiler. Can you use 'V=1' to look at > what command line make is using to compile this file, please? > (you'll probably want to dump the whole make output to a file > and then search through it). It says gcc-4.9 for the compiler. I wonder if the wrong header file is being used somewhere. > Also: > * what does your config-host.mak say (in particular about what > it's set CC, HOST_CC, CXX, etc to)? CC=gcc-4.9 HOST_CC=cc CXX=gcc-4.9 CPP=gcc-4.9 -E OBJCC=gcc-4.9 > * can you check your environment doesn't have CC set to anything? > ("env | grep CC" should tell you if it is) Nothing is returned. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] CMSG_SPACE() causing compile time error on Mac OS X 2016-01-19 1:23 ` Programmingkid @ 2016-01-19 23:49 ` Programmingkid 0 siblings, 0 replies; 15+ messages in thread From: Programmingkid @ 2016-01-19 23:49 UTC (permalink / raw) To: Peter Maydell, Eric Blake, Paolo Bonzini, qemu-devel qemu-devel On Jan 18, 2016, at 8:23 PM, Programmingkid wrote: > > On Jan 18, 2016, at 5:09 PM, Peter Maydell wrote: > >> On 18 January 2016 at 21:09, Programmingkid <programmingkidx@gmail.com> wrote: >>> >>> On Jan 18, 2016, at 3:49 PM, Peter Maydell wrote: >>>> Can you say what 'gcc --version' prints for you? That will >>>> tell us the clang version number, which is more interesting >>>> than what clang claims its gcc-compatibility is. >>> >>> $ gcc-4.9 --version >>> gcc-4.9 (Homebrew gcc49 4.9.2_1) 4.9.2 >>> Copyright (C) 2014 Free Software Foundation, Inc. >>> This is free software; see the source for copying conditions. There is NO >>> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. >> >> Ah, I misread your earlier message and I thought you said that >> gcc-4.9 worked ok and it was plain 'gcc' that caused the warning. >> Is that expansion of the macro the one produced by gcc-4.9, then? > > Actually it should have but wasn't. It is of gcc 4.2.1. > > Here is gcc 4.9.2's output: > > char control[(((__darwin_size_t)((char *)(__darwin_size_t)(sizeof(struct cmsghdr)) + (sizeof(__uint32_t) - 1)) &~ (sizeof(__uint32_t) - 1)) + ((__darwin_size_t)((char *)(__darwin_size_t)(sizeof(int) * 16) + (sizeof(__uint32_t) - 1)) &~ (sizeof(__uint32_t) - 1)))] = { 0 }; > > This is gcc 4.2.1's output: > > char control[(((__darwin_size_t)((char *)(__darwin_size_t)(sizeof(struct cmsghdr)) + (sizeof(__uint32_t) - 1)) &~ (sizeof(__uint32_t) - 1)) + ((__darwin_size_t)((char *)(__darwin_size_t)(sizeof(int) * 16) + (sizeof(__uint32_t) - 1)) &~ (sizeof(__uint32_t) - 1)))] = { 0 }; > > They appear to be identical. > >> >> Also, you're right that we should figure out why it seems to >> be using the wrong C compiler. Can you use 'V=1' to look at >> what command line make is using to compile this file, please? >> (you'll probably want to dump the whole make output to a file >> and then search through it). > > It says gcc-4.9 for the compiler. I wonder if the wrong header file is being used somewhere. > >> Also: >> * what does your config-host.mak say (in particular about what >> it's set CC, HOST_CC, CXX, etc to)? > > CC=gcc-4.9 > HOST_CC=cc > CXX=gcc-4.9 > CPP=gcc-4.9 -E > OBJCC=gcc-4.9 > >> * can you check your environment doesn't have CC set to anything? >> ("env | grep CC" should tell you if it is) > > Nothing is returned. printf("GCC version = %d.%d.%d\n", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); I thought I should add that with this code in the qio_channel_socket_register_types() function of channel-socket.c, this was printed: GCC version = 4.9.2 It looks like my theory of another version of GCC being used for compiling the channel-socket.c file isn't correct. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] CMSG_SPACE() causing compile time error on Mac OS X 2016-01-17 22:23 [Qemu-devel] CMSG_SPACE() causing compile time error on Mac OS X Programmingkid 2016-01-17 23:22 ` Paolo Bonzini @ 2016-01-18 9:58 ` Daniel P. Berrange 2016-01-18 14:36 ` Programmingkid 1 sibling, 1 reply; 15+ messages in thread From: Daniel P. Berrange @ 2016-01-18 9:58 UTC (permalink / raw) To: Programmingkid; +Cc: Peter Maydell, qemu-devel qemu-devel, Paolo Bonzini On Sun, Jan 17, 2016 at 05:23:44PM -0500, Programmingkid wrote: > I was wondering if you had problems compiling QEMU on Mac OS X recently. On my system, the channel-socket.c file causes this error: > > io/channel-socket.c: In function 'qio_channel_socket_writev': > io/channel-socket.c:497:18: error: variable-sized object may not be initialized > char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)] = { 0 }; Can you try applying this patch: diff --git a/io/channel-socket.c b/io/channel-socket.c index eaa411f..bc117b1 100644 --- a/io/channel-socket.c +++ b/io/channel-socket.c @@ -493,10 +495,12 @@ static ssize_t qio_channel_socket_writev(QIOChannel *ioc, QIOChannelSocket *sioc = QIO_CHANNEL_SOCKET(ioc); ssize_t ret; struct msghdr msg = { NULL, }; - char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)] = { 0 }; + char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)]; size_t fdsize = sizeof(int) * nfds; struct cmsghdr *cmsg; + memset(control, 0, CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)); + msg.msg_iov = (struct iovec *)iov; msg.msg_iovlen = niov; Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| ^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] CMSG_SPACE() causing compile time error on Mac OS X 2016-01-18 9:58 ` Daniel P. Berrange @ 2016-01-18 14:36 ` Programmingkid 2016-01-19 14:06 ` Daniel P. Berrange 0 siblings, 1 reply; 15+ messages in thread From: Programmingkid @ 2016-01-18 14:36 UTC (permalink / raw) To: Daniel P. Berrange; +Cc: Peter Maydell, qemu-devel qemu-devel, Paolo Bonzini On Jan 18, 2016, at 4:58 AM, Daniel P. Berrange wrote: > On Sun, Jan 17, 2016 at 05:23:44PM -0500, Programmingkid wrote: >> I was wondering if you had problems compiling QEMU on Mac OS X recently. On my system, the channel-socket.c file causes this error: >> >> io/channel-socket.c: In function 'qio_channel_socket_writev': >> io/channel-socket.c:497:18: error: variable-sized object may not be initialized >> char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)] = { 0 }; > > Can you try applying this patch: > > diff --git a/io/channel-socket.c b/io/channel-socket.c > index eaa411f..bc117b1 100644 > --- a/io/channel-socket.c > +++ b/io/channel-socket.c > @@ -493,10 +495,12 @@ static ssize_t qio_channel_socket_writev(QIOChannel *ioc, > QIOChannelSocket *sioc = QIO_CHANNEL_SOCKET(ioc); > ssize_t ret; > struct msghdr msg = { NULL, }; > - char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)] = { 0 }; > + char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)]; > size_t fdsize = sizeof(int) * nfds; > struct cmsghdr *cmsg; > > + memset(control, 0, CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)); > + > msg.msg_iov = (struct iovec *)iov; > msg.msg_iovlen = niov; > > > > Regards, > Daniel > -- > |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| > |: http://libvirt.org -o- http://virt-manager.org :| > |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| > |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| Your patch solves the problem. Good job! Reviewed-By: John Arbuckle <programmingkidx@gmail.com> ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] CMSG_SPACE() causing compile time error on Mac OS X 2016-01-18 14:36 ` Programmingkid @ 2016-01-19 14:06 ` Daniel P. Berrange 0 siblings, 0 replies; 15+ messages in thread From: Daniel P. Berrange @ 2016-01-19 14:06 UTC (permalink / raw) To: Programmingkid; +Cc: Peter Maydell, qemu-devel qemu-devel, Paolo Bonzini On Mon, Jan 18, 2016 at 09:36:08AM -0500, Programmingkid wrote: > > On Jan 18, 2016, at 4:58 AM, Daniel P. Berrange wrote: > > > On Sun, Jan 17, 2016 at 05:23:44PM -0500, Programmingkid wrote: > >> I was wondering if you had problems compiling QEMU on Mac OS X recently. On my system, the channel-socket.c file causes this error: > >> > >> io/channel-socket.c: In function 'qio_channel_socket_writev': > >> io/channel-socket.c:497:18: error: variable-sized object may not be initialized > >> char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)] = { 0 }; > > > > Can you try applying this patch: > > > > diff --git a/io/channel-socket.c b/io/channel-socket.c > > index eaa411f..bc117b1 100644 > > --- a/io/channel-socket.c > > +++ b/io/channel-socket.c > > @@ -493,10 +495,12 @@ static ssize_t qio_channel_socket_writev(QIOChannel *ioc, > > QIOChannelSocket *sioc = QIO_CHANNEL_SOCKET(ioc); > > ssize_t ret; > > struct msghdr msg = { NULL, }; > > - char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)] = { 0 }; > > + char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)]; > > size_t fdsize = sizeof(int) * nfds; > > struct cmsghdr *cmsg; > > > > + memset(control, 0, CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)); > > + > > msg.msg_iov = (struct iovec *)iov; > > msg.msg_iovlen = niov; > > > > Your patch solves the problem. Good job! > > Reviewed-By: John Arbuckle <programmingkidx@gmail.com> Thanks, I'll include this fix in my next PULL request for the io/ layer Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| ^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2016-01-19 23:49 UTC | newest] Thread overview: 15+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-01-17 22:23 [Qemu-devel] CMSG_SPACE() causing compile time error on Mac OS X Programmingkid 2016-01-17 23:22 ` Paolo Bonzini 2016-01-17 23:45 ` Programmingkid 2016-01-18 17:45 ` Eric Blake 2016-01-18 17:59 ` Peter Maydell 2016-01-18 19:46 ` Programmingkid 2016-01-18 19:50 ` Programmingkid 2016-01-18 20:49 ` Peter Maydell 2016-01-18 21:09 ` Programmingkid 2016-01-18 22:09 ` Peter Maydell 2016-01-19 1:23 ` Programmingkid 2016-01-19 23:49 ` Programmingkid 2016-01-18 9:58 ` Daniel P. Berrange 2016-01-18 14:36 ` Programmingkid 2016-01-19 14:06 ` Daniel P. Berrange
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).