diff --git a/changes/http-link-call.md b/changes/http-link-call.md new file mode 100644 index 00000000..0884052f --- /dev/null +++ b/changes/http-link-call.md @@ -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`. diff --git a/tools/ludic-cli/build.ludic b/tools/ludic-cli/build.ludic index be3f4c3d..da363ce5 100644 --- a/tools/ludic-cli/build.ludic +++ b/tools/ludic-cli/build.ludic @@ -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` }