Segmentation fault in linking
@ap87no Like someone else in the help-archive, I'm getting a segmentation fault when I try to link the files I've compiled, which are mostly .c, and only one .cpp file which calls into all the .c code.
clang-16: error: unable to execute command: Segmentation fault
clang-16: error: optimizer command failed due to signal (use -v to see invocation)
I've been able to fix this a couple of times as I slowly add in more code, but I am now blocked. Through trial and error, I've found if I comment out a particular function call, it succeeds. But if I call that function from file2.c, I get the seg. fault. Meanwhile, that function is called from file1.c and links just fine.
If I give you a copy of the .bc files and the command to link them into the final wasm, is that enough for you to diagnose the problem? Or would you need the source code too? I'm sure the source code would help, but I'd need to obfuscate it so I don't give away my company's code.
6 Replies
The
bc
files are enough, to begin with you might also considering sharing the stacktraceHere is everything I get back including the stacktrace:
@ap87no see your DMs for the .bc and build.sh files
The issue is actually clear, there is a global value being used but not defined
The function you are commenting to fix the problem is using the global, you should try compiling with
-cheerp-strict-linking=warning
to see the names of all symbols being missing
In this case I could find it for you Ctype = external local_unnamed_addr global [0 x i8], align 1
Thank you! I think the strict linking param will help. That gives me several others in addition to Ctype
Take into account that it is, in most cases, safe to leave symbols undefined. It is often convenient to link code only as it is first used when porting a codebase
Variables, in particular, needs to be defined though