Repository navigation
macOS dylib cross-linked off a Mac gets an install name and a minimum; three glob-import fixes - #3874
Merged
Merged
Conversation
A struct literal's field initialiser (`Font { size: 2 }`) and a struct
pattern's field are AST_ASSIGNMENT nodes whose value is the field name.
rename_intra_module_refs renames the target of a write to a module-level
`var` (#937), so with a module `var size` beside `struct Font { size }`
the field became `<ns>_size`, in the module's own functions and, through
`import m (*)`, in the importer. Only the initialiser (or sub-pattern) of
such a field is renamed now.
Regression: tests/integration/glob_import_struct_field_name.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`import m (*)` bound every `m_<name>` in the symbol table and renamed every constant of m in the importer, a private module-level `var` included. An importer's loop variable or local `text` then became m's `var text` (`m_text = <string>` on a string[]). A glob now binds only what m's `exports (...)` list names (module_glob_binds: everything when there is no list, never a leading underscore), in the checker's alias table, in the importer's rename pass, and in a module's own glob of another module (apply_inherited_selective_imports). rename_intra_module_refs also took any name spelt like one of the prefix module's vars for that var (write targets, receivers, and the locals it drops from shadowing), whatever the import bound; it now does so only for a var among the `consts` it renames (bound_module_var): all of them in the module's own bodies, as before, only the imported ones in an importer's. Regression: tests/integration/glob_import_private_var_hidden. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`button = button(t)` after `import buttons (*)` built C calling an undeclared `buttons_button`. The checker resolved the right-hand call to the import (the local is bound after its initializer), but the dead-code prune skipped every call spelt like a local of the enclosing function (#2218) and dropped the function. The prune now also tracks, per function, which locals are bound so far in walk order (PruneScope: a binding counts from after its initializer to the end of its block; anything it cannot place counts as unbound, which only seeds more), and seeds a call spelt like a local that is not bound yet. The checker's #3086 alias step took a bare call for the import even over a local of that name, so a call AFTER the binding (`button = 0` then `button = button(t)`) called the function too, against the language reference, and the prune had dropped it. It now leaves a local or parameter alone, and the call fails E0301 as for a program's own function (#2683), naming the import: "'button' is a local here, which hides the imported function 'buttons.button'". Regression: tests/integration/glob_import_local_named_like_fn. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zig spells the macOS targets aarch64-macos-none / x86_64-macos-none, and cross_target_is_apple() took only "-apple-" for an Apple target, so a macOS --emit=lib cross build linked on Linux or FreeBSD went through the ELF arm: no -install_name, so zig recorded the -o build path as the dylib's LC_ID_DYLIB and every program linked against it failed with "Library not loaded"; GNU strip flags under --size; and zig's default minimum, macOS 15.0. A Mac host rewrote the id with install_name_tool after the link, which hid the first half there. The one predicate did two jobs. cross_target_uses_xcode() now keeps the "-apple-" check for choosing the xcrun driver (the iOS clang triples only); cross_target_is_apple() recognises every Apple spelling (zig's -macos/-ios, clang's -apple-/-darwin, and the other Apple OS names) and decides the Mach-O link: -dynamiclib -install_name @rpath/<leaf>, as the native macOS build sets it, and Apple ld's -x -dead_strip. A zig macOS triple carries an explicit minimum, 13.0 by default, AETHER_MACOS_MIN to override (as AETHER_IOS_MIN does for iOS); documented in build-system.md. tests/integration/cross_macos_dylib_identity reads LC_ID_DYLIB and the minos from the load commands, so it runs on the Linux runner; CI runs it in the contrib.sqlite cross job, which has zig. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The close-race rounds dialled with connect_until and a deadline 3 to 9 ms away. A loopback connect is non-blocking there, and on macOS it is always EINPROGRESS: the handshake completes on another kernel path, so a loaded runner can spend the whole deadline on the dial. connect_until then rightly refuses with "deadline exceeded", the round goes on with a null socket, and the read's "connection closed or receive failed" overwrote the dial's error: the failure seen on the macOS x86_64 runner, which read like a deadline or cancel disturbing a connection. Each round now dials with the cancel bound and no deadline, then sets the few-ms deadline once connected, so the deadline and the cancel still race the read and the close as before. A failed dial ends the loop with its own error, and the first thing wrong in a round is the one reported: decoy dial errors no longer give way to "a decoy was disturbed". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Five fixes: one cross-build fix, three
import m (*)compiler fixes, and a flaky std.tcp deadline test.1. A macOS dylib cross-linked off a Mac gets an install name and a minimum (cb0301e)
zig spells the macOS targets
aarch64-macos-none/x86_64-macos-none, andcross_target_is_apple()took only-apple-for an Apple target. So a macOS--emit=libcross build linked on Linux or FreeBSD went through the ELF arm:-install_name, so zig recorded the-obuild path as LC_ID_DYLIB (a release built on CI carried/home/runner/work/.../libfoo.so, and every program linked against it failed with "Library not loaded");--size;A Mac host rewrote the id with install_name_tool after the link, which hid the first half there.
The fix splits the predicate, which was doing two jobs:
cross_target_uses_xcode()keeps the-apple-check, which picks the xcrun driver (the iOS clang triples).cross_target_is_apple()recognises every Apple spelling: zig's-macos/-ios, clang's-apple-/-darwin, and the other Apple OS names. It decides the Mach-O link:-dynamiclib -install_name @rpath/<leaf>(the id the native macOS build sets) and Apple ld's-x -dead_strip.A zig macOS triple now carries an explicit minimum: 13.0 by default, overridden with
AETHER_MACOS_MINthe wayAETHER_IOS_MINworks for iOS. This is documented indocs/build-system.md.Linux and FreeBSD
--emit=libstill set noDT_SONAME, which matches the native path. That is now documented and left as is.Test:
tests/integration/cross_macos_dylib_identityreads LC_ID_DYLIB and minos straight from the Mach-O load commands, so it needs no otool. It covers aarch64 at the default minimum, and x86_64 with--sizeandAETHER_MACOS_MIN=14.2. On a Mac it also links and runs a C consumer with-lgreet. CI runs it in the contrib.sqlite cross job, the Linux job that has zig.LC_ID_DYLIB is '/tmp/tmp.U1th7PbCYf/build/out/arm64/libgreet.dylib', want '@rpath/libgreet.dylib'.minos is '15.0', want '13.0'.2. merge: a struct literal's field is not a module var's write (c1a95fc)
If a module has
var sizenext to a struct fieldsize, everyFont { size: 2 }(in the module and through a glob import) used to be lowered to a field<module>_sizethat does not exist. Test:tests/integration/glob_import_struct_field_name.3. merge, typechecker: a glob import binds what the module exports (98ccd97)
import m (*)no longer binds private names, vars included.docs/language-reference.mdgets one sentence on this in its Glob Import section. Test:tests/integration/glob_import_private_var_hidden.4. prune, typechecker: a local named like an imported function (78b967a)
button = 0; button = button(t)afterimport buttons (*)is now compile error E0301: "'button' is a local here, which hides the imported function 'buttons.button'". This matches the language reference and the check that already applies to a program's own functions. Test:tests/integration/glob_import_local_named_like_fn. Its E0301 fixture is listed intests/ae_sweep_prune.txt.5. tcp_deadline_cancel: each race round gets its deadline after the dial (895a934)
On the macOS x86_64 runner, the first run of this PR failed
tests/integration/tcp_deadline_cancelwithround 66: read ended with [connection closed or receive failed]. That failure was in the test, not the runtime. Each close-race round dialled withconnect_untiland a deadline 3 to 9 ms away. On macOS a non-blocking loopback connect is always EINPROGRESS, and the handshake completes on another kernel path, so a loaded runner can use up the whole deadline on the dial. When that happens,connect_untilcorrectly refuses with "deadline exceeded". The round then went on with a null socket, and the read's error overwrote the dial's error. No deadline or cancel ever touched a descriptor.Each round now dials with the cancel bound and no deadline, and sets the few-ms deadline once it is connected. The deadline and the cancel still race the read and the close. A failed dial now reports its own error, and each round reports the first thing that went wrong in it.
dial: deadline exceeded6 times in about 3,000 rounds.192.0.2.1stall address failed at once with "connection failed" in the lab network. That is unrelated to this change, and the old test passed 20/20 there. Under the same background-QoS load, the new test ran 2,000 race rounds with no failures. That load also starves the trickle case below its 4-byte floor, in both the old and the new test.CC=gcc make cigave 2380 passed, 0 failed, 31 skipped (CI PASSED). On macOS arm64,make test-aegave 2355 passed, 0 failed, 56 skipped.BROKEN_CANCELLER=1) still reports "a decoy was disturbed".Verification
CC=gcc make ci: 2380 passed, 0 failed, 31 skipped; CI PASSED.otool -Dgives@rpath/libgreet.dylib;codesign -vis OK;-lgreetloads the arm64 dylib and runs.make test: green.make test-ae: 2355 passed, 0 failed, 56 skipped. This includes the sweep with both new prune entries.make cion ae-x64 in their author's own run (2380 passed, 0 failed).🤖 Generated with Claude Code