Bug 257402 - graphics/qgis illegal instruction, AVX instruction called on non-AVX Arch
Summary: graphics/qgis illegal instruction, AVX instruction called on non-AVX Arch
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Some People
Assignee: Rainer Hurling
URL: https://www.felixcloutier.com/x86/movups
Keywords:
Depends on:
Blocks:
 
Reported: 2021-07-25 07:50 UTC by alt2600
Modified: 2021-12-21 07:13 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (rhurlin)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description alt2600 2021-07-25 07:50:35 UTC
just finished compiling qgis and after much effort I get this

/usr/ports/graphics/qgis|$} lldb `which qgis`
(lldb) target create "/usr/local/bin/qgis"
Current executable set to '/usr/local/bin/qgis' (x86_64).
(lldb) r
Process 65039 launching
Process 65039 launched: '/usr/local/bin/qgis' (x86_64)
Process 65039 stopped
* thread #1, name = 'qgis', stop reason = signal SIGILL: privileged instruction
    frame #0: 0x000000080d970e69
->  0x80d970e69: vmovups (%rcx), %xmm0
    0x80d970e6d: vmovups %xmm0, 0x10(%rax)
    0x80d970e72: movq   (%r14), %rcx
    0x80d970e75: movq   %rcx, 0x20(%rax)
(lldb) 

If I'm not mistaken vmovups is an AVX extension, I am running westmere architecture there is no AVX here. I believe this to be related to qmake not being properly configured for <Haswell as referenced in PR 255753

https://www.felixcloutier.com/x86/movups

Not sure much can be done with maintainer, it seems qmake needs to be corrected to not force AVX for all amd64 systems. I might be wrong, but this seems to be more fallout.
Comment 1 Steve Wills freebsd_committer freebsd_triage 2021-07-25 20:52:11 UTC
Please confirm your CFLAGS, just to be sure. Thanks.
Comment 2 alt2600 2021-07-25 21:01:45 UTC
(In reply to Steve Wills from comment #1)
make.conf relevant settings

CPUTYPE?=westmere
###### CFLAGS+= -march=${CPUTYPE} -mtune=${CPUTYPE}
###### CXXFLAGS+= ${CFLAGS}
COPTFLAGS+= -O -pipe


They are default. I turned off setting CFLAGS around RELENG12 as it seemed to cause more problems then it was worth. Never set more than -O2 -pipe anyway which seems to be the default these days anyway within most ports, if not them choosing higher optimization levels. So whatever Ports is setting for them is what is being used. Assuming you mean from make.conf
Comment 3 alt2600 2021-07-25 22:34:10 UTC
I did double check and so far I haven't found -mavx inside of qgis being used, but I did find this from some quick checks, so I am more confident this is the fact qt5-3d is not being built correctly on my <Haswell system

AVX is being built for it, and similar to pyside2 qgis is the only other port on my system that depends on qt5-3d, which surprised me I figured FreeCAD would but it seems to still run on and doesn't directly depend.

##### qt5-3d configure excerpt
===>  Configuring for qt5-3d-5.15.2_2
/bin/mkdir -p /usr/ports/graphics/qt5-3d/work/qt3d-everywhere-src-5.15.2
echo 'CMAKE_MODULE_TESTS = -' > /usr/ports/graphics/qt5-3d/work/qt3d-everywhere-src-5.15.2/.qmake.cache
echo 'QMAKE_LIBDIR_FLAGS = -L/usr/ports/graphics/qt5-3d/work/qt3d-everywhere-src-5.15.2/lib' >> /usr/ports/graphics/qt5-3d/work/qt3d-everywhere-src-5.15.2/.qmake.cache
echo 'QMAKE_DEFAULT_LIBDIRS += /usr/local/lib /usr/lib /lib' >> /usr/ports/graphics/qt5-3d/work/qt3d-everywhere-src-5.15.2/.qmake.cache
echo 'QMAKE_DEFAULT_INCDIRS += /usr/local/include /usr/include' >> /usr/ports/graphics/qt5-3d/work/qt3d-everywhere-src-5.15.2/.qmake.cache
Info: creating stash file /usr/ports/graphics/qt5-3d/work/qt3d-everywhere-src-5.15.2/.qmake.stash

Running configuration tests...
Checking for Assimp... yes
Checking for Autodesk FBX... no
Done running configuration tests.

Configure summary:

Qt 3D:
  Assimp ................................. yes
  System Assimp .......................... yes
  Output Qt3D GL traces .................. no
  Use SSE2 instructions .................. yes
  Use AVX2 instructions .................. yes
  Aspects:
    Render aspect ........................ yes
    Input aspect ......................... yes
    Logic aspect ......................... yes
    Animation aspect ..................... yes
    Extras aspect ........................ yes
Qt 3D Renderers:
  OpenGL Renderer ........................ yes
  RHI Renderer ........................... no
Qt 3D GeometryLoaders:
  Autodesk FBX ........................... no


#### pkg info qt5-3d

/usr/ports/graphics/qgis|$} pkg info -dr qt5-3d
qt5-3d-5.15.2_2
Depends on     :
        qt5-gui-5.15.2_5
        qt5-declarative-5.15.2_3
        qt5-network-5.15.2_1
        assimp-5.0.1
        qtchooser-66_4
        qt5-core-5.15.2_5
        qt5-concurrent-5.15.2_2
Required by    :
        qgis-3.20.0_2
        py38-pyside2-5.15.2
        py38-pyside2-tools-5.15.2
Comment 4 alt2600 2021-08-21 04:02:18 UTC
applying devel/qt5-qmake patch in PR 255753 filed against devel/pyside2 and reverting graphics/qt5-3d AVX patch PR 248155 resolves this issue on non-AVX machines. I filed a consolidated patch provided in PR 25573 to that includes both these changes, I just hope I'm using the right format. Please let me know if more switches beyond git diff --staged are necessary, I want to do this correctly as I get used to using git.
Comment 5 alt2600 2021-12-20 13:46:00 UTC
commit 183d079fd681df544b67cf2f03c7d1d5aa7853fc

fixed qt5-3d and qmake, qgis builds without avx instructions being called on non-avx archs
Comment 6 Rainer Hurling freebsd_committer freebsd_triage 2021-12-20 13:52:19 UTC
(In reply to alt2600 from comment #5)
Thanks for the feedback. I'm glad to hear that the problem is fixed now :)
Comment 7 Steve Wills freebsd_committer freebsd_triage 2021-12-20 13:52:51 UTC
(In reply to alt2600 from comment #5)
Well, I guess that's fine, but the option in graphics/qt5-3d is useless.
Comment 8 alt2600 2021-12-20 22:40:33 UTC
(In reply to Steve Wills from comment #7)

it certainly appeared to not do anything, but that was what the committer decided to do. It certainly should be an option, because this nonsense of letting it turn on AVX on a whim based on the build system seemingly supporting it breaks packages outright. architecture breaking features should not just non-deterministically be set by configure.

But it compiled, along with pyside2 and qgis wasn't broken, so it wasn't really right to keep a bug on a the qgis victim.
Comment 9 Steve Wills freebsd_committer freebsd_triage 2021-12-21 07:13:31 UTC
(In reply to alt2600 from comment #8)
Right, with the change to qmake, it obeys the CFLAGS. The qt-3d option isn't needed, qt-3d and qgis will be built according to CFLAGS and everything is fine.