Skip to content

Experiment: Reduce the ABI surface on Linux with '-fvisibility-inlines-hidden'#3604

Merged
Vika-F merged 1 commit intouxlfoundation:mainfrom
Vika-F:dev/abi_inlines_hidden
Apr 15, 2026
Merged

Experiment: Reduce the ABI surface on Linux with '-fvisibility-inlines-hidden'#3604
Vika-F merged 1 commit intouxlfoundation:mainfrom
Vika-F:dev/abi_inlines_hidden

Conversation

@Vika-F
Copy link
Copy Markdown
Contributor

@Vika-F Vika-F commented Apr 10, 2026

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

Verdict ⚠️ COMPATIBLE_WITH_RISK
Breaking changes 0
Source-level breaks 0
Deployment risk changes 2
Compatible changes 2137

⚠️ Deployment Risk Changes

These changes are binary-compatible but may cause the library to fail
loading on older systems (e.g. a new GLIBC version requirement). Verify
your target environment before deploying.

  • symbol_leaked_from_dependency_changed: Symbol 'std::vector<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::allocator<std::__cxx11::basic_string<char, std::char_traits, std::allocator > > >::push_back(std::__cxx11::basic_string<char, std::char_traits, std::allocator >&&)' was removed but appears to originate from 'libstdc++.so.6' (a dependency of this library). This is a real ABI change — the library is leaking dependency symbols into its public ABI surface. Consider applying -fvisibility=hidden.
  • symbol_leaked_from_dependency_changed: Symbol 'std::vector<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::allocator<std::__cxx11::basic_string<char, std::char_traits, std::allocator > > >::~vector()' was removed but appears to originate from 'libstdc++.so.6' (a dependency of this library). This is a real ABI change — the library is leaking dependency symbols into its public ABI surface. Consider applying -fvisibility=hidden.

ABI Report: libonedal.so

Verdict ⚠️ COMPATIBLE_WITH_RISK
Breaking changes 0
Source-level breaks 0
Deployment risk changes 51
Compatible changes 353

⚠️ Deployment Risk Changes

These changes are binary-compatible but may cause the library to fail
loading on older systems (e.g. a new GLIBC version requirement). Verify
your target environment before deploying.

  • symbol_leaked_from_dependency_changed: Symbol 'std::__detail::__variant::_Variant_storage<false, std::shared_ptr, std::shared_ptr >::_M_reset()' was removed but appears to originate from 'libstdc++.so.6' (a dependency of this library). This is a real ABI change — the library is leaking dependency symbols into its public ABI surface. Consider applying -fvisibility=hidden.
  • symbol_leaked_from_dependency_changed: Symbol 'std::map<unsigned long, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const, std::less, std::allocator<std::pair<unsigned long const, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const> > >::~map()' was removed but appears to originate from 'libstdc++.so.6' (a dependency of this library). This is a real ABI change — the library is leaking dependency symbols into its public ABI surface. Consider applying -fvisibility=hidden.
  • symbol_leaked_from_dependency_changed: Symbol 'std::enable_if<((__exactly_once<std::_Nth_type<__accepted_index<std::shared_ptr&&>, std::shared_ptr, std::shared_ptr >::type>)&&(is_constructible_v<std::_Nth_type<__accepted_index<std::shared_ptr&&>, std::shared_ptr, std::shared_ptr >::type, std::shared_ptr >))&&(is_assignable_v<std::_Nth_type<__accepted_index<std::shared_ptr&&>, std::shared_ptr, std::shared_ptr >::type&, std::shared_ptr >), std::variant<std::shared_ptr, std::shared_ptr >&>::type std::variant<std::shared_ptr, std::shared_ptr >::operator=<std::shared_ptr >(std::shared_ptr&&)' was removed but appears to originate from 'libstdc++.so.6' (a dependency of this library). This is a real ABI change — the library is leaking dependency symbols into its public ABI surface. Consider applying -fvisibility=hidden.
  • ...

ABI Report: libonedal_dpc.so

Verdict ⚠️ COMPATIBLE_WITH_RISK
Breaking changes 0
Source-level breaks 0
Deployment risk changes 115
Compatible changes 452

⚠️ Deployment Risk Changes

