Re: Build failure with clang on older CPU :Illegal instruction

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On 11. 11. 19 09:46, Luboš Luňák wrote:
  The guilty commit is actually
https://cgit.freedesktop.org/libreoffice/core/commit/?id=f43f9b99603736a4d54f550052509eb5f4d04b45 .

  The INTRINSICS_CXXFLAGS variable is misdesigned or misused. What happens is
that a source file gets unconditionally compiled with whatever configure
finds to be the most advanced instruction set, and then the code from the
compiled source gets executed unconditionally, without a runtime check. A
runtime check is necessary, as flags like -mavx2 allow the compiler to use
newer instructions even for source code that doesn't explicitly use them.

  Looking at tools/qa/cppunit/test_cpuid.cxx, it seems that it doesn't need any
special CXXFLAGS, as it doesn't use them. And if it does need them, then
those parts need to be split to one source file per instruction set, each
compiled with its matching CXXFLAGS, and then another source file (compiled
normally) needs to call them only after doing a runtime check. See the
description of -mavx2 etc. in 'man gcc' and see 'git grep SSE2 sc/' for an
example.

Right, the test is quite naive and use of INTRINSICS_CXXFLAGS doesn't make sense here as it tests the runtime detection only, which is not dependent on the compiler flags (it just reports what the CPU supports). Probably this was needed in the past because compile and runtime detection was mixed with compile time detection, so if the compiler flags didn't return support for an instruction set, then runtime detection wasn't even performed, but this is not the case with the latest code anymore.

I fixed this problem with the test with [1] patch and I'll make a proper test at a later date to demonstrate how this is supposed to work.

[1] https://gerrit.libreoffice.org/#/c/82422/

Regards, Tomaž

_______________________________________________
LibreOffice mailing list
LibreOffice@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/libreoffice




[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux