Skip to content

Add direct include for getenv usages - #99856

Merged
fm4v merged 1 commit into
ClickHouse:masterfrom
4JustMe4:getenv-stdlib
Apr 8, 2026
Merged

fm4v merged 1 commit into
ClickHouse:masterfrom
4JustMe4:getenv-stdlib

Conversation

@4JustMe4

@4JustMe4 4JustMe4 commented Mar 18, 2026 •

Copy link
Copy Markdown
Contributor

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Trying to build a project with libсxx version between 21st and 22nd leads to an error

${root}/clickhouse/src/Common/EnvironmentChecks.cpp:204:34: error: use of undeclared identifier 'getenv'
  204 |         if (const char * value = getenv(var); value && value[0]) // NOLINT(concurrency-mt-unsafe)
      |                                  ^
${root}/clickhouse/src/Common/EnvironmentChecks.cpp:207:17: error: use of undeclared identifier 'setenv'
  207 |             if (setenv(var, "", true)) // NOLINT(concurrency-mt-unsafe) // this is safe if not called concurrently

Version info

  • Merged into: 26.4.1.644

@alexey-milovidov

Copy link
Copy Markdown
Member

We use a pinned version of libcxx from sources, so this PR is irrelevant for us.

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's still ok for merging.

@alexey-milovidov alexey-milovidov self-assigned this Mar 18, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Mar 18, 2026
@clickhouse-gh

clickhouse-gh Bot commented Mar 18, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f5f4d29]

Summary: ❌

job_name test_name status info comment
Stateless tests (amd_tsan, parallel, 2/2) failure
Server died FAIL cidb, issue ISSUE CREATED
Stress test (arm_msan) failure
Server died FAIL cidb IGNORED
MemorySanitizer: use-of-uninitialized-value (STID: 4179-5154) FAIL cidb, issue ISSUE EXISTS
AST fuzzer (arm_asan_ubsan) failure
UndefinedBehaviorSanitizer: undefined behavior (STID: 2527-3af3) FAIL cidb, issue ISSUE EXISTS

AI Review

Summary

This PR adds a direct #include <stdlib.h> in src/Common/EnvironmentChecks.cpp to fix builds with certain libc++ versions where getenv/setenv are not declared transitively. The change is minimal, targeted, and correct for the stated build failure; no correctness, safety, or performance issues were found.

ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ✅
Compilation time ✅
Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Mar 18, 2026
@4JustMe4

Copy link
Copy Markdown
Contributor Author

Branch was rebased for checks retry

@clickhouse-gh

clickhouse-gh Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.10% 84.00% -0.10%
Functions 90.90% 90.90% +0.00%
Branches 76.60% 76.50% -0.10%

Changed lines: N/A (no coverable changed lines) · Uncovered code

Full report · Diff report

@fm4v
fm4v added this pull request to the merge queue Apr 8, 2026
Merged via the queue into ClickHouse:master with commit c3381c9 Apr 8, 2026
159 of 163 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Apr 8, 2026
@rschu1ze rschu1ze mentioned this pull request Apr 8, 2026
@rschu1ze

rschu1ze commented Apr 8, 2026

Copy link
Copy Markdown
Member

@4JustMe4 Your PR was reverted. Please try again in the style of #102114

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

Labels

can be tested Allows running workflows for external contributors pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants