We have some code that compiles and runs as intended using gpc-20020502 based on gcc 2.95.2. I am now trying to get it running with gpc-20060325 based on gcc-3.4.4.
As a demonstration the program
Program Test_err; Var errno:integer; external name 'errno'; Begin Writeln(@Error number is ',Errno); End;
Compiles but fails to link with 20060325 :
"/usr/bin/ld: errno: TLS definition in /lib/libc.so.6 section .tbss mismatches non-TLS reference in /tmp/ccae8f7a.o"
The same program runs correctly with 20020522 when external name is replaced by the older syntax asmname. A bit of googling suggests this is a common problem and not limited to gpc but I can't find how I am now supposed to access errno. Any suggestions?
On Wed, Jul 19, 2006 at 10:00:28PM +0100, Martin Liddle wrote:
We have some code that compiles and runs as intended using gpc-20020502 based on gcc 2.95.2. I am now trying to get it running with gpc-20060325 based on gcc-3.4.4.
As a demonstration the program
Program Test_err; Var errno:integer; external name 'errno'; Begin Writeln(@Error number is ',Errno); End;
Compiles but fails to link with 20060325 :
"/usr/bin/ld: errno: TLS definition in /lib/libc.so.6 section .tbss mismatches non-TLS reference in /tmp/ccae8f7a.o"
The same program runs correctly with 20020522 when external name is replaced by the older syntax asmname. A bit of googling suggests this is a common problem and not limited to gpc but I can't find how I am now supposed to access errno. Any suggestions? --
I'd guess the problem is that according to the C standard, errno does not have to be a variable, it could be a macro. You may try to use a C wrapper, like this (untested):
get_errno.c:
#include <errno.h>
int get_errno (void) { return errno; }
Pascal source:
Program Test_err; {$L get_errno.c}
function errno: Cinteger; external name 'get_errno';
Begin Writeln('Error number is ',Errno); End.
Emil Jerabek
In message 20060719225003.GA6121@artax.karlin.mff.cuni.cz, Emil Jerabek ejer5183@artax.karlin.mff.cuni.cz writes
On Wed, Jul 19, 2006 at 10:00:28PM +0100, Martin Liddle wrote:
As a demonstration the program
Program Test_err; Var errno:integer; external name 'errno'; Begin Writeln(@Error number is ',Errno); End;
Compiles but fails to link with 20060325 :
I'd guess the problem is that according to the C standard, errno does not have to be a variable, it could be a macro. You may try to use a C wrapper, like this (untested):
Thanks, that seems to work for a test program and allows one of my actual programs to link. It segfaults when run but I need to dig deeper to find the problem.