* Stricter requirements for function main signature @ 2008-04-07 18:37 Ramon Bertran Monfort 2008-04-08 10:22 ` Andrew Haley 2008-04-08 16:34 ` Jim Wilson 0 siblings, 2 replies; 7+ messages in thread From: Ramon Bertran Monfort @ 2008-04-07 18:37 UTC (permalink / raw) To: gcc-help Hello, I guess that this is the correct place to ask the following question. I've built a crosstoolchain for building Cell binaries on a x86 platform. The gcc version I used is gcc 4.3.0 . When I compile spu binaries with the corresponding main function signature... main(unsigned long long spe, unsigned long long argp, unsigned long long envp) ... I get an error telling me that the main signature is not correct (the first parameters must be and integer, etc...). spumain.cpp:56: error: first argument of 'int main(long long unsigned int, long long unsigned int, long long unsigned int)' should be 'int' spumain.cpp:56: error: second argument of 'int main(long long unsigned int, long long unsigned int, long long unsigned int)' should be 'char **' spumain.cpp:56: error: third argument of 'int main(long long unsigned int, long long unsigned int, long long unsigned int)' should probably be 'char **' I've seen in http://www.gnu.org/software/gcc/gcc-4.3/porting_to.html that C++ from version 4.3.0 has stricter requirements for function main signature. How is supposed to work this on a Cell platform? Thanks in advance, Salut! ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Stricter requirements for function main signature 2008-04-07 18:37 Stricter requirements for function main signature Ramon Bertran Monfort @ 2008-04-08 10:22 ` Andrew Haley 2008-04-08 13:17 ` Ramon Bertran Monfort 2008-04-08 16:34 ` Jim Wilson 1 sibling, 1 reply; 7+ messages in thread From: Andrew Haley @ 2008-04-08 10:22 UTC (permalink / raw) To: Ramon Bertran Monfort; +Cc: gcc-help Ramon Bertran Monfort wrote: > Hello, > > I guess that this is the correct place to ask the following question. > > I've built a crosstoolchain for building Cell binaries on a x86 platform. > The gcc version I used is gcc 4.3.0 . When I compile spu binaries with the > corresponding main function signature... > > main(unsigned long long spe, unsigned long long argp, unsigned long long > envp) > > ... I get an error telling me that the main signature is not correct (the > first parameters must be and integer, etc...). > > spumain.cpp:56: error: first argument of 'int main(long long unsigned int, > long long unsigned int, long long unsigned int)' should be 'int' > spumain.cpp:56: error: second argument of 'int main(long long unsigned int, > long long unsigned int, long long unsigned int)' should be 'char **' > spumain.cpp:56: error: third argument of 'int main(long long unsigned int, > long long unsigned int, long long unsigned int)' should probably be 'char > **' > > I've seen in http://www.gnu.org/software/gcc/gcc-4.3/porting_to.html that > C++ from version 4.3.0 has stricter requirements for function main > signature. How is supposed to work this on a Cell platform? Why don't you just define main() correctly? argv should be 'char **', and envp should probably be 'char **'. How can you possibly have an envp that's a long long unsigned int? Also, what are the compiler options you're using? Andrew. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Stricter requirements for function main signature 2008-04-08 10:22 ` Andrew Haley @ 2008-04-08 13:17 ` Ramon Bertran Monfort 2008-04-08 14:56 ` Andrew Haley 0 siblings, 1 reply; 7+ messages in thread From: Ramon Bertran Monfort @ 2008-04-08 13:17 UTC (permalink / raw) To: Andrew Haley; +Cc: Ramon Bertran Monfort, gcc-help [-- Attachment #1: Type: text/plain, Size: 1701 bytes --] Well, first of all, thanks for answering. > > Why don't you just define main() correctly? argv should be 'char **', > and envp should probably be 'char **'. How can you possibly have an > envp that's a long long unsigned int? > If a follow the SDK3.0 programming guide, it tells me that the spe main function has three parameters: the spe id, and two pointers to application specific data. The last two are optional. I can try to change the signature to the 'correctly' one ... but doing this will break the spe run-time probably. (I've to experiment with this). Anyway, sometimes I use three parameters witch is not allowed with the 'correct' strict signature. I know that there are workarounds for solving this issues, but I'm wondering if there is any gcc flag to relax this strict condition. It would be easy to port applications to gcc 4.3.0 such as the Cell application which changing the code is not as straightforward as the example shown in http://www.gnu.org/software/gcc/gcc-4.3/porting_to.html . > Also, what are the compiler options you're using? I guess that does not matter. I'm using just 'spu-g++ -O2' for testing. > > Andrew. Salut! -- ------------------------------------------------------------------------------- Ramon Bertran Monfort Departament d'Arquitectura de Computadors Telefon (+34) 93 4054033/54055 Universitat Politecnica de Catalunya Fax (+34) 93 4017055 Despatx C6-103/C6-221-9 Campus Nord e-mail rbertran@ac.upc.edu C. Jordi Girona 1-3 - 08034 Barcelona ------------------------------------------------------------------------------- [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Stricter requirements for function main signature 2008-04-08 13:17 ` Ramon Bertran Monfort @ 2008-04-08 14:56 ` Andrew Haley 2008-04-08 18:08 ` Ramon Bertran Monfort 0 siblings, 1 reply; 7+ messages in thread From: Andrew Haley @ 2008-04-08 14:56 UTC (permalink / raw) To: Ramon Bertran Monfort; +Cc: gcc-help Ramon Bertran Monfort wrote: > Well, > first of all, thanks for answering. > >> Why don't you just define main() correctly? argv should be 'char **', >> and envp should probably be 'char **'. How can you possibly have an >> envp that's a long long unsigned int? > > If a follow the SDK3.0 programming guide, it tells me that the spe main > function has three parameters: the spe id, and two pointers to application > specific data. The last two are optional. But you passed not a pointer but a long long unsigned int. Why not pass a pointer instead of a long long unsigned int, especially since that's what the programming guide tells you to do? > I can try to change the signature to the 'correctly' one ... but doing this > will break the spe run-time probably. (I've to experiment with this). > Anyway, sometimes I use three parameters witch is not allowed with the > 'correct' strict signature. g++ allows the third argument to be a pointer. > I know that there are workarounds for solving this issues, but I'm > wondering if there is any gcc flag to relax this strict condition. It would > be easy to port applications to gcc 4.3.0 such as the Cell application > which changing the code is not as straightforward as the example shown in > http://www.gnu.org/software/gcc/gcc-4.3/porting_to.html . >> Also, what are the compiler options you're using? > > I guess that does not matter. I'm using just 'spu-g++ -O2' for testing. Ah, OK. It seems that you have been caught by a version of gcc that treats this as an error rather than a warning. I'm not sure exactly when this changed, but the current development version has a warning, not an error. Andrew. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Stricter requirements for function main signature 2008-04-08 14:56 ` Andrew Haley @ 2008-04-08 18:08 ` Ramon Bertran Monfort 0 siblings, 0 replies; 7+ messages in thread From: Ramon Bertran Monfort @ 2008-04-08 18:08 UTC (permalink / raw) To: Andrew Haley; +Cc: Ramon Bertran Monfort, gcc-help [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset=utf-8, Size: 3338 bytes --] El Tue, Apr 08, 2008 at 02:16:23PM +0100, Andrew Haley ens deleità amb les següents paraules: > Ramon Bertran Monfort wrote: >> Well, >> first of all, thanks for answering. >> >>> Why don't you just define main() correctly? argv should be 'char **', >>> and envp should probably be 'char **'. How can you possibly have an >>> envp that's a long long unsigned int? >> >> If a follow the SDK3.0 programming guide, it tells me that the spe main >> function has three parameters: the spe id, and two pointers to application >> specific data. The last two are optional. > > But you passed not a pointer but a long long unsigned int. Why not pass a > pointer instead of a long long unsigned int, especially since that's > what the programming guide tells you to do? > I've just used the same main signature that they use. I thought that they used that strange signature for something... Now, I've change the signature to the 'correct' one : main ( int, char**, char**) and the program seems to compile correctly. However, if I execute it, it fails. I get a 'bus error' when trying to do a dma_transfer from the address of the second parameter. So, I guess that this kind of 'implicit' casting do not like to the Cell runtime... it should be a uint64_t, as is stated in the programming guide. >> I can try to change the signature to the 'correctly' one ... but doing this >> will break the spe run-time probably. (I've to experiment with this). >> Anyway, sometimes I use three parameters witch is not allowed with the >> 'correct' strict signature. > > g++ allows the third argument to be a pointer. > Oups, sorry for my ignorance. >> I know that there are workarounds for solving this issues, but I'm >> wondering if there is any gcc flag to relax this strict condition. It would >> be easy to port applications to gcc 4.3.0 such as the Cell application >> which changing the code is not as straightforward as the example shown in >> http://www.gnu.org/software/gcc/gcc-4.3/porting_to.html . > >>> Also, what are the compiler options you're using? >> >> I guess that does not matter. I'm using just 'spu-g++ -O2' for testing. > > Ah, OK. It seems that you have been caught by a version of gcc that treats > this as an error rather than a warning. I'm not sure exactly when this > changed, but the current development version has a warning, not an error. > Yes, the version is gcc 4.3.0 . I do not know if they relaxed this condition afterwards. I will try a newer version of gcc if this condition is relaxed. Do you know from which gcc version the error is just a warning again? > Andrew. Thanks in advance, Salut! -- ------------------------------------------------------------------------------- Ramon Bertran Monfort Departament d'Arquitectura de Computadors Telefon (+34) 93 4054033/54055 Universitat Politecnica de Catalunya Fax (+34) 93 4017055 Despatx C6-103/C6-221-9 Campus Nord e-mail rbertran@ac.upc.edu C. Jordi Girona 1-3 - 08034 Barcelona http://rbm.pc.ac.upc.edu ------------------------------------------------------------------------------- Listening: Hall of the king (Follow the blind) - Blind Guardian [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Stricter requirements for function main signature 2008-04-07 18:37 Stricter requirements for function main signature Ramon Bertran Monfort 2008-04-08 10:22 ` Andrew Haley @ 2008-04-08 16:34 ` Jim Wilson 2008-04-08 18:33 ` Ramon Bertran Monfort 1 sibling, 1 reply; 7+ messages in thread From: Jim Wilson @ 2008-04-08 16:34 UTC (permalink / raw) To: Ramon Bertran Monfort; +Cc: gcc-help Ramon Bertran Monfort wrote: > I've seen in http://www.gnu.org/software/gcc/gcc-4.3/porting_to.html that > C++ from version 4.3.0 has stricter requirements for function main > signature. How is supposed to work this on a Cell platform? Apparently Cell has unusual programming requirements. You might need to ask on a Cell related mailing list rather than a gcc related mailing list. -ffreestanding will turn off the ISO C++ required check for the main type signature, but it will also do other things that you may not want. Jim ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Stricter requirements for function main signature 2008-04-08 16:34 ` Jim Wilson @ 2008-04-08 18:33 ` Ramon Bertran Monfort 0 siblings, 0 replies; 7+ messages in thread From: Ramon Bertran Monfort @ 2008-04-08 18:33 UTC (permalink / raw) To: Jim Wilson; +Cc: Ramon Bertran Monfort, gcc-help [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset=utf-8, Size: 1369 bytes --] El Tue, Apr 08, 2008 at 08:56:44AM -0700, Jim Wilson ens deleità amb les següents paraules: > Ramon Bertran Monfort wrote: >> I've seen in http://www.gnu.org/software/gcc/gcc-4.3/porting_to.html >> that C++ from version 4.3.0 has stricter requirements for function main >> signature. How is supposed to work this on a Cell platform? > > Apparently Cell has unusual programming requirements. You might need to > ask on a Cell related mailing list rather than a gcc related mailing > list. > I'll do it, thanks for the suggestion. > -ffreestanding will turn off the ISO C++ required check for the main > type signature, but it will also do other things that you may not want. > Okz, thanks again. Using this flag I can compile and the program runs as expected. > Jim Salut! -- ------------------------------------------------------------------------------- Ramon Bertran Monfort Departament d'Arquitectura de Computadors Telefon (+34) 93 4054033/54055 Universitat Politecnica de Catalunya Fax (+34) 93 4017055 Despatx C6-103/C6-221-9 Campus Nord e-mail rbertran@ac.upc.edu C. Jordi Girona 1-3 - 08034 Barcelona http://rbm.pc.ac.upc.edu ------------------------------------------------------------------------------- Not playing [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-04-08 17:53 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2008-04-07 18:37 Stricter requirements for function main signature Ramon Bertran Monfort 2008-04-08 10:22 ` Andrew Haley 2008-04-08 13:17 ` Ramon Bertran Monfort 2008-04-08 14:56 ` Andrew Haley 2008-04-08 18:08 ` Ramon Bertran Monfort 2008-04-08 16:34 ` Jim Wilson 2008-04-08 18:33 ` Ramon Bertran Monfort
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 read-only IMAP folder(s) and NNTP newsgroup(s).