These changes are binary-compatible but may cause the library to fail
loading on older systems (e.g. a new GLIBC version requirement). Verify
your target environment before deploying.

  • symbol_leaked_from_dependency_changed: Symbol 'std::__detail::__variant::_Variant_storage<false, std::shared_ptr, std::shared_ptr >::~_Variant_storage()' was removed but appears to originate from 'libstdc++.so.6' (a dependency of this library). This is a real ABI change — the library is leaking dependency symbols into its public ABI surface. Consider applying -fvisibility=hidden.
  • symbol_leaked_from_dependency_changed: Symbol 'std::__detail::__variant::_Variant_storage<false, std::shared_ptr, std::shared_ptr >::_M_reset()' was removed but appears to originate from 'libstdc++.so.6' (a dependency of this library). This is a real ABI change — the library is leaking dependency symbols into its public ABI surface. Consider applying -fvisibility=hidden.
  • symbol_leaked_from_dependency_changed: Symbol 'std::__detail::__variant::_Variant_storage<false, std::shared_ptr, std::shared_ptr >::_M_reset()' was removed but appears to originate from 'libstdc++.so.6' (a dependency of this library). This is a real ABI change — the library is leaking dependency symbols into its public ABI surface. Consider applying -fvisibility=hidden.
  • ...

ABI Report: libonedal_parameters.so

Verdict ⚠️ COMPATIBLE_WITH_RISK
Breaking changes 0
Source-level breaks 0
Deployment risk changes 10
Compatible changes 23

ABI Report: libonedal_parameters_dpc.so

Verdict ⚠️ COMPATIBLE_WITH_RISK
Breaking changes 0
Source-level breaks 0
Deployment risk changes 10
Compatible changes 28

ABI Report: libonedal_thread.so

Verdict COMPATIBLE
Breaking changes 0
Source-level breaks 0
Deployment risk changes 0
Compatible changes 1

Checklist:

Completeness and readability

  • I have commented my code, particularly in hard-to-understand areas.
    The changes are small and self-descriptive.
  • Git commit message contains an appropriate signed-off-by string (see CONTRIBUTING.md for details).
  • I have resolved any merge conflicts that might occur with the base branch.

Testing

  • I have run it locally and tested the changes extensively.
  • All CI jobs are green or I have provided justification why they aren't.
  • I have extended testing suite if new functionality was introduced in this PR.

No new functionality was introduced, though the ABI testing mechanism should be improved, but not in this PR.

Performance

Not applicable.

@david-cortes-intel
Copy link
Copy Markdown
Contributor

@Vika-F What about MSVC?

@david-cortes-intel
Copy link
Copy Markdown
Contributor

@Vika-F What about MSVC?

Took a look at the article, not required on msvc.

@Vika-F
Copy link
Copy Markdown
Contributor Author

Vika-F commented Apr 10, 2026

@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 abidiff will consider this PR an ABI-breaking as it removes a lot of inlines from the ABI, but this can lead to a real ABI breakage in rare cases.
So, we need to re-consider the ABI checking mechanism.

@Vika-F Vika-F changed the title Experiment: Reduce ABI surface with '-fvisibility-inlines-hidden' Experiment: Reduce the ABI surface on Linux with '-fvisibility-inlines-hidden' Apr 10, 2026
Copy link
Copy Markdown
Contributor

@david-cortes-intel david-cortes-intel left a comment

Choose a reason for hiding this comment

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

LGTM, but deferring to @Alexandr-Solovev about ABI part.

@Vika-F
Copy link
Copy Markdown
Contributor Author

Vika-F commented Apr 13, 2026

/intelci: run

@Vika-F Vika-F marked this pull request as ready for review April 14, 2026 08:54
Copilot AI review requested due to automatic review settings April 14, 2026 08:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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-hidden to the Make-based build visibility flags.
  • Add -fvisibility-inlines-hidden to Bazel copts for 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.

Comment thread dev/bazel/daal.bzl
Comment on lines 55 to 58
copts = copts + select({
"@platforms//os:windows": [],
"//conditions:default": ["-fvisibility=hidden"],
"//conditions:default": ["-fvisibility=hidden", "-fvisibility-inlines-hidden"],
}),
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment thread makefile
-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)
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment thread dev/bazel/dal.bzl
Comment on lines 498 to 500
"@platforms//os:windows": [],
"//conditions:default": ["-fvisibility=hidden"],
"//conditions:default": ["-fvisibility=hidden", "-fvisibility-inlines-hidden"],
}),
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@Vika-F Vika-F merged commit 867c643 into uxlfoundation:main Apr 15, 2026
37 of 42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants