[squeak-dev] <CDECL kerfuffled on OpenGL. was (Re: OGLUnixX11LE >> glPixelStorei: with:)

gettimothy gettimothy at zoho.com
Sun May 10 16:08:12 UTC 2020


Thanks all.



TL;DR "none" of the OpenGL KeyWord API methods are being cdecled, they are all <apicall in the bytecodes and decompile.





preludes:



1. I am able to compile and run a Hello Triangle from http://antongerdelan.net/opengl/hellotriangle.html  so basic library stuff is there on Linux64



2. Squeak is :

/home/wm/usr/src/smalltalk/squeak6.0alpha/shared/Squeak6.0alpha-19537-64bit.image

Squeak6.0alpha

latest update: #19634

Current Change Set: OpenGL

Image format 68021 (64 bit)







Examining the source under the "decompile" option:





glPixelStorei: pname with: param 

<apicall: void 'glPixelStorei' (ulong long) module: 'libGL.so.1'>

^ self externalCallFailed





which shows that the source code string in my original question, is being replaced.

Here is that "source" view again:


glPixelStorei: pname with: param

"This method was automatically generated."

"void glPixelStorei(GLenum pname, GLint param);"

<apicall: void 'glPixelStorei' (ulong long) module: '#openGLLibraryName'>

^self externalCallFailed









You will notice that the <apicall: has not been replaced with the <cdecl:



That failure is true on both decompile and byteCodes:




<apicall: void 'glPixelStorei' (ulong long) module: 'libGL.so.1'>


41 <F8 78 00> callPrimitive: 120

44 <4C> self

45 <81> send: externalCallFailed

46 <5C> returnTop








it is true for all the methods of  a quick scan in Keyword API category.



verifying that the cdecl is wrong, I look in FFITestLibrary ffiPrintString:



and there is a correct looking cdecl.






<cdecl: char* 'ffiPrintString' (char*)>


41 <F8 78 00> callPrimitive: 120

44 <4C> self

45 <81> send: externalCallFailed

46 <5C> returnTop








I check it:




FFITestLibrary new ffiPrintString: 'foo'  -> 'foo'




Something more basic is missing from the soup.



I look forward to your insights.




---- On Sun, 10 May 2020 02:17:17 -0400 Beckmann, Tom <mailto:Tom.Beckmann at student.hpi.uni-potsdam.de> wrote ----


Hi Vanessa,

thank you for clarifying! Do you know if there's any reason to keep the conditional asking for the osVersion to either return 'GL' or 'libgl.so.1'? In its current state it is broken on most linux systems I tested on (mainly Ubuntu-based), but I was wondering whether the correct fix would be to adapt it to the correct matching string 'linux-gnu' or just have it return 'libgl.so.1' always.

Best,
Tom
________________________________________
From: Squeak-dev <mailto:squeak-dev-bounces at lists.squeakfoundation.org> on behalf of Vanessa Freudenberg <mailto:vanessa at codefrau.net>
Sent: Sunday, May 10, 2020 3:19:00 AM
To: The general-purpose Squeak developers list
Subject: Re: [squeak-dev] OGLUnixX11LE >> glPixelStorei: with:

On Sat, May 9, 2020 at 12:05 AM Beckmann, Tom <mailto:Tom.Beckmann at student.hpi.uni-potsdam.de<mailto:mailto:Tom.Beckmann at student.hpi.uni-potsdam.de>> wrote:
Hi there!

Replacing the whole #openGLLibraryName method with a simple
^ 'GL'
should work, as long as you adapt your LD_LIBRARY_PATH to include the arch specific libraries. For example adding
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu/"
in your squeak.sh before the vm gets started should make sure that the image finds libgl*. Of course, if your libgl.so.1 is not found under that path, adjust accordingly.

Alternatively, you can also specify the absolute path to the library, e.g.
^ '/usr/lib/x86_64-linux-gnu/libGL.so'
which may be a safer option to start from if you're having troubles getting it to run.

'libGL.so' typically is installed by the opengl dev package as a symlink to 'libGL.so.1'. The user package installs 'libGL.so.1' and will *not* be found by the VM if you just specify 'GL' because the VM will only automatically try the '.so' suffix but not '.so.1'.

That is why 'libGL.so.1' is indeed the correct value to be returned from openGLLibraryName on Linux.

For the apicall:'s, if you inspect the byte codes of the method, you will in fact notice that is has already been replaced for you. This happens in OpenGL>>#privateInstallLibrary:, but only updates the method's bytecode, not its source code (which is good, because otherwise this would end up in commits or your changes file).

Yep. As Levente mentioned, you need to switch your browser to show decompiled code to see the actual methods being executed.

You will also see that apicall has been replaced by cdecl which is the right calling convention on Linux.

- Vanessa -


Best,
Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200510/c8640018/attachment.html>


More information about the Squeak-dev mailing list