Bug 258708
| Summary: | [LibWebRTC] Enable AVX2 extensions only if host supports AVX2 | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Diego Pino <dpino> |
| Component: | New Bugs | Assignee: | Diego Pino <dpino> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | bugs-noreply, webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
Diego Pino
265400@main updated the CMake list of LibWebRTC sources after update to M115 (265320@main).
In the sources update, a new block was added to include specialized files that make use of AVX2 extensions if the host is X64. This condition is too broad, since not all X64 computers have support for AVX2 extensions (rare nowadays, but it may happen).
Another issue we found out was that since the AVX2 files are built with `-march=native` the host may emit AVX512 instructions if the host supports that extension. This may cause compatibility issues if a binary is built in a host with AVX512 support and it is executed in a host without AVX512 suport (the result will be a crash due to 'invalid instruction').
The build flag `m=no-avx512f` prevents emitting AVX512 instructions.
https://stackoverflow.com/questions/60815316/disabling-all-avx512-extensions
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Diego Pino
Pull request: https://github.com/webkit/webkit/pull/15432
EWS
Committed 265646@main (d95cad7579b5): <https://commits.webkit.org/265646@main>
Reviewed commits have been landed. Closing PR #15432 and removing active labels.
Radar WebKit Bug Importer
<rdar://problem/111556402>
Diego Pino
After chatting with Carlos Lopez in a private conversation, we concluded that the LibWebRTC's AVX2 files should be included always, regardless of whether the host machine that builds WebKit has support for it or not.
The flags `-march=machine -mno-avx512f` added to CMAKE_CXX_FLAGS should be removed because they affect all files. Instead, these flags should only apply to the set of AVX2 files. To enable compilation with AVX2 extension is enough with adding '-mavx2'. This is how Chromium does it:
https://webrtc.googlesource.com/src/+/refs/heads/main/modules/audio_processing/aec3/BUILD.gn#269
CMake macro `set_source_files_properties` can be used to apply build flags to a set of files.
https://cmake.org/cmake/help/latest/prop_sf/COMPILE_OPTIONS.html#prop_sf:COMPILE_OPTIONS
Diego Pino
Pull request: https://github.com/webkit/webkit/pull/15527
EWS
Committed 265754@main (0de2717c0029): <https://commits.webkit.org/265754@main>
Reviewed commits have been landed. Closing PR #15527 and removing active labels.
Diego Pino
Re-opening for pull request https://github.com/webkit/webkit/pull/15586
EWS
Committed 265790@main (48d7dce49219): <https://commits.webkit.org/265790@main>
Reviewed commits have been landed. Closing PR #15586 and removing active labels.
Diego Pino
Re-opening for pull request https://github.com/webkit/webkit/pull/15622
EWS
Committed 265832@main (aff1c9e1b48a): <https://commits.webkit.org/265832@main>
Reviewed commits have been landed. Closing PR #15622 and removing active labels.