Skip to content

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

Open
Evstifeev Mikhail (mievst) wants to merge 1 commit into
microsoft:mainfrom
mievst:fix-musl-execinfo
Open

Evstifeev Mikhail (mievst) wants to merge 1 commit into
microsoft:mainfrom
mievst:fix-musl-execinfo

Conversation

@mievst

Copy link
Copy Markdown

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
Author

@microsoft-github-policy-service agree

This branch has not been deployed

No deployments
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.

1 participant