Bug 198738 - Incorrect optimization flag SSE2 on i386
Summary: Incorrect optimization flag SSE2 on i386
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Ports Framework (show other bugs)
Version: Latest
Hardware: i386 Any
: --- Affects Many People
Assignee: Port Management Team
URL:
Keywords:
Depends on: 200258 202586
Blocks:
  Show dependency treegraph
 
Reported: 2015-03-20 14:52 UTC by sasamotikomi
Modified: 2015-08-28 17:36 UTC (History)
3 users (show)

See Also:


Attachments
sdl20 cpu autodetect patch (2.33 KB, patch)
2015-05-10 10:08 UTC, Tijl Coosemans
no flags Details | Diff
qt5 cpu autodetect patch (525 bytes, patch)
2015-05-10 12:06 UTC, Tijl Coosemans
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description sasamotikomi 2015-03-20 14:52:08 UTC
Many ports have -msse2 on 32-bit version FreeBSD.
I think it's incorrect, many modern 32-bit processor have SSE but SSE2 isn't.
As example affected many QT4/5 ports:
From devel/qt5-core:

c++ -c -O2 -pipe -fstack-protector -fno-strict-aliasing -msse2 -pthread -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -O3 -fvisibility=hidden -fvisibility-inlines-hidden -std=c++11 -Wall -W -pthread -D_THREAD_SAFE -fPIC -DQT_NO_MTDEV -DQT_NO_LIBUDEV -DQT_NO_EVDEV -DQT_GLIB -DQT_NO_USING_NAMESPACE -DQT_BUILD_CORE_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050000 -DQT_USE_ICU -DQT_CORE_LIB -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -I. -I../../include -I../../include/QtCore -I../../include/QtCore/5.4.1 -I../../include/QtCore/5.4.1/QtCore -Iglobal -I../3rdparty/harfbuzz/src -I../3rdparty/md5 -I../3rdparty/md4 -I../3rdparty/sha3 -I.moc -I/usr/local/lib/qt5/mkspecs/freebsd-clang -o .obj/qabstractanimation.o animation/qabstractanimation.cpp


Even is define (in make.conf as CPUTYPE) processor without SSE2 support:

 c++ -c -O2 -pipe -march=athlon-xp -fstack-protector -fno-strict-aliasing -msse2 -pthread -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -O3 -fvisibility=hidden -fvisibility-inlines-hidden -std=c++11 -Wall -W -pthread -D_THREAD_SAFE -fPIC -DQT_NO_MTDEV -DQT_NO_LIBUDEV -DQT_NO_EVDEV -DQT_GLIB -DQT_NO_USING_NAMESPACE -DQT_BUILD_CORE_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050000 -DQT_USE_ICU -DQT_CORE_LIB -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -I. -I../../include -I../../include/QtCore -I../../include/QtCore/5.4.1 -I../../include/QtCore/5.4.1/QtCore -Iglobal -I../3rdparty/harfbuzz/src -I../3rdparty/md5 -I../3rdparty/md4 -I../3rdparty/sha3 -I.moc -I/usr/local/lib/qt5/mkspecs/freebsd-clang -o .obj/qdatetime.o tools/qdatetime.cpp
Comment 1 sasamotikomi 2015-03-20 15:18:55 UTC
A similar bug:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=198296
Comment 2 sasamotikomi 2015-05-09 22:31:02 UTC
devel/sdl20 have same issue:

libtool: compile:  cc -O2 -pipe -march=athlon-xp -DLIBICONV_PLUG -fstack-protector -fno-strict-aliasing -I/usr/local/include -DLIBICONV_PLUG -DUSING_GENERATED_CONFIG_H -Iinclude -I/usr/ports/devel/sdl20/work/SDL2-2.0.3/include -mmmx -msse -msse2 -fvisibility=hidden -I/usr/local/include -DHAVE_USBHID_H -DUSBHID_NEW -D_REENTRANT -D_THREAD_SAFE -Wall -MMD -MT build/SDL_sysfilesystem.lo -c /usr/ports/devel/sdl20/work/SDL2-2.0.3/src/filesystem/unix/SDL_sysfilesystem.c  -fPIC -DPIC -o build/.libs/SDL_sysfilesystem.o
libtool: compile:  cc -O2 -pipe -march=athlon-xp -DLIBICONV_PLUG -fstack-protector -fno-strict-aliasing -I/usr/local/include -DLIBICONV_PLUG -DUSING_GENERATED_CONFIG_H -Iinclude -I/usr/ports/devel/sdl20/work/SDL2-2.0.3/include -mmmx -msse -msse2 -fvisibility=hidden -I/usr/local/include -DHAVE_USBHID_H -DUSBHID_NEW -D_REENTRANT -D_THREAD_SAFE -Wall -MMD -MT build/SDL_sysfilesystem.lo -c /usr/ports/devel/sdl20/work/SDL2-2.0.3/src/filesystem/unix/SDL_sysfilesystem.c -o build/SDL_sysfilesystem.o >/dev/null 2>&1
Comment 3 Tijl Coosemans freebsd_committer freebsd_triage 2015-05-10 10:08:25 UTC
Created attachment 156602 [details]
sdl20 cpu autodetect patch

