Why do files that use optind, optarg, getopt(), or environ sometimes fail to compile?
The tool xflat-gcc is just a thin wrapper around the real GNU compiler (with name like arm-linux-gcc or armeb-linux-uclibc-gcc or some such thing). They are the same compiler. The only difference is that xflat-gcc mucks with the command line parameters that are passed to the real GNU compiler in order to make life easier for you. As disccussed above here and here, because of the technical approach taken by XFLAT, there are issues with accessing global variables across shared module boundaries. This is not so much a consequence of the XFLAT implementation as it is a consequence of the absence of the GOT (Global Offset Table): The absence of a GOT means that XFLAT cannot support the indirection that you would need to relocate the data references. XFLAT works around this limitation by (1) recognizing when your code attempts to access a well-known shared variable, (2) replacing the variable reference with a call to an XFLAT accessor function that gets the variable address for you, and then