[infra] Add a new build flag to enable SSE2 for MSVC builds.
A freetype change [1] has improved font rendering under the following
conditions:
- When the host CPU is 64-bit.
- When SSE2 SIMD registers and instructions are available (even on x86).
This results in PDFium bot "win_xfa_msvc_32" having different test
expectations compared to other bots. To keep the test expectations
across all PDFium bots consistent, we need enable SSE2 for MSVC bots so
that MSVC bots won't have unique rendering results.
This CL adds a new build flag "msvc_use_sse2" for enabling SSE2 by
default for MSVC builds so that MSVC bots will be updated. Meanwhile, in
the freetype library, [2] will replace the check that `__SSE2__` is
defined with a check that `_M_IX86_FP` is defined and greater than or
equal to 2.
[1] https://chromium.googlesource.com/chromium/src/third_party/freetype2.git/+/56cc2ad446e920164e823e78a21972cadb339bfc)
[2] https://gitlab.freedesktop.org/freetype/freetype/-/merge_requests/80
Bug: pdfium:1714
Change-Id: I9c5492a98f5653a57c5d5eede7c49fb7660100d2
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/84433
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Hui Yingst <nigi@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index 7f98174..94edcde 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -43,6 +43,9 @@
if (is_win) {
# Assume UTF-8 by default to avoid code page dependencies.
cflags += [ "/utf-8" ]
+ if (msvc_use_sse2 && !is_clang) {
+ cflags += [ "/arch:SSE2" ]
+ }
}
if (is_clang) {
diff --git a/pdfium.gni b/pdfium.gni
index 5032de0..5851099 100644
--- a/pdfium.gni
+++ b/pdfium.gni
@@ -67,6 +67,9 @@
# Don't build against bundled libpng.
use_system_libpng = false
+
+ # Enable SSE2 for MSVC builds. Ignored if it's not a MSVC build.
+ msvc_use_sse2 = true
}
if (pdf_use_skia && pdf_use_skia_paths) {