<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: segmentation fault when linking libc and mkl statically in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/segmentation-fault-when-linking-libc-and-mkl-statically/m-p/1344049#M32447</link>
    <description>&lt;P&gt;Hi Karl,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt;&lt;I&gt;how I can link libgcc AND mkl statically (with clang++) *without* having a segfault in case an exceptions is thrown.&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please try with the below command and let us know if it helps in resolving the issue?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;clang++ -march=native -O3 -qmkl -Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_intel_ilp64.a ${MKLROOT}/lib/intel64/libmkl_sequential.a ${MKLROOT}/lib/intel64/libmkl_core.a -Wl,--end-group -lpthread -lm -ldl -static-libgcc -static &amp;lt;file.cpp&amp;gt;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please find the below screenshot for more details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="VidyalathaB_Intel_0-1639504123158.png" style="width: 400px;"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/24831i04B5E5D8975DEB6A/image-size/medium?v=v2&amp;amp;px=400&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" role="button" title="VidyalathaB_Intel_0-1639504123158.png" alt="VidyalathaB_Intel_0-1639504123158.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Vidya.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 14 Dec 2021 17:49:05 GMT</pubDate>
    <dc:creator>VidyalathaB_Intel</dc:creator>
    <dc:date>2021-12-14T17:49:05Z</dc:date>
    <item>
      <title>segmentation fault when linking libc and mkl statically</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/segmentation-fault-when-linking-libc-and-mkl-statically/m-p/1342273#M32401</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the following program crashes when libc and mkl are both linked statically. I found this for compilers g++ and intel clang++ for linux kernels 5.10 and 3.10. Under kernel 3.10 the crash occurs with g++/libc version &amp;gt;=8.3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;#include &amp;lt;string&amp;gt;
#include &amp;lt;iostream&amp;gt;
#include "mkl.h"
void zzzz(){
  double *z,*zz;
  double x=cblas_ddot(10,z,1,zz,1);
}
int main(int argc, char** argv){
  std::string msg;
  try{
    msg="bla";throw msg;
  }catch(std::string msg){
    std::cout&amp;lt;&amp;lt;"an error has occured."&amp;lt;&amp;lt;std::endl;
    return(1);
  }
  return(0);
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the makefile was&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="bash"&gt;SHELL := /bin/bash
intel_loc=/opt/intel
export LD_LIBRARY_PATH=$(intel_loc)/oneapi/compiler/2021.2.0/linux/compiler/lib/intel64_lin:$LD_LIBRARY_PATH
a=$(shell source $(intel_loc)/oneapi/setvars.sh; echo $$PATH)
export PATH = $(a)
gnu:
	g++ -march=native -O3 -ffast-math -static -static-libstdc++ main1.cpp -I /opt/intel/oneapi/mkl/2021.2.0//include/ -I /opt/intel/oneapi/mkl/2021.2.0//include/intel64/ilp64 -Wl,--start-group /opt/intel/oneapi/mkl/2021.2.0//lib/intel64/libmkl_intel_ilp64.a /opt/intel/oneapi/mkl/2021.2.0//lib/intel64/libmkl_core.a /opt/intel/oneapi/mkl/2021.2.0//lib/intel64/libmkl_sequential.a -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -lm -ldl
iclang:
	clang++ -march=native -O3 -static  -static-libstdc++ main1.cpp -I /opt/intel/oneapi/mkl/2021.2.0//include/ -I /opt/intel/oneapi/mkl/2021.2.0//include/intel64/ilp64 -Wl,--start-group /opt/intel/oneapi/mkl/2021.2.0//lib/intel64/libmkl_intel_ilp64.a /opt/intel/oneapi/mkl/2021.2.0//lib/intel64/libmkl_core.a /opt/intel/oneapi/mkl/2021.2.0//lib/intel64/libmkl_sequential.a -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -lm -ldl
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A workaround is to change from "-static" to "-static-intel". However any other suggestions/workaround for this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 22:50:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/segmentation-fault-when-linking-libc-and-mkl-statically/m-p/1342273#M32401</guid>
      <dc:creator>may_ka</dc:creator>
      <dc:date>2021-12-07T22:50:25Z</dc:date>
    </item>
    <item>
      <title>Re: segmentation fault when linking libc and mkl statically</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/segmentation-fault-when-linking-libc-and-mkl-statically/m-p/1342450#M32408</link>
      <description>&lt;P&gt;Hi Karl,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for reaching out to us.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;I&gt;&amp;gt;&amp;gt; A workaround is to change from "-static" to "-static-intel"&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you wanted to link the MKL statically you need to use -static-intel flag during compiling your code, as per the documentation when you use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;-static &lt;/STRONG&gt; --- It prevents the code from linking with shared libraries&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;-static-intel&lt;/STRONG&gt; --- It is used to link the Intel provided libraries statically&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please refer to the below documentation link for more details&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.intel.com/content/www/us/en/develop/documentation/oneapi-dpcpp-cpp-compiler-dev-guide-and-reference/top/compiler-reference/compiler-options/alphabetical-list-of-compiler-options.html" target="_blank" rel="noopener"&gt;https://www.intel.com/content/www/us/en/develop/documentation/oneapi-dpcpp-cpp-compiler-dev-guide-and-reference/top/compiler-reference/compiler-options/alphabetical-list-of-compiler-options.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Vidya.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Dec 2021 12:40:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/segmentation-fault-when-linking-libc-and-mkl-statically/m-p/1342450#M32408</guid>
      <dc:creator>VidyalathaB_Intel</dc:creator>
      <dc:date>2021-12-08T12:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: segmentation fault when linking libc and mkl statically</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/segmentation-fault-when-linking-libc-and-mkl-statically/m-p/1342472#M32409</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thank you for your response.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am aware that for clang++ the workaround flags are "-static -shared-libgcc" and for icpc "-static-intel" .....................&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, the question was how I can link libgcc AND mkl statically (with clang++) *without* having a segfault in case an exceptions is thrown.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best&lt;/P&gt;</description>
      <pubDate>Wed, 08 Dec 2021 13:10:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/segmentation-fault-when-linking-libc-and-mkl-statically/m-p/1342472#M32409</guid>
      <dc:creator>may_ka</dc:creator>
      <dc:date>2021-12-08T13:10:57Z</dc:date>
    </item>
    <item>
      <title>Re: segmentation fault when linking libc and mkl statically</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/segmentation-fault-when-linking-libc-and-mkl-statically/m-p/1344049#M32447</link>
      <description>&lt;P&gt;Hi Karl,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;gt;&lt;I&gt;how I can link libgcc AND mkl statically (with clang++) *without* having a segfault in case an exceptions is thrown.&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please try with the below command and let us know if it helps in resolving the issue?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;clang++ -march=native -O3 -qmkl -Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_intel_ilp64.a ${MKLROOT}/lib/intel64/libmkl_sequential.a ${MKLROOT}/lib/intel64/libmkl_core.a -Wl,--end-group -lpthread -lm -ldl -static-libgcc -static &amp;lt;file.cpp&amp;gt;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please find the below screenshot for more details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="VidyalathaB_Intel_0-1639504123158.png" style="width: 400px;"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/24831i04B5E5D8975DEB6A/image-size/medium?v=v2&amp;amp;px=400&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" role="button" title="VidyalathaB_Intel_0-1639504123158.png" alt="VidyalathaB_Intel_0-1639504123158.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Vidya.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Dec 2021 17:49:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/segmentation-fault-when-linking-libc-and-mkl-statically/m-p/1344049#M32447</guid>
      <dc:creator>VidyalathaB_Intel</dc:creator>
      <dc:date>2021-12-14T17:49:05Z</dc:date>
    </item>
    <item>
      <title>Re:segmentation fault when linking libc and mkl statically</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/segmentation-fault-when-linking-libc-and-mkl-statically/m-p/1345579#M32475</link>
      <description>&lt;P&gt;Hi Karl,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Reminder:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Has the solution provided above helped? If yes, could you please confirm whether we can close this thread from our end?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vidya.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 21 Dec 2021 05:06:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/segmentation-fault-when-linking-libc-and-mkl-statically/m-p/1345579#M32475</guid>
      <dc:creator>VidyalathaB_Intel</dc:creator>
      <dc:date>2021-12-21T05:06:12Z</dc:date>
    </item>
    <item>
      <title>Re:segmentation fault when linking libc and mkl statically</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/segmentation-fault-when-linking-libc-and-mkl-statically/m-p/1347314#M32510</link>
      <description>&lt;P&gt;Hi Karl,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;As we have not heard back from you, we are closing this thread assuming that your issue is resolved. &lt;/P&gt;&lt;P&gt;Please post a new question if you need any additional information from Intel as this thread will no longer be monitored.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vidya.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 29 Dec 2021 07:51:58 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/segmentation-fault-when-linking-libc-and-mkl-statically/m-p/1347314#M32510</guid>
      <dc:creator>VidyalathaB_Intel</dc:creator>
      <dc:date>2021-12-29T07:51:58Z</dc:date>
    </item>
  </channel>
</rss>

