cgen: emit interface type-table index as a real symbol under -usecache (fix undefined _IError_None___index)#27381
cgen: emit interface type-table index as a real symbol under -usecache (fix undefined _IError_None___index)#27381medvednikov wants to merge 4 commits into
-usecache (fix undefined _IError_None___index)#27381Conversation
…e (fix undefined `_IError_None___index`) With -usecache, modules like `builtin` are compiled separately in build_module mode, where the interface type-table index is emitted as `extern const u32 _<I>_<T>___index;` and referenced. Commit 60ac6ce changed the main (non-build_module) branch to emit the index as a compile-time `enum { ..._index = N };` instead of `const u32 ..._index = N;`. An enum constant has no linker symbol, so the `extern const u32` reference from the cached `builtin` object had no definition, failing at link time: undefined symbol: _IError_None___index This reproduces with any -usecache build (e.g. `hello world`); FreeBSD/clang reported it first. Restore a real, externally-linked `const u32 ..._index = N;` definition when `-usecache` is active, while keeping the tcc-friendly `enum` form for ordinary single-build compilations (which need no cross-TU symbol). Fixes #27330
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f9776fa596
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: be5327d59f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fd1e6b1a66
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Description
Fixes #27330.
Multiple FreeBSD/clang reports failed at link time with:
Root cause
interface_table()emits the interface type-table index for each concrete variant. With-usecache, modules likebuiltinare compiled separately in build_module mode, where the index is emitted as a forward reference to a real symbol:Commit
60ac6ce06("cgen: linux tcc fix") changed the main (non-build_module) branch to emit the index as a compile-time enum:instead of the previous
const u32 _IError_None___index = 1;. Anenumconstant has no linker symbol, so the cachedbuiltinobject'sextern const u32reference had no definition anywhere — undefined symbol at link time. This reproduces with any-usecachebuild (evenfn main(){ println('hello world') }); FreeBSD/clang's stricter linker surfaced it.Fix
Restore a real, externally-linked
const u32 ..._index = N;definition in the main program when-usecacheis active, while keeping the tcc-friendlyenumform for ordinary single-build compilations (which need no cross-TU symbol). This is exactly the pre-60ac6ce06behavior for the usecache case, scoped so the tcc fix is preserved everywhere else.Verification
v -usecache -o - hello.vpreviously emittedenum { _IError_None___index = 1 };; with the fix it emitsconst u32 _IError_None___index = 1;, and theundefined symbol: _IError_None___index/_IError_MessageError_indexlink errors are gone.usecachebuilds are unchanged (still emit theenumform);hello worldand an error-handling program build and run normally; the compiler self-compiles.vlib/v/tests/usecache_interface_index_symbol_test.vasserting the-usecachecodegen emits the realconst u32symbol (and that plain builds keep theenum).