Kurt Harriman
2005-Nov-21 22:50 UTC
[LLVMdev] setjmp/longjmp interoperable between llvm and gcc?
Hi, I would like to build an x86 executable consisting of a number of subsystems (mostly legacy C code). One subsystem will be compiled to native code using llvm. It calls, and is called by, the other subsystems, many of which have to be compiled using gcc because they use small amounts of inline assembly. All of the subsystems catch and throw errors to one another using setjmp/longjmp. When gcc-built code calls longjmp(), the destination might be a setjmp() in llvm-built code, and vice versa. At present the gcc-built code uses the setjmp/longjmp implementations provided by the gnu C library; and presumably the llvm-built code will use llvm's setjmp/longjmp intrinsics. Are the two implementations safely interoperable? Alternatives would be to force the llvm-built code to use the libgc setjmp/longjmp; force the gcc-built code to use a setjmp/longjmp borrowed from llvm; or perhaps make each setjmp tag the jmpbuf to show which flavor of longjmp is required. Regards, ... kurt
Chris Lattner
2005-Nov-21 22:53 UTC
[LLVMdev] setjmp/longjmp interoperable between llvm and gcc?
On Mon, 21 Nov 2005, Kurt Harriman wrote:> When gcc-built code calls longjmp(), the destination might be a > setjmp() in llvm-built code, and vice versa. At present the > gcc-built code uses the setjmp/longjmp implementations provided > by the gnu C library; and presumably the llvm-built code will use > llvm's setjmp/longjmp intrinsics. Are the two implementations > safely interoperable?No, not right now. EH in general doesn't interoperate. This will be fixed in the future, but is problematic for the time being.> Alternatives would be to force the llvm-built code to use the libgc > setjmp/longjmp; force the gcc-built code to use a setjmp/longjmp > borrowed from llvm; or perhaps make each setjmp tag the jmpbuf to > show which flavor of longjmp is required.I depends on what sort of thing you want to do. Another option is to compile everything with LLVM if possible. -Chris -- http://nondot.org/sabre/ http://llvm.org/