vlib,builder,v3: add i18n and fix shared builds#27721
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eff64129d1
ℹ️ 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".
| pub fn tr_plural(lang string, key string, amount int) string { | ||
| return tr_plural_from_map(default_tr_map, lang, key, amount) | ||
| } | ||
|
|
||
| pub fn tr_plural_from_map(translations map[string]map[string]string, lang string, key string, amount int) string { |
There was a problem hiding this comment.
Add required doc comments to plural APIs
These two new public functions are exported without V doc comments, while the repo guide requires a doc comment immediately before each new or modified public function and says it should start with the function name (AGENTS.md lines 286-289). This leaves the new i18n public API undocumented in generated module docs; please add tr_plural... comments for both helpers.
Useful? React with 👍 / 👎.
eff6412 to
9e8a02d
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9e8a02d1d7
ℹ️ 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".
| pic_flag := if is_shared && prefs.normalized_target_os() != 'windows' { | ||
| '-fPIC ' | ||
| } else { |
There was a problem hiding this comment.
Compile C object dependencies as PIC for shared builds
For v3 -shared builds on non-Windows targets, this only adds -fPIC to the final compile/link of the generated src.c. Any #flag ... .o dependency whose object is missing is compiled earlier by ensure_c_object_file() through prepare_c_flags_for_link() without this flag, and with the same cache key as non-shared builds, so modules that pull in C objects with global relocations can fail at cc -shared with “recompile with -fPIC”. Please thread the shared/PIC setting into that object-compilation path as well.
Useful? React with 👍 / 👎.
9e8a02d to
ffab48b
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ffab48ba35
ℹ️ 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".
| } | ||
|
|
||
| opt_flag := if is_prod { '-O2 ' } else { '' } | ||
| shared_link_flag := if is_shared { '-shared ' } else { '' } |
There was a problem hiding this comment.
Emit init hooks for shared libraries
When -shared is used on a module that has init() functions or runtime global/const initialization, this path only adds linker/PIC flags. The v3 C generator emits _vinit() but only calls it from generated main/test harnesses (vlib/v3/gen/c/fn.v:2221 and vlib/v3/gen/c/fn.v:2366), while shared module builds have no main, so exported functions can observe zero/uninitialized state after the .so is loaded. The v1 shared path emits constructor-style _vinit_caller/cleanup hooks for this case (vlib/v/gen/c/cgen.v:12240); please wire is_shared into v3 cgen and emit equivalent shared init/cleanup hooks before treating -shared as working.
Useful? React with 👍 / 👎.
Summary
vlib.i18nmodule and routevebtranslation loading through itTests
./v -g -keepc -o ./vnew cmd/v./vnew -silent test vlib/i18n/./vnew -silent test vlib/v/builder/cc_test.v./vnew -silent test vlib/v3/tests/shared_flag_test.v