Skip to content

vlib,builder,v3: add i18n and fix shared builds#27721

Open
medvednikov wants to merge 2 commits into
masterfrom
pr/i18n-shared-library-builds
Open

vlib,builder,v3: add i18n and fix shared builds#27721
medvednikov wants to merge 2 commits into
masterfrom
pr/i18n-shared-library-builds

Conversation

@medvednikov

Copy link
Copy Markdown
Member

Summary

  • add a reusable vlib.i18n module and route veb translation loading through it
  • fix shared-library build flag handling in builder/v3
  • add coverage for i18n loading and shared build flags

Tests

  • ./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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread vlib/i18n/i18n.v
Comment on lines +70 to +74
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 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@medvednikov medvednikov force-pushed the pr/i18n-shared-library-builds branch from eff6412 to 9e8a02d Compare July 9, 2026 23:32

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread vlib/v3/v3.v Outdated
Comment on lines +658 to +660
pic_flag := if is_shared && prefs.normalized_target_os() != 'windows' {
'-fPIC '
} else {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@medvednikov medvednikov force-pushed the pr/i18n-shared-library-builds branch from 9e8a02d to ffab48b Compare July 9, 2026 23:53

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread vlib/v3/v3.v
}

opt_flag := if is_prod { '-O2 ' } else { '' }
shared_link_flag := if is_shared { '-shared ' } else { '' }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant