Compiling master from source on alpine fails with undefined reference to backtrace

username: kldavis4
cooked: <p>I’m using this docker image with latest master (as well as v1.3.1) <a href="https://github.com/stephwag/pytorch-alpine/blob/master/Dockerfile" rel="nofollow noopener">https://github.com/stephwag/pytorch-alpine/blob/master/Dockerfile</a></p>
<p>According to what I’ve found elsewhere, libexecinfo-dev provides /usr/lib/libexecinfo.so which provides backtrace, but it doesn’t seem to find it.</p>
<p>Here is the error I am seeing:</p>
<pre><code class="lang-auto">[ 36%] Linking CXX executable ../../bin/c10_tempfile_test
/usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: ../../lib/libc10.so: undefined reference to `backtrace'
/usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: ../../lib/libc10.so: undefined reference to `backtrace_symbols'
collect2: error: ld returned 1 exit status
make[2]: *** [c10/test/CMakeFiles/c10_tempfile_test.dir/build.make:89: bin/c10_tempfile_test] Error 1
make[1]: *** [CMakeFiles/Makefile2:2158: c10/test/CMakeFiles/c10_tempfile_test.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 36%] Building CXX object third_party/ideep/mkl-dnn/src/CMakeFiles/mkldnn.dir/cpu/gemm/s8x8s32/ref_gemm_s8x8s32.cpp.o
[ 36%] Generating src/x86_64-fma/blas/shdotxf.py.o
[ 37%] Linking CXX executable ../../bin/c10_typeid_test
/usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: ../../lib/libc10.so: undefined reference to `backtrace'
/usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: ../../lib/libc10.so: undefined reference to `backtrace_symbols'
collect2: error: ld returned 1 exit status
make[2]: *** [c10/test/CMakeFiles/c10_typeid_test.dir/build.make:89: bin/c10_typeid_test] Error 1
make[1]: *** [CMakeFiles/Makefile2:2118: c10/test/CMakeFiles/c10_typeid_test.dir/all] Error 2
</code></pre>

username: albanD
cooked: <p>From that google search: <a href="https://github.com/openalpr/openalpr/issues/566">https://github.com/openalpr/openalpr/issues/566</a> it seems like <code>musl</code> does not provide the <code>backtrace</code> function. So I guess you will have to use glibc to be able to compute pytorch.</p>
<p><a class="mention" href="/u/gchanan">@gchanan</a> is musl something we would like to add support for in the future?</p>

username: kldavis4
cooked: <p>My understanding is that libexecinfo-dev provides this library (<a href="https://www.freshports.org/devel/libexecinfo" rel="nofollow noopener">https://www.freshports.org/devel/libexecinfo</a>). It doesn’t seem to link it correctly, though.</p>

username: albanD
cooked: <p>Is our build system even trying to link to it? In the sense that we don’t need it with glibc.</p>
<p>Maybe try to <code>LD_PRELOAD</code> it to see if this is really the issue?</p>

username: kldavis4
cooked: <aside class="quote no-group" data-username="albanD" data-post="4" data-topic="64676">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/alband/48/215_2.png" class="avatar"> albanD:</div>
<blockquote>
<p>Maybe try to <code>LD_PRELOAD</code> it to see if this is really the issue?</p>
</blockquote>
</aside>
<p>Sure, I’ll try LD_PRELOAD and see if that links it</p>

username: albanD
cooked: <p>It won’t link it, but it will make these symbols available <img src="https://discuss.pytorch.org/images/emoji/apple/smiley.png?v=9" title=":smiley:" class="emoji" alt=":smiley:"></p>

username: kldavis4
cooked: <p>Got it - thanks! <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=9" title=":slight_smile:" class="emoji" alt=":slight_smile:"></p>

username: kldavis4
cooked: <p>hmm, same error with <code>LD_PRELOAD=/usr/lib/libexecinfo.so python setup.py install</code></p>

username: thammada
cooked: <p>Were you able to solve this?</p>

username: kldavis4
cooked: <p>Unfortunately I was not able to resolve it. I ended up just using a non-alpine image.</p>

username: StrawVulcan
cooked: <p>If it’s not a ton of trouble, I would really appreciate being able to build PyTorch for Alpine.</p>

username: edwardxwu
cooked: <p>execinfo is only used in 1-2 files so you could comment out the header and set SUPPORTS_BACKTRACE to 0 to remove it. worked for me on alpine and 1.4</p>