Skip to content

Commit ca3d456

Browse files
authored
[NFC][Testing] Test Poppler with optimizations (#24628)
Poppler's configure script chooses -O2 for gcc, and nothing for all other compilers, so we were never optimizing source files. Fix that by adding optimizations in cflags. This is important for test coverage, but also for branch hints, as LLVM does not emit hints when not optimizing. Another fix for branch hints is applied here: the likely macro was tailored (once again) to gcc. (This is NFC for now, but if/when LLVM gets branch hint support, this will become a useful real-world test of compiling and linking real-world code with such hints.) This also makes the Poppler benchmark 33% faster.
1 parent 6caf36c commit ca3d456

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

test/common.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,6 +2030,9 @@ def get_poppler_library(self, env_init=None):
20302030
self.cflags += [
20312031
'-I' + test_file('third_party/freetype/include'),
20322032
'-I' + test_file('third_party/poppler/include'),
2033+
# Poppler's configure script emits -O2 for gcc, and nothing for other
2034+
# compilers, including emcc, so set opts manually.
2035+
"-O2",
20332036
]
20342037

20352038
# Poppler has some pretty glaring warning. Suppress them to keep the

test/third_party/poppler/goo/GooLikely.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
#ifndef GOOLIKELY_H
1212
#define GOOLIKELY_H
1313

14-
#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
14+
// XXX EMSCRIPTEN: Remove gcc-specific detection of __builtin_expect.
15+
// #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
16+
#ifdef __EMSCRIPTEN__
1517
# define likely(x) __builtin_expect((x), 1)
1618
# define unlikely(x) __builtin_expect((x), 0)
1719
#else

0 commit comments

Comments
 (0)