GCC errors building the pkg package on SPARC
While building the pkg package on SPARC hardware, I encountered two gcc errors. This is the first one:
/usr/gcc/4.4.4/bin/gcc -fno-strict-aliasing -std=c99 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Imodules -I/usr/include/python2.6 -c modules/actions/_actions.c -o /dpool/export/home/mills/Downloads/code/oi-userland-apr/components/openindiana/pkg/pkg/proto/build_sparc/temp.solaris-2.11-sun4v-2.6/modules/actions/_actions.o -O3 -D__EXTENSIONS__ -Werror cc1: warnings being treated as errors modules/actions/_actions.c: In function 'fromstr': modules/actions/_actions.c:508: error: suggest explicit braces to avoid ambiguous 'else' modules/actions/_actions.c:523: error: suggest explicit braces to avoid ambiguous 'else' error: command '/usr/gcc/4.4.4/bin/gcc' failed with exit status 1 *** Error code 1
The solution is to add braces to the inner if statement. There is no else here, but adding the braces is still good style. The x86 build won't be affected.
The second error was this one:
/usr/gcc/4.4.4/bin/gcc -fno-strict-aliasing -m32 -O3 -mno-app-regs -fPIC -DPIC -std=c99 -D_XOPEN_SOURCE=600 -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -DPIC -Imodules -I/usr/include/python2.7 -c modules/actions/_actions.c -o /dpool/export/home/mills/Downloads/code/oi-userland-apr/components/openindiana/pkg/pkg/proto/build_sparc/temp64.solaris-2.11-sun4v.32bit-2.7/modules/actions/_actions.o -O3 -D__EXTENSIONS__ -Werror -m64 gcc: may not use both -m32 and -m64 error: command '/usr/gcc/4.4.4/bin/gcc' failed with exit status 1
Note that the gcc command line contains -m32 near the beginning and -m64 at the end. Apparently, gcc allows this practice on x86 hardware, but stops with an error on SPARC hardware. My solution was to modify the setup.py script so that it removed the
early -m32 unconditionally, and added -m32 or -m64 at the end of the command line, depending on whether it was to be a 32-bit or a 64-bit compile. This change also should not affect the x86 build. Somebody who knows python should be able to simplify the changes to setup.py, but my changes do work and do result in a successful build on SPARC.
I also made one addition to the Makefile to signal that patches were added. If both the patches are incorporated into the Github source, the change to Makefile will not be needed.