Stack frame byte alignment in BlitzMax on Linux?

Archives Forums/Linux Discussion/Stack frame byte alignment in BlitzMax on Linux?

JoshK(Posted 2014) [#1]
It appears that BlitzMax is not entirely compatible with the GCC spec. This causing my application to crash on Linux:
It looks like the issue is that we're getting called on a stack frame that isn't 16-byte aligned. The current i386 ABI mandates 16-byte alignment, and a lot of GCC internals depend on it to be able to consistently emit SSE code when auto-vectorizing, etc. Looking at your debug app it seems like the first "appstub" stack frame is what offsets everything and undoes the entry vector alignment.

Is this something that can be fixed in BlitzMax for Linux?


dawlane(Posted 2014) [#2]
The ABI alignment issue has pissed a few people off. Most of the arguments are about who should fix it to ensure that 4/8 byte aligned applications and libraries are compatible. This in my opinion should be down to the distribution vendor to make sure that they compile the distribution for mixed mode.
Try adding -mstackrealign to the list of compiler options in bmkutils.bmx and recompile bmk.
You should rebuild any 32bit libraries as well with this option in CFLAGS.

You should read the options available for dealing with stacks with GCC on x86 processors

Edit: If it fails then you only have three choices
1) Email Mark about the problem.
2) Try Brucey's bcc along with compiler options for the stack.
3) Abandon BlitzMax and use PureBasic or another cross platform coding tool.


JoshK(Posted 2014) [#3]
I tried recompiled my application and all modules after this flag was added in the compiler opts. The library in question is closed source and cannot be altered unless I convince the company to do so.


Brucey(Posted 2014) [#4]
It may be something in the generated ASM, but you'd really need to speak to Mark about that.


dawlane(Posted 2014) [#5]
Josh did they give you any information on the distribution that it fails on?

There are a few tools to check the ABI of a binary listed here on stack-overflow. There should be one in the repositories called abicheck. You should follow a few of the links on stack-overflow as well for some interesting material. Another thing that was reported was the use of certain optimisation flags (in particular -Os), but that was something like 8 years ago.


JoshK(Posted 2014) [#6]
This is resolved, thanks to Mark. Leadwerks for Linux is coming to Steam now!:



Derron(Posted 2014) [#7]
Feel free to explain what has to be changed ... if there is something to change.

bye
Ron


JoshK(Posted 2014) [#8]
Mark sent me a new copy of BCC with something different.


Derron(Posted 2014) [#9]
Ah ok.. time (and intermediate output files) will show what was changed.

Glad to hear Mark has still some spare time for BlitzMax.


bye
ron


Brucey(Posted 2014) [#10]
A new bcc coming our way. Yay! :-)