Skip to content

Commit 01df4a4

Browse files
committed
Add a few Compiler flags to optimize llvm-libc for binary size and math throughput performances
1 parent c6756c2 commit 01df4a4

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

tools/system_libs.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,23 @@ class llvmlibc(DebugLibrary, AsanInstrumentedLibrary, MTLibrary):
10081008
name = 'libllvmlibc'
10091009
never_force = True
10101010
includes = ['system/lib/llvm-libc']
1011-
cflags = ['-Os', '-DLIBC_NAMESPACE=__llvm_libc', '-DLLVM_LIBC', '-DLIBC_COPT_PUBLIC_PACKAGING']
1011+
cflags = [
1012+
'-Os',
1013+
'-DLIBC_NAMESPACE=__llvm_libc',
1014+
'-DLLVM_LIBC',
1015+
'-DLIBC_COPT_PUBLIC_PACKAGING',
1016+
# Disable accurate pass to speed up certain math operations
1017+
'-DLIBC_MATH=LIBC_MATH_FAST',
1018+
'-DLIBC_MATH_SKIP_ACCURATE_PASS',
1019+
'-D__LIBC_USE_BUILTIN_CEIL_FLOOR_RINT_TRUNC',
1020+
# Reduce size bloats from string conversions.
1021+
'-DLIBC_COPT_STRTOFLOAT_DISABLE_EISEL_LEMIRE',
1022+
# To Enable FMA, we need to set the following flags. But we can't really ship this in a default libc build.
1023+
# Once llvm-libc gets used, we might need to have a FMA-enalbed flavor to enable these following flags.
1024+
'-Wno-unused-variable',
1025+
'-mrelaxed-simd',
1026+
'-ffast-math',
1027+
]
10121028

10131029
def get_files(self):
10141030
files = glob_in_path('system/lib/llvm-libc/src/assert', '*.cpp')

0 commit comments

Comments
 (0)