Original Post
Hi, I've been poking around Angelscript again on my machine ( Linux/gcc 64bit as the title might suggest :) ) and found a few problems with it. Mostly minor things, but one thing that did require reading through the spec on 64bit calling convention. First the minor things; 1) The angelscript makefile required a little update to include somethings it was missing. 2) Same for the test_feature makefile. 3) I modified asGetLibraryOptions to report AS_X64_GCC ( and AS_X64_MSVC while I was there ), these are needed for some of the other changes below. 4) test_registertype.cpp seemed to be missing a couple of lines of the error message it returned, which in turn was causing that test to fail. It's possible that this test should just be ignored on this platform. Now the bigger issue ( I think, please feel free to correct me if I'm wrong ), and I'll quote from ABI.pdf here ( the spec on 64bit calling conv ). "If the type has class MEMORY, then the caller provides space for the return value and passes the address of this storage in %rdi as if it were the first argument to the function. In effect, this address becomes a “hidden” first argument. On return %rax will contain the address that has been passed in by the caller in %rdi." Basically if a function returns a object then the first parameter to that function should be a pointer the pre-allocated memory for the return object. With the code the way it was the test_vector3 operator overload functions caused a segfaults as it expected the first parameter to be a pointer to the return pointer allocated memory but got 0 or float instead. Of course this is made more difficult by having to identify if the class has non-trivial copy constructor/destructor or not. I'd prefer if someone with a bit more knowledge of this could look over the code, but the changes I made to as_callfunc_x64_gcc.cpp seem to have done the trick. Just added a bit of code to check the return type and then readjust paramBuffer/argsType to include the retPointer as the first parameter. Unfortunately angelscript currently doesn't have a object flag to tell if a registered class has a copy constructor or not. I've checked against asOBJ_APP_CLASS_CA, which seems to work on the current test cases, but I think this is just plain luck. Without something like, asOBJ_APP_CLASS_K ( K for copy constructor? ) the engine just can't test for this. And lastly another minor thing, I created a makefile for test_performance on this platform, renamed utils.cpp to win32_utils.cpp and create a linux_utils.cpp with a corresponding GetSystemTimer function. Not sure if this is worth including or not thou. I've put up my changes as patches files here; http://www.keyboardcowboy.co.uk/angelscript-patches.tbz2 Again, I'm not 100% confident in all these changes but at least they get angelscript building and passing most of test_feature tests. Oh and one very last thing ( honestly ), test_stack2 still fails but only because the exception is reported as coming from myCompare rather than testclass.