From whahappan+e8 at gmail.com Mon Jan 9 15:51:28 2006 From: whahappan+e8 at gmail.com (whahappan+e8 at gmail.com) Date: Mon, 9 Jan 2006 18:51:28 +0300 Subject: [fetter-devel] mostly Windows/VC++ issues (name mangling, calling conventions and exception handling) Message-ID: <7d6004c70601090751o4f7439f7qc29843a97a91ccc5@mail.gmail.com> Hi, First, I want to tell that Verrazano is a superb project, (potentially) enabling a new level of CL/C++ integration; great work, Rayiner! (Btw, what license does Vzn come with? I wasn't able to find any information on this. I think this license uncertainty may hinder Vzn adoption by some people (e.g. is Vzn GPL or LLGPL, BSD is a significant matter for both open- and closed source projects)) Second, there are some apparent problems (most are Windows/VC++ specific): 1. Calling conventions for member functions VC++ by default uses __thiscall calling convention for class member functions which on x86 platforms does pass 'this' pointer in ECX register rather as hidden first parameter on stack and is obviously unsupported by CFFI. Alternate calling convention could be specified, but that is not always possible. 2. Name mangling VC++ name mangling scheme is incompatible with GCC's one and is undocumented (there are ways to demangle a name to a human-readable form, but again output format is not really specified) Specifying 'extern "C"' for C++ functions doesn't solve entire problem since such functions cannot have C++ data types as return values (compiler allows only POD types here) 3. Exception handling (not MS-specific, applies to GCC) C++ exceptions, which are integral part of many C++ APIs, must be handled properly to achieve full CL/C++ interface. As there are no CL implementations capable of catching C++ exceptions along the FFI to my knowledge, this must be handled by Verrazano or its runtime. Below is description of my vision of how these problems could be solved, but before I would like to see Rayiner's opinion on this, since, undoubtedly, these problems (at least exception handling) ought to be considered when Verrazano was conceived; maybe I overlooked something. One solution to these problems could be introducing automatically generated C-compatible wrapper functions for all C++ function calls and global variable access. (In fact, the assumption that C++ functions could be used transparently through C-oriented FFIs and that C++ ABI for given compiler is compatible with its C equivalent is not really true, at least on Windows platforms, so going through C layer may be the only correct solution) This generated wrapper function should do the following: 1. Perform actual C++ function/method/operator/etc. call 2. Pass return value through additional pointer argument 3. Provide C++ exception handler with catch(...) to enable correct stack unwinding 4. Provide C++ exception run-time type information (this is impossible in standard C++, but for two major special cases, GCC and VC++, this could be done; I have working code for VC++) There should be an additional CL wrapper for return value handling and exception translation. There's an example of C++ wrapper function: extern "C" vzn_status __declspec(dllexport) wrapper_(Type *self, , Return_type *retval, Vzn_cxx_exception_info *exception_info) { try { *retval = self->method() return vzn_success; } catch (...) { some_magic(exception_info); // extracts exception information from compiler-generated // data in unportable way return vzn_exception; } } In principle, exception handling could be performed entirely on CL side in CFFI-portable way (at least on win32), but correct C++ stack unwinding seems to be next to impossible (this is completely undocumented matter in case of VC++) Next, there's problem about C++ name translation: when there are spaces, colons or commas in C++ name (which is often the case with templates and namespaces), it doesn't work. I made a patch (vzn:translate-name) that forces C++ names into |...| form when there are symbols that clash with CL readtable (I could provide the patch, however it's very simple, just few lines) Also, there's another problem I found (cvs snapshot from 05012005): Vzn does not generate CFFI descriptions for template instantiations (which are more or less equivalent to non-templates for practical matters). E.g. if we have a function returning std::basic_string<...>, Vzn doesn't generate cffi:defcstruct for it; as a result CFFI complains about unknown type. What would the best place to look into this (I'm not really understand the whole codebase, so I'm asking first)? Regards, Vladimir From tuchol at gmail.com Wed Jan 18 07:23:36 2006 From: tuchol at gmail.com (Boris Tschirschwitz) Date: Wed, 18 Jan 2006 08:23:36 +0100 Subject: [fetter-devel] testsuit problem Message-ID: <651881340601172323m97042dfpf02ba0ae8968b653@mail.gmail.com> Hi. I was trying to run the cairo demo (on an iBook with OS X.4.4), getting the following output: ; SLIME 2005-12-27 CL-USER> (require 'verrazano) ; loading system definition from /Users/tucho/.sbcl/systems/parse-number.asd ; into # ; registering # as PARSE-NUMBER ; loading system definition from /Users/tucho/.sbcl/systems/split-sequence.asd ; into # ; registering # as SPLIT-SEQUENCE ; loading system definition from /Users/tucho/.sbcl/systems/s-xml.asd into ; # ; registering # as S-XML NIL CL-USER> (load "/Users/tucho/builds/verrazano/testsuite/cairo/generate.lisp") An error occurred generating a temporary C++ file ; Evaluation aborted Where is the temporary C++ file generated? Thanks. From root at common-lisp.net Wed Jan 18 16:23:30 2006 From: root at common-lisp.net (root) Date: Wed, 18 Jan 2006 10:23:30 -0600 (CST) Subject: [fetter-devel] Auto-nag: fetter link verifier failed Message-ID: <20060118162330.D3AD72F3EB@common-lisp.net> You are being nagged on because your project's name showed up in the nightly Checkbot run. Checkbot checks for broken links etc. This probably means that you are either pointing to a broken link or that someone is pointing to a broken link on your site. Or something else, it check's a bunch of stuff. Update your webpages or you shall be nagged again next week. To find out what's wrong with your webpages, please consult: http://common-lisp.net/checkbot/checkbot-common-lisp.net.html Any questions? You can reach the author of this cronjob at admin at common-lisp.net Thanks! From root at common-lisp.net Mon Jan 23 08:15:20 2006 From: root at common-lisp.net (root) Date: Mon, 23 Jan 2006 02:15:20 -0600 (CST) Subject: [fetter-devel] Auto-nag: fetter link verifier failed Message-ID: <20060123081520.D2B98102F4@common-lisp.net> You are being nagged on because your project's name showed up in the nightly Checkbot run. Checkbot checks for broken links etc. This probably means that you are either pointing to a broken link or that someone is pointing to a broken link on your site. Or something else, it check's a bunch of stuff. Update your webpages or you shall be nagged again next week. To find out what's wrong with your webpages, please consult: http://common-lisp.net/checkbot/checkbot-common-lisp.net.html Any questions? You can reach the author of this cronjob at clo-devel at common-lisp.net Thanks! From root at common-lisp.net Mon Jan 30 08:15:17 2006 From: root at common-lisp.net (root) Date: Mon, 30 Jan 2006 02:15:17 -0600 (CST) Subject: [fetter-devel] Auto-nag: fetter link verifier failed Message-ID: <20060130081517.F13F05258@common-lisp.net> You are being nagged on because your project's name showed up in the nightly Checkbot run. Checkbot checks for broken links etc. This probably means that you are either pointing to a broken link or that someone is pointing to a broken link on your site. Or something else, it check's a bunch of stuff. Update your webpages or you shall be nagged again next week. To find out what's wrong with your webpages, please consult: http://common-lisp.net/checkbot/checkbot-common-lisp.net.html Any questions? You got this email but your webpage doesn't seem to be listed on the checkbot webpage? You can reach the author of this cronjob at clo-devel at common-lisp.net Thanks!