Skip to content

Include <execinfo.h> only where backtrace() is used - #1554

Merged
bmehta001 merged 1 commit into
microsoft:mainfrom
mievst:fix-musl-execinfo
Nov 5, 2026
Merged

bmehta001 merged 1 commit into
microsoft:mainfrom
mievst:fix-musl-execinfo

Conversation

@mievst

Copy link
Copy Markdown
Contributor

lib/utils/Utils.hpp includes <execinfo.h> on every non-Android __unix__ target. The header is glibc-specific and musl (Alpine Linux) does not provide it, so the SDK fails to compile there:

lib/utils/Utils.hpp:37:10: fatal error: execinfo.h: No such file or directory

The only user of the header is print_backtrace() in lib/utils/Utils.cpp, and only under USE_BACKTRACE. This change moves the include there, under the same condition. Builds without USE_BACKTRACE (all regular builds) no longer depend on the header.

This breaks ONNX Runtime builds on Alpine, which build the SDK by default since 1DS became their telemetry backend: microsoft/onnxruntime#33827.

Tested:

  • ONNX Runtime 1.31.0 on Alpine 3.23.7 (gcc 15.2.0, musl) with default telemetry and the pinned SDK v3.10.279.1 plus this change: builds, libmat.a links, the Python wheel runs a model. Without the change it fails with the error above.
  • SDK main with this change on Debian 13 (gcc 14.2.0, glibc 2.41): mat builds.

Note, not changed here: with -DUSE_BACKTRACE on GCC print_backtrace() does not compile, with or without this change. mat_demangle is the identity macro there (_CPPRTTI is MSVC-only), so mat_demangle(strings[i]).c_str() is called on a char*.

Utils.hpp included <execinfo.h> on every non-Android __unix__ target, but only
print_backtrace() in Utils.cpp needs it, and only under USE_BACKTRACE. musl
(Alpine Linux) does not provide the header, so the SDK failed to compile there.
This also breaks ONNX Runtime builds on Alpine, which build the SDK by default
since 1DS became their telemetry backend (microsoft/onnxruntime#33827).
@mievst
Evstifeev Mikhail (mievst) requested a review from a team as a code owner November 2, 2026 22:23
@mievst

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the change addressing compilation failures on musl-based systems.

No open issues 🎉

What changed in this PR

Removes the SDK’s dependency on <execinfo.h> for regular builds, addressing the reported compilation failure on musl-based systems such as Alpine Linux.

Changes:

  • Removes <execinfo.h> from the shared utility header.
  • Includes it in Utils.cpp only when USE_BACKTRACE and __unix__ are defined.
File Description
lib/​utils/​Utils.hpp Removes the transitive dependency on <execinfo.h>.
lib/​utils/​Utils.cpp Places the include alongside its backtrace usage, under the matching condition.

Review effort: Balanced

@bmehta001
bmehta001 enabled auto-merge (squash) November 5, 2026 05:58
@bmehta001

Copy link
Copy Markdown
Contributor

Evstifeev Mikhail (@mievst) Thank you for identifying the problem and creating a fix. I will try to get this into a new release for ORT ASAP

@bmehta001
bmehta001 merged commit dac58c6 into microsoft:main Nov 5, 2026
93 of 94 checks passed
@mievst
Evstifeev Mikhail (mievst) deleted the fix-musl-execinfo branch November 5, 2026 07:53
@mievst

Copy link
Copy Markdown
Contributor Author

Thanks for the quick review!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants