[clang] Warn when unique objects might be duplicated in shared libraries (PR #117622)
Devon Loehr via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 27 12:08:44 PST 2025
DKLoehr wrote:
> Can you share a few of the examples where it triggers, to get a feel for what this looks like on the LLVM code?
There's a text file linked in the initial description ([here](https://github.com/user-attachments/files/18563888/clang-warnings.txt), for convenience) that summarizes the warnings I examined in clang itself. I also found a few more in other parts of the LLVM project before giving up on whack-a-mole and just turning the warning off:
```
| /var/lib/buildkite-agent/builds/linux-56-59b8f5d88-78z5r-1/llvm-project/github-pull-requests/build-runtimes/libcxxabi/test-suite-install/include/c++/v1/__algorithm/shuffle.h:59:17: error: '__x' is mutable, has hidden visibility, and external linkage; it may be duplicated when built into a shared library [-Werror,-Wunique-object-duplication]
# | 59 | static char __x;
```
```
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-5wwkv-1/llvm-project/github-pull-requests/third-party/benchmark/src/log.h:59:14: error: 'log_level' is mutable, has hidden visibility, and external linkage; it may be duplicated when built into a shared library [-Werror,-Wunique-object-duplication]
59 | static int log_level = 0;
| ^
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-5wwkv-1/llvm-project/github-pull-requests/third-party/benchmark/src/log.h:64:18: error: 'null_log' is mutable, has hidden visibility, and external linkage; it may be duplicated when built into a shared library [-Werror,-Wunique-object-duplication]
64 | static LogType null_log(static_cast<std::ostream*>(nullptr));
| ^
/var/lib/buildkite-agent/builds/linux-56-59b8f5d88-5wwkv-1/llvm-project/github-pull-requests/third-party/benchmark/src/log.h:69:18: error: 'error_log' is mutable, has hidden visibility, and external linkage; it may be duplicated when built into a shared library [-Werror,-Wunique-object-duplication]
69 | static LogType error_log(&std::clog);
| ^
```
https://github.com/llvm/llvm-project/pull/117622
More information about the cfe-commits
mailing list