This patch replaces MMX and SSE options in devel/sdl20 with autodetection based on CPUTYPE.
Comment 4 Dimitry Andric freebsd_committer freebsd_triage 2015-05-10 10:33:04 UTC
I think this may depend entirely on the port.  In your example of devel/sdl20, its Makefile contains:

OPTIONS_DEFINE=         ALSA ASM DLOPEN ESOUND MMX NAS OSS \
                        PULSEAUDIO PTHREADS SSE SDL_ATOMIC SDL_AUDIO \
                        SDL_CPUINFO SDL_EVENTS SDL_FILE SDL_HAPTIC \
                        SDL_JOYSTICK SDL_LOADSO SDL_POWER SDL_RENDER \
                        SDL_THREADS SDL_TIMERS SDL_VIDEO VIDEO_OPENGL VIDEO_X11
OPTIONS_DEFAULT=        ASM DLOPEN OSS PTHREADS SDL_ATOMIC SDL_AUDIO \
                        SDL_CPUINFO SDL_EVENTS SDL_FILE SDL_HAPTIC \
                        SDL_JOYSTICK SDL_LOADSO SDL_POWER SDL_RENDER \
                        SDL_THREADS SDL_TIMERS SDL_VIDEO VIDEO_OPENGL VIDEO_X11
OPTIONS_DEFAULT_i386=   MMX SSE
OPTIONS_DEFAULT_amd64=  MMX SSE

and then later on:

SSE_CONFIGURE_ENABLE=           sse sse2 ssemath

this causes bsd.options.mk to pass all three as 'enable' options to sdl20's configure script:

# ${opt}_CONFIGURE_ENABLE       Will add to CONFIGURE_ARGS:
#                               Option enabled  --enable-${content}
#                               Option disabled --disable-${content}

So in case of the sdl20 port, enabling the *port* SSE option will enable both the SSE and SSE2 *configure* options.  This is probably debatable.  But it is trickier to have two separate port options for SSE and SSE2, I guess.
Comment 5 Tijl Coosemans freebsd_committer freebsd_triage 2015-05-10 12:06:31 UTC
Created attachment 156606 [details]
qt5 cpu autodetect patch

Qt 5.3 uses SSE2 by default.  Pass -no-sse2 to configure on i386 when SSE2 isn't supported.
Comment 6 sasamotikomi 2015-05-16 01:36:39 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=200234
opencv-core sse2 and even sse3 on i386
Comment 7 Tijl Coosemans freebsd_committer freebsd_triage 2015-05-16 14:46:59 UTC
Can you please create a separate bug for that?  It will be auto-assigned to the maintainer so he can have a look.
Comment 8 sasamotikomi 2015-05-17 00:59:23 UTC
(In reply to Tijl Coosemans from comment #7)
devel/qt5-core
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=200258
Comment 9 sasamotikomi 2015-05-17 06:02:47 UTC
Here is idea of universal solution for incorrect vendor optimization:   
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=200262
Comment 10 commit-hook freebsd_committer freebsd_triage 2015-05-24 16:41:21 UTC
A commit references this bug:

Author: tijl
Date: Sun May 24 16:41:18 UTC 2015
New revision: 387281
URL: https://svnweb.freebsd.org/changeset/ports/387281

Log:
  Qt 5.3 removed runtime detection of SSE2 so it needs to be configured
  with -no-sse2 at buildtime on i386.

  PR:		198738, 200258
  Reported by:	sasamotikomi@gmail.com
  Approved by:	maintainer timeout (2 weeks)

Changes:
  head/Mk/bsd.qt.mk
  head/devel/qt5-core/Makefile
  head/x11-toolkits/qt5-declarative/Makefile
  head/x11-toolkits/qt5-gui/Makefile
Comment 11 commit-hook freebsd_committer freebsd_triage 2015-05-24 16:49:25 UTC
A commit references this bug:

Author: tijl
Date: Sun May 24 16:48:41 UTC 2015
New revision: 387283
URL: https://svnweb.freebsd.org/changeset/ports/387283

Log:
  Replace MMX and SSE options with CPU autodetection such that they aren't
  enabled by default on i386.

  PR:		198738
  Approved by:	maintainer timeout (2 weeks)

Changes:
  head/devel/sdl20/Makefile
Comment 13 Tijl Coosemans freebsd_committer freebsd_triage 2015-05-26 18:30:19 UTC
There's nothing more to work on in this bug.  It provides no additional information over those three bugs you mention.  The problem of incorrect compiler flags is also different for every port with patches that are entirely different for every port so there's no point in keeping a general bug like this.  Please close it again.
Comment 14 sasamotikomi 2015-05-26 19:57:02 UTC
(In reply to Tijl Coosemans from comment #13)
I use this bug as aggregator for similar issues.
I can close it but I afraid we can forgot about this issue type.
I don't know how much ports affected it issue, I think better close this pr when all similar issues will be solved.(It's give time to find more of similar issues.)
Comment 15 Antoine Brodin freebsd_committer freebsd_triage 2015-08-28 17:36:24 UTC
Close: such problems should individually for each affected port