morningman opened a new pull request, #71117: URL: https://github.com/apache/doris/pull/71117
### Background `be/test/util/internal_rpc_tls_test.cpp` (added by #70697) generates its TLS fixture by spawning a shell with `posix_spawnp(..., environ)`, so the child inherits the test's environment. POSIX leaves the declaration of `environ` to the program; glibc's `<unistd.h>` declares it when `_GNU_SOURCE` is defined, which the Linux build always has, and macOS's `<unistd.h>` does not declare it. ### What problem does this PR solve? Issue Number: None Related PR: #70697 (added the test) PR Type: Test Problem Summary: On macOS the BE unit tests no longer build: `internal_rpc_tls_test.cpp:95` fails with `use of undeclared identifier 'environ'`, and since every test is linked into one `doris_be_test` binary, no BE unit test can run locally on a Mac. This PR declares `extern char** environ;` at global scope in that test, the form POSIX documents. Linux builds see a second, identical declaration of what `<unistd.h>` already declares, and nothing else changes. ### Details - **Failure:** macOS arm64, `run-be-ut.sh` at master `d97993b7256`: `../test/util/internal_rpc_tls_test.cpp:95:85: error: use of undeclared identifier 'environ'`, the build stops and `doris_be_test` is not linked. - **Cause:** the test uses `environ` without declaring it and relies on glibc's `<unistd.h>` to do so; macOS's headers don't. - **Stability evidence:** a compile error, not a flaky test; with the declaration the file compiles and the suite passes on macOS (see Testing). ### Testing - macOS arm64, ASAN, `run-be-ut.sh` with `--gtest_filter=InternalRpcTlsTest.*`: before the change the build fails with the error above; after it `doris_be_test` links and all 21 `InternalRpcTlsTest` tests pass. - Linux: not built locally; the declaration is identical to the one glibc provides, and the BE UT pipelines cover it. - `clang-format` 16 reports no change. ### Release note None ### Check List (For Author) - Behavior changed: No - Does this need documentation: No - Pre-submission status: Partially verified: not built on Linux locally; the BE UT pipelines cover it ### AI Disclosure - Tool: Claude Code (Claude Opus 5.5) - Generated: the change and this description - Human review: the author asked for this fix as a separate PR after it was found while running other BE unit tests; no further review statement yet -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
