[GCC-XML] 32-bit build on 64-bit host

Brad King brad.king at kitware.com
Sat Mar 1 18:05:49 EST 2008


Steve Vinoski wrote:
> Hi, is gccxml supposed to honor the -m32 switch? Trying to build
> 32-bit code on a 64-bit Linux system and wanted to run gccxml in the
> same mode, but it doesn't seem to define things properly so that
> definitions in <limits.h> are set for 32-bit.
> 
> This is with the latest gccxml code from cvs and g++ 4.2.2.
> 
> If I compile the following, which is a trimmed down version of some
> code found in the ACE C++ networking framework, with -m32 on a 64-bit
> host:
> 
> #include <limits.h>
> #include <sys/types.h>
> u_long p = ULONG_MAX;
> 
> I get:
> 
> $ gccxml -fxml=/dev/null -m32 foo.cc
> foo.cc:3: error: integer constant is too large for 'long' type
> 
> It's as if the type system is 32-bit but the preprocessor constants
> (e.g., ULONG_MAX) are following the size of the host architecture.
> Running with --debug doesn't seem to give any clues, but I could
> certainly be missing something.

You should not pass the -m32 option to gccxml itself.  The fact that it 
has a gcc parser is an implementation detail.  You need to add -m32 to 
the options configuring the simulated compiler:

   gccxml --gccxml-cxxflags "-m32" foo.cc -fxml=foo.xml

That should get the constants adjusted at preprocessing time.

It won't change the actual size of the builtin types though.  To do that 
you would need to cross-compile the internal gcc parser.  Since gccxml 
is about the interface and not the implementation that is not a design goal.

-Brad



More information about the gccxml mailing list