@@ -81,8 +81,26 @@ async def handler(data, context):
8181 sources = " " .join (vsrcs + csrcs )
8282 jobs = data .get ("jobs" , "" )
8383
84+ # Fix nix runtime library paths: embed rpath so binary finds nix libstdc++/glibc
85+ libstdcpp_path = subprocess .run (
86+ "g++ -print-file-name=libstdc++.so" , shell = True , capture_output = True , text = True
87+ ).stdout .strip ()
88+ if libstdcpp_path and "/" in libstdcpp_path :
89+ nix_lib_dir = os .path .dirname (os .path .realpath (libstdcpp_path ))
90+ ldflags += f" -Wl,-rpath,{ nix_lib_dir } "
91+
92+ # Enable ccache for verilator C++ compilation via OBJCACHE
93+ if subprocess .run ("command -v ccache" , shell = True , capture_output = True ).returncode == 0 :
94+ os .environ ["OBJCACHE" ] = "ccache"
95+
96+ # Build acceleration: lld for faster linking (available in nix env)
97+ use_lld = subprocess .run ("command -v ld.lld" , shell = True , capture_output = True ).returncode == 0
98+ if use_lld :
99+ ldflags += " -fuse-ld=lld"
100+
101+ # -O1 instead of -O3: much faster C++ compilation, minimal simulation speed difference
84102 verilator_cmd = (
85- f"verilator -MMD --build -cc --trace -O3 --x-assign fast --x-initial fast --noassert -Wno-fatal "
103+ f"verilator -MMD -cc --vpi --trace -O1 --x-assign fast --x-initial fast --noassert -Wno-fatal "
86104 f"--trace-fst --trace-threads 1 --output-split 10000 --output-split-cfuncs 100 "
87105 f"--unroll-count 256 "
88106 f"-Wno-PINCONNECTEMPTY "
@@ -101,11 +119,18 @@ async def handler(data, context):
101119 cmd = verilator_cmd ,
102120 logger = context .logger ,
103121 cwd = bbdir ,
104- stdout_prefix = "verilator build " ,
105- stderr_prefix = "verilator build " ,
122+ stdout_prefix = "verilator verilation " ,
123+ stderr_prefix = "verilator verilation " ,
106124 )
125+ if result .returncode != 0 :
126+ success_result , failure_result = await check_result (
127+ context , result .returncode , continue_run = False , extra_fields = {"task" : "build" }
128+ )
129+ return
130+
131+ make_jobs = jobs if jobs else str (os .cpu_count () or 16 )
107132 result = stream_run_logger (
108- cmd = f"make -C { obj_dir } -f V{ topname } .mk V{ topname } " ,
133+ cmd = f"make -j { make_jobs } VM_PARALLEL_BUILDS=1 - C { obj_dir } -f V{ topname } .mk V{ topname } " ,
109134 logger = context .logger ,
110135 cwd = bbdir ,
111136 stdout_prefix = "verilator build" ,
0 commit comments