- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there,
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 >=8.3.
#include <string>
#include <iostream>
#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<<"an error has occured."<<std::endl;
return(1);
}
return(0);
}
the makefile was
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
A workaround is to change from "-static" to "-static-intel". However any other suggestions/workaround for this?
Thanks
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Karl,
Thanks for reaching out to us.
>> A workaround is to change from "-static" to "-static-intel"
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
-static --- It prevents the code from linking with shared libraries
-static-intel --- It is used to link the Intel provided libraries statically
Please refer to the below documentation link for more details
Regards,
Vidya.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
thank you for your response.
I am aware that for clang++ the workaround flags are "-static -shared-libgcc" and for icpc "-static-intel" .....................
However, the question was how I can link libgcc AND mkl statically (with clang++) *without* having a segfault in case an exceptions is thrown.
Best
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Karl,
>>how I can link libgcc AND mkl statically (with clang++) *without* having a segfault in case an exceptions is thrown.
Could you please try with the below command and let us know if it helps in resolving the issue?
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 <file.cpp>
Please find the below screenshot for more details.
Regards,
Vidya.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Karl,
Reminder:
Has the solution provided above helped? If yes, could you please confirm whether we can close this thread from our end?
Regards,
Vidya.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Karl,
As we have not heard back from you, we are closing this thread assuming that your issue is resolved.
Please post a new question if you need any additional information from Intel as this thread will no longer be monitored.
Regards,
Vidya.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page