Bug 692007 - SSE2 builds don't work for 32 bit Linux
Summary: SSE2 builds don't work for 32 bit Linux
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: Build Process (show other bugs)
Version: master
Hardware: PC All
: P4 normal
Assignee: Marcos H. Woehrmann
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-28 17:07 UTC by Marcos H. Woehrmann
Modified: 2011-08-15 23:36 UTC (History)
2 users (show)

See Also:
Customer:
Word Size: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marcos H. Woehrmann 2011-02-28 17:07:30 UTC
There is a problem with SSE2 under 32 bit Linux.  For Ghostscript the presence of the SSE2 instructions is not detected (i.e. -DHAVE_SSE2 is not listed on the CAPOPT line) and for GhostPDL the compile fails with this error:

.
.
.
gcc -m32  -O2 -Wall -Wundef -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -Wpointer-arith -Wwrite-strings -Wno-strict-aliasing -fno-builtin -fno-common -DHAVE_STDINT_H -DHAVE_MKSTEMP -DHAVE_HYPOT -DGX_COLOR_INDEX_TYPE="unsigned long"  -DPCL_INCLUDED -DHAVE_SSE2  -I./obj -I../gs/base  -o ./obj/gximono.o -c ../gs/base/gximono.c

In file included from ../gs/base/gximono.c:55:
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/include/emmintrin.h:32:3: error: #error "SSE2 instruction set not enabled"
../gs/base/gximono.c: In function 'threshold_16_SSE':
../gs/base/gximono.c:1069: error: '__m128i' undeclared (first use in this function)
.
.
.

This can be reproduced on Alex gate machine (aka briareus) which is an i686 Celeron and also on the various x84_64 machines if you force a 32 bit build.
Comment 1 Henry Stiles 2011-02-28 17:32:58 UTC
likely a problem with the sse2 auto configuration that I didn't do correctly the first time.
Comment 2 Henry Stiles 2011-02-28 17:42:31 UTC
(In reply to comment #1)
> likely a problem with the sse2 auto configuration that I didn't do correctly
> the first time.

Woops the autoconf stuff is correct.  ghostpdl does not have autoconf so that leaves users to set USE_SSE2 (the default defines it) on their own.  We do plan to have minimal autoconf support for ghostpdl by next release, but as the code is now it is working as expected.
Comment 3 Michael Vrhel 2011-02-28 19:03:53 UTC
This does happen on my VMWare Ubuntu 32 bit build of ghostscript also.  I have to do a make with HAVE_SSE2_DEFINE="" to avoid the issue.  Talking with Robin it is likely an issue with how I installed Ubuntu since my machine does have SSE2.
Comment 4 Marcos H. Woehrmann 2011-02-28 19:17:09 UTC
(In reply to comment #2)
> 
> Woops the autoconf stuff is correct.  ghostpdl does not have autoconf so that
> leaves users to set USE_SSE2 (the default defines it) on their own.  We do plan
> to have minimal autoconf support for ghostpdl by next release, but as the code
> is now it is working as expected.

Not sure why you are talking about ghostpdl in comment #2.  This not a GhostPDL bug; it's filed under Product:Ghostscript and Ghostscript is explicitly mentioned in the Description.
Comment 5 Marcos H. Woehrmann 2011-02-28 19:21:28 UTC
Not sure why you are talking about ghostpdl in comment #2.  This not a GhostPDL bug; it's filed under Product:Ghostscript and Ghostscript is explicitly mentioned in the Description.
(In reply to comment #4)
> This not a GhostPDL
> bug; it's filed under Product:Ghostscript and Ghostscript is explicitly
> mentioned in the Description.

Sorry, I reread my initial Description and now realize that I wasn't clear.  The Ghostscript bug is that the availability of SSE2 is not being detected on i686 machines; I should not have mentioned the GhostPDL issue in the description.
Comment 6 Marcos H. Woehrmann 2011-02-28 19:22:13 UTC
BTW, Ghostscript also fail on non-Intel cpus (this is from my iMac G5, where as you can see SSE2 is correctly not being detected):

gcc  -DHAVE_MKSTEMP -DHAVE_HYPOT     -DHAVE_SETLOCALE  -O2 -Wall -Wstrict-prototypes -Wundef -Wmissing-declarations -Wmissing-prototypes -Wwrite-strings -Wno-strict-aliasing -Wdeclaration-after-statement -fno-builtin -fno-common -DHAVE_STDINT_H -DGX_COLOR_INDEX_TYPE="unsigned long long"  -DUSE_LIBICONV_GNU  -I./obj -I./base  -o ./obj/gximono.o -c ./base/gximono.c
./base/gximono.c: In function 'threshold_row_bit':
./base/gximono.c:997: error: 'threshold_inverts' undeclared (first use in this function)
./base/gximono.c:997: error: (Each undeclared identifier is reported only once
./base/gximono.c:997: error: for each function it appears in.)
./base/gximono.c: In function 'threshold_landscape':
./base/gximono.c:1172: warning: 'align' attribute directive ignored
./base/gximono.c: In function 'image_render_mono_ht':
./base/gximono.c:1442: warning: assignment discards qualifiers from pointer target type
./base/gximono.c:1291: warning: unused variable 'i'
make: *** [obj/gximono.o] Error 1
Comment 7 Henry Stiles 2011-02-28 22:09:43 UTC
gcc -m32 does not enable SSE2 I am not sure why, but that is a gcc issue.  

Did you set the flags before ran configure?

CFLAGS=-m32 LDFLAGS=-m32 ./configure

Certainly you would have to do that.  SSE2 is checked by running a small C program, the program should fail to compile if the CFLAGS include -m32 resulting in no -DHAVE_SSE2 flag.  

I suspect you are setting CFLAGS after the SSE2 autoconf program runs or not at all, using your CC=gcc -m32 trick, that would foil the autoconf sse2 test.  If this isn't it can you tell me exactly how you set -m32.  comment #6 looks like a separate bug - just a syntax error in michael's code when sse2 is disabled.
Comment 8 Henry Stiles 2011-03-01 21:31:35 UTC
Assigning back to reporter to see everything is resolved before closing.
Comment 9 Marcos H. Woehrmann 2011-08-15 23:36:05 UTC
Everything is resolved.  Closing.