fix(cli): link http.ll only for a program that calls hs_send

http_link_flags grepped the IR for "@hs_", which every program's header
declares, so `ludic build` linked the HTTP transport and Foundation into
everything - invisible on macOS, a failed link on Linux, where it broke four CI
cases (ludic run, the installed layout, ludic new, the seed build through
`ludic build`). It now looks for a call to hs_send: examples/library/http.ludic
has one, snake.ludic (which still declares ten @hs_ names) has none.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-13 03:45:04 +03:00
parent 096f851408
commit 39a7593521
2 changed files with 12 additions and 1 deletions

View file

@ -0,0 +1,8 @@
bump: patch
type: fix
**`ludic build` links `http.ll` only into a program that uses `Http.*`.**
The check that added it grepped the IR for `@hs_`, which every program's header declares,
so the HTTP transport and Foundation were linked into everything. That cost nothing visible
on macOS and failed the link on Linux, where `ludic build`, `ludic run` and a new project all
broke in CI. It now looks for a call to `hs_send`.

View file

@ -75,7 +75,10 @@ function gl_link_flags(ll: pointer) -> pointer {
# then, in both modes, as `ludicc -o` does (selfhost/main.ludic). Without it a Http.*
# program built through `ludic build` failed to link on every hs_* symbol.
function http_link_flags(ll: pointer) -> pointer {
if not shq(`grep -q "@hs_" {ll}`) { return "" }
# a CALL, not the name: every program's header declares the hs_* transport, so grepping
# for "@hs_" linked http.ll and Foundation into everything - harmless on macOS, a failed
# link on Linux. Only the Http runtime a program actually uses calls hs_send.
if not shq(`grep -q "call void @hs_send" {ll}`) { return "" }
return ` {ludic_home()}runtime/native/http.ll -Wl,-needed_framework,Foundation`
}