Experiment: Reduce the ABI surface on Linux with '-fvisibility-inlines-hidden'#3604
Conversation
|
@Vika-F What about MSVC? |
Took a look at the article, not required on msvc. |
@david-cortes-intel thanks for early review. The only issue is that |
david-cortes-intel
left a comment
There was a problem hiding this comment.
LGTM, but deferring to @Alexandr-Solovev about ABI part.
|
/intelci: run |
There was a problem hiding this comment.
Pull request overview
This PR experiments with reducing the exported ABI surface by compiling with -fvisibility-inlines-hidden (alongside -fvisibility=hidden), aiming to make inline methods/destructors less ABI-fragile in the produced shared libraries.
Changes:
- Add
-fvisibility-inlines-hiddento the Make-based build visibility flags. - Add
-fvisibility-inlines-hiddento Bazelcoptsfor both DAL and DAAL modules (non-Windows builds).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
makefile |
Extends the non-Windows visibility flags to include -fvisibility-inlines-hidden. |
dev/bazel/dal.bzl |
Adds -fvisibility-inlines-hidden to default (non-Windows) Bazel C++ compile options for DAL modules. |
dev/bazel/daal.bzl |
Adds -fvisibility-inlines-hidden to default (non-Windows) Bazel C++ compile options for DAAL modules. |
| copts = copts + select({ | ||
| "@platforms//os:windows": [], | ||
| "//conditions:default": ["-fvisibility=hidden"], | ||
| "//conditions:default": ["-fvisibility=hidden", "-fvisibility-inlines-hidden"], | ||
| }), |
There was a problem hiding this comment.
Same as in dev/bazel/dal.bzl: //conditions:default enables -fvisibility-inlines-hidden on all non-Windows OSes, not just Linux. If the experiment is Linux-only, please scope this flag to @platforms//os:linux to avoid unintended ABI/symbol-visibility changes on macOS.
| -optlevel := $(-optlevel.$(COMPILER)) | ||
| -fPIC := $(if $(OS_is_win),,-fPIC) | ||
| -visibility := $(if $(OS_is_win),,-fvisibility=hidden) | ||
| -visibility := $(if $(OS_is_win),,-fvisibility=hidden -fvisibility-inlines-hidden) |
There was a problem hiding this comment.
The PR title/description says this experiment is for Linux, but this Makefile flag is enabled for all non-Windows platforms (including macOS). If the intent is Linux-only (ELF ABI surface reduction), gate -fvisibility-inlines-hidden behind OS_is_lnx (or equivalent) so macOS builds/ABI aren’t affected unintentionally.
| "@platforms//os:windows": [], | ||
| "//conditions:default": ["-fvisibility=hidden"], | ||
| "//conditions:default": ["-fvisibility=hidden", "-fvisibility-inlines-hidden"], | ||
| }), |
There was a problem hiding this comment.
This applies -fvisibility-inlines-hidden to every non-Windows Bazel build via //conditions:default, which includes macOS as well. If this PR is meant to be Linux-only (per title), please restrict the flag to @platforms//os:linux (and leave other OSes unchanged) to avoid changing symbol visibility/ABI on macOS unexpectedly.
Description
Implements a better solution to the problem of the ABI fragility caused by the inline methods, including destructors.
See the problem description in the PR #3591; also read this blog post for better understanding of the problem and the solution:
https://holyblackcat.github.io/blog/2025/12/01/visibility-inlines-hidden.html
abicheck tool summary:
ABI Report: libonedal_core.so
COMPATIBLE_WITH_RISKABI Report: libonedal.so
COMPATIBLE_WITH_RISKABI Report: libonedal_dpc.so
COMPATIBLE_WITH_RISKABI Report: libonedal_parameters.so
COMPATIBLE_WITH_RISKABI Report: libonedal_parameters_dpc.so
COMPATIBLE_WITH_RISKABI Report: libonedal_thread.so
COMPATIBLEChecklist:
Completeness and readability
The changes are small and self-descriptive.
Testing
No new functionality was introduced, though the ABI testing mechanism should be improved, but not in this PR.
Performance
Not applicable.