-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
cgen: emit interface type-table index as a real symbol under -usecache (fix undefined _IError_None___index)
#27381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f9776fa
cgen: emit interface type-table index as a real symbol under -usecach…
medvednikov be5327d
cgen: keep usecache interface indexes usable in case labels
medvednikov fd1e6b1
cgen: compare build-module interface indexes at runtime
medvednikov 3870a5b
cgen: keep usecache interface indexes out of parallel headers
medvednikov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import os | ||
|
|
||
| const vexe = @VEXE | ||
|
|
||
| // Regression test for https://github.com/vlang/v/issues/27330 | ||
| // | ||
| // With -usecache, modules like `builtin` are compiled separately in | ||
| // build_module mode, where the interface type-table index is emitted as | ||
| // `extern const u32 ..._index;` and referenced. The main program must therefore | ||
| // provide a real, externally-linked `const u32 ..._index = N;` definition - a | ||
| // compile-time `enum` constant has no linker symbol, so the reference would be | ||
| // undefined at link time (e.g. `undefined symbol: _IError_None___index` on | ||
| // FreeBSD/clang). | ||
| fn test_usecache_interface_index_is_real_symbol() { | ||
| tmp_dir := os.join_path(os.vtmp_dir(), 'v_issue_27330') | ||
| os.mkdir_all(tmp_dir) or { panic(err) } | ||
| defer { | ||
| os.rmdir_all(tmp_dir) or {} | ||
| } | ||
| source_path := os.join_path(tmp_dir, 'issue_27330.v') | ||
| os.write_file(source_path, "fn main() {\n\tprintln('hello world')\n}\n") or { panic(err) } | ||
|
|
||
| // -o - dumps the generated C of the main program to stdout. | ||
| res := os.execute('${os.quoted_path(vexe)} -usecache -o - ${os.quoted_path(source_path)}') | ||
| if res.exit_code != 0 { | ||
| panic(res.output) | ||
| } | ||
| // The index must be a real (externally-linked) definition, not a bare enum. | ||
| assert res.output.contains('const u32 _IError_None___index =') | ||
| assert !res.output.contains('enum { _IError_None___index =') | ||
|
|
||
| // Sanity check: without -usecache the compile-time enum form is kept (it is | ||
| // the tcc-friendly form and needs no external symbol in a single build). | ||
| res2 := os.execute('${os.quoted_path(vexe)} -o - ${os.quoted_path(source_path)}') | ||
| if res2.exit_code != 0 { | ||
| panic(res2.output) | ||
| } | ||
| assert res2.output.contains('enum { _IError_None___index =') | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.