Optimize library runtime builders with -O3 -march=native -mtune=native -fomit-frame-pointer

This commit is contained in:
Andras Laszlo committed 2026-10-16 14:09:00 +02:00
1 parent 08a2153308
commit 4065c4dadf
3 files changed
+13 -10

No files matched your search

+8 -5
View File
@@ -15,6 +15,7 @@ generation only. Outputs build/riot-libc++.1.dylib and build/riot-libc++abi.dyli
"""
from concurrent.futures import ThreadPoolExecutor
from pathlib import Path
import os
import re
import shlex
import subprocess
@@ -47,20 +48,22 @@ def build(library, object_dir, link_dir, output):
obj = root / ("build/riot-opt-%s-%s.o" % (library, relative.replace("/", "_")))
jobs.append((relative, obj))
link[index] = str(obj)
print(library, "recompiling", len(jobs), "objects at -O2", flush=True)
print(library, "recompiling", len(jobs), "objects at -O3", flush=True)
def compile_one(job):
relative, obj = job
subprocess.run(["clang++", *flags["CXX_DEFINES"], *flags["CXX_INCLUDES"], *flags["CXX_FLAGS"],
"-O2", "-fno-strict-aliasing", "-c", str(source / relative), "-o", str(obj)],
cxx_flags = [f for f in flags["CXX_FLAGS"] if f not in ("-g", "-O0", "-O1", "-O2")]
subprocess.run(["clang++", *flags["CXX_DEFINES"], *flags["CXX_INCLUDES"], *cxx_flags,
"-O3", "-march=native", "-mtune=native", "-fomit-frame-pointer", "-fno-strict-aliasing",
"-c", str(source / relative), "-o", str(obj)],
check=True, capture_output=True)
riot_build_gate.wait_until_free()
with ThreadPoolExecutor(max_workers=6) as pool:
with ThreadPoolExecutor(max_workers=os.cpu_count() or 8) as pool:
list(pool.map(compile_one, jobs))
link[link.index("-o") + 1] = str(root / "build" / output)
subprocess.run(link, cwd=folder, check=True)
print("built build/" + output, len(jobs), "objects at -O2", flush=True)
print("built build/" + output, len(jobs), "objects at -O3", flush=True)
if __name__ == "__main__":
+2 -3
View File
@@ -100,9 +100,8 @@ def compile_command(target_folder, source, object_path):
skip = True
continue
cleaned.append(token)
if "-O2" not in cleaned:
cleaned.append("-O2")
cleaned.append("-fno-strict-aliasing")
cleaned = [t for t in cleaned if t not in ("-g", "-O0", "-O1", "-O2")]
cleaned.extend(["-O3", "-march=native", "-mtune=native", "-fno-strict-aliasing", "-fomit-frame-pointer"])
return cleaned
return None
+3 -2
View File
@@ -27,10 +27,11 @@ for original in list(link):
if not original.startswith('CMakeFiles/platform_obj.dir/src/string/generic/') or not original.endswith('.c.o'):continue
relative=original.split('platform_obj.dir/',1)[1].removesuffix('.o')
obj=root/('build/riot-platform-'+Path(relative).name+'.o')
subprocess.run(['clang',*flags['C_DEFINES'],*flags['C_INCLUDES'],*flags['C_FLAGS'],'-O2','-fno-builtin','-fno-strict-aliasing','-c',str(root/'build/darling-src/src/external/libplatform'/relative),'-o',str(obj)],check=True)
c_flags = [f for f in flags['C_FLAGS'] if f not in ('-g', '-O0', '-O1', '-O2')]
subprocess.run(['clang',*flags['C_DEFINES'],*flags['C_INCLUDES'],*c_flags,'-O3','-march=native','-mtune=native','-fomit-frame-pointer','-fno-builtin','-fno-strict-aliasing','-c',str(root/'build/darling-src/src/external/libplatform'/relative),'-o',str(obj)],check=True)
link[link.index(original)]=str(obj)
recompiled+=1
link[link.index('-o')+1]=str(root/'build/riot-libsystem_platform.dylib')
subprocess.run(link,cwd=folder,check=True)
print('built build/riot-libsystem_platform.dylib with',recompiled,'string objects at -O2')
print('built build/riot-libsystem_platform.dylib with',recompiled,'string objects at -O3')
p=root/'build/m810-platform-runtime';p.mkdir(exist_ok=True);shutil.copy2(root/'build/riot-libsystem_platform.dylib',p/'libsystem_platform.dylib')