The constant initialization for globals in NVPTX is generated as an array of bytes. The generation of this byte arrays expects the host to be little endian, which prevents big endian hosts to be used in the generation of the PTX code.
This patch fixes the problem by changing the way the bytes are extracted so that it works for either little and big endian.
I identified this issue while crosscompiling for PTX in power7 machines.