Skip to content

Commit 172bfc0

Browse files
committed
Add a few Compiler flags to optimize llvm-libc for binary size and math throughput performances
1 parent 00c6531 commit 172bfc0

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

tools/system_libs.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,8 +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', '-DLIBC_MATH=LIBC_MATH_FAST', '-DLIBC_MATH_SKIP_ACCURATE_PASS', '-D__LIBC_USE_BUILTIN_CEIL_FLOOR_RINT_TRUNC', '-mrelaxed-simd', '-ffast-math', '-Wno-nan-infinity-disabled']
1012-
#'-DLIBC_MATH_SKIP_ACCURATE_PASS',
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+
# Enable FMA
1023+
"-Wno-unused-variable",
1024+
"-mrelaxed-simd",
1025+
"-ffast-math",
1026+
]
1027+
10131028
def get_files(self):
10141029
files = glob_in_path('system/lib/llvm-libc/src/assert', '*.cpp')
10151030
files += glob_in_path('system/lib/llvm-libc/src/complex', '**/*.cpp')

0 commit comments

Comments
 (0)