Skip to content

Commit 8a3e17c

Browse files
committed
v3: preseed parallel libc helpers
1 parent 0cea9e0 commit 8a3e17c

4 files changed

Lines changed: 15 additions & 3 deletions

File tree

ci/qemu_linux_tests.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ if ((sync_checkout)); then
203203
ssh "${ssh_options[@]}" "$guest" bash -s -- "$guest_repo" <<'EOF'
204204
set -Eeuo pipefail
205205
guest_repo=$1
206-
manifest=$(git -C "$guest_repo" rev-parse --git-path qemu-linux-tests-untracked)
206+
git_dir=$(git -C "$guest_repo" rev-parse --absolute-git-dir)
207+
manifest="${git_dir}/qemu-linux-tests-untracked"
207208
if [[ -f "$manifest" ]]; then
208209
cd "$guest_repo"
209210
while IFS= read -r -d '' path; do
@@ -245,7 +246,7 @@ EOF
245246
printf '%s\0' "$path"
246247
done \
247248
| ssh "${ssh_options[@]}" "$guest" \
248-
"manifest=\$(git -C ${guest_repo_q} rev-parse --git-path qemu-linux-tests-untracked) && cat > \"\$manifest\""
249+
"git_dir=\$(git -C ${guest_repo_q} rev-parse --absolute-git-dir) && cat > \"\${git_dir}/qemu-linux-tests-untracked\""
249250
fi
250251

251252
if (($# == 0)); then

vlib/v3/gen/c/cleanc.v

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2828,6 +2828,12 @@ pub fn (mut g FlatGen) gen_with_used_options(a &flat.FlatAst, used_fns map[strin
28282828
} else {
28292829
g.precompute_consts()
28302830
}
2831+
if defer_parallel_support {
2832+
// The declaration worker emits builtin ABI helpers concurrently with the
2833+
// function-body workers. Seed compatibility helpers before it starts; body
2834+
// workers still merge any lowering-only discoveries below.
2835+
g.preseed_libc_compat_fns()
2836+
}
28312837
g.timing_profile(' [ttime] cg precompute ${f64(cgsw.elapsed().microseconds()) / 1000.0:7.2f} ms')
28322838
cgsw.restart()
28332839
orig_sb := g.sb

vlib/v3/gen/c/fn.v

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,6 +1402,9 @@ fn (mut g FlatGen) libc_compat_call_name(name string) ?string {
14021402

14031403
fn (mut g FlatGen) preseed_libc_compat_fns() {
14041404
refs := g.c_extern_referenced_symbols()
1405+
if refs['C.syscall'] || refs['syscall'] {
1406+
g.libc_compat_fns[c_libc_compat_syscall_decl_key] = true
1407+
}
14051408
if refs['C.gettid'] || refs['gettid'] {
14061409
g.libc_compat_fns['gettid'] = true
14071410
}

vlib/v3/tests/gettid_libc_compat_codegen_test.v

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ const gettid_compat_v3_src = os.join_path(gettid_compat_v3_dir, 'v3.v')
99
fn gettid_compat_build_v3() string {
1010
v3_bin := os.join_path(os.temp_dir(), 'v3_gettid_compat_test_${os.getpid()}')
1111
os.rm(v3_bin) or {}
12+
// -prealloc enables the parallel declaration worker that must emit the helper
13+
// before function bodies can call it.
1214
build :=
13-
os.execute('${gettid_compat_vexe} -gc none -path "${gettid_compat_vlib_dir}|@vlib|@vmodules" -o ${v3_bin} ${gettid_compat_v3_src}')
15+
os.execute('${gettid_compat_vexe} -prealloc -path "${gettid_compat_vlib_dir}|@vlib|@vmodules" -o ${v3_bin} ${gettid_compat_v3_src}')
1416
assert build.exit_code == 0, build.output
1517
return v3_bin
1618
}

0 commit comments

Comments
 (0)