Re: [fpc-pascal] Building trunk

2018-11-24 Thread C Western

On 23/11/2018 09:50, Sven Barth via fpc-pascal wrote:
Am Fr., 23. Nov. 2018, 10:26 hat C Western > geschrieben:


I haven't been able to build trunk i386 fpc for a couple of weeks. Is
this supposed to be working, or have I misconfigured something? (I
don't
think I have changed anything.) The output is below. I don't think
it is
significant, but I am building on a 64 bit system, but with a 32 bit
starting compiler. (The 64 bit build with the 64 bit starting
compiler
works fine.)


We have i386 trunk building on at least one x86_64-linux machine, so 
it can't be a principal problem. :/
Could you check whether it's FPC itself that segfaults or something 
else and if the former try to retrieve a stacktrace, please?


Regards,
Sven

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Looks like the ppc1 compiler crashes during setup:

gdb) run
Starting program: /home/me/fpc/trunk/fpcsrc/compiler/ppc1

Program received signal SIGSEGV, Segmentation fault.
0x08068760 in INITTLS () at system.pp:543
543        case phdr^.p_type of
(gdb) bt
#0  0x08068760 in INITTLS () at system.pp:543
#1  0x082a63fb in _FPC_PROC_START () at ./i386/si_prc.inc:105
(gdb) p phdr
$1 = (PPHDR) 0x8048034
(gdb) p phdr^
Cannot access memory at address 0x8048034

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Building trunk

2018-11-24 Thread C Western

On 23/11/2018 13:58, Joost van der Sluis wrote:

On 11/23/18 2:48 PM, C Western wrote:
make distclean cycle OPT="-n" OS_TARGET=linux CPU_TARGET=i386 
FPC=~/fpc/bootstrap/ppcx64


/home/ctcmw/fpc/trunk/fpcsrc/compiler/ppcross386 -Pi386 
-XPi386-linux- -Xr -Fui386 -Fusystems -Fu../rtl/units/i386-linux 
-Fii386 -FEi386/bin/i386-linux -FUi386/units/i386-linux -n -di386 
-dGDB -dBROWSERLOG -Fux86 -Sew    -di386 -dGDB -dBROWSERLOG -Fux86 
-Sew pp.pas
pp.pas(277,1) Error: Util i386-linux-ld not found, switching to 
external linking



I will try and generate a backtrace as suggested by Sven later.


No need to. The compiler does not crash. It cannot find i386-linux-ld.

You need the binutils for cross-compilation. See the buildfaq.

Or, create them yourself. Add the following bash-scripts somewhere in 
your path and make them executable: (Works on Fedora, might be 
different on other systems)


i386-linux-as:
--
#!/bin/bash
# name this file /usr/bin/i386-linux-as
as --32 $@
--

i386-linux-ld:

--
#!/bin/bash
# name this file /usr/bin/i386-linux-ld
ld -A elf32-i386 $@
--


Regards,

Joost.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Creating i386-linux-ld allows the make distclean cycle to complete. 
However the resulting compiler (ppc386) gives a segmentation fault on 
startup, just as I had with the previous approach. See my other message 
for the stack trace.


Colin

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Building trunk

2018-11-24 Thread Sven Barth via fpc-pascal
Am Sa., 24. Nov. 2018, 10:09 hat C Western  geschrieben:

> On 23/11/2018 09:50, Sven Barth via fpc-pascal wrote:
> > Am Fr., 23. Nov. 2018, 10:26 hat C Western  > > geschrieben:
> >
> > I haven't been able to build trunk i386 fpc for a couple of weeks. Is
> > this supposed to be working, or have I misconfigured something? (I
> > don't
> > think I have changed anything.) The output is below. I don't think
> > it is
> > significant, but I am building on a 64 bit system, but with a 32 bit
> > starting compiler. (The 64 bit build with the 64 bit starting
> > compiler
> > works fine.)
> >
> >
> > We have i386 trunk building on at least one x86_64-linux machine, so
> > it can't be a principal problem. :/
> > Could you check whether it's FPC itself that segfaults or something
> > else and if the former try to retrieve a stacktrace, please?
> >
> > Regards,
> > Sven
> >
> > ___
> > fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
> Looks like the ppc1 compiler crashes during setup:
>
> gdb) run
> Starting program: /home/me/fpc/trunk/fpcsrc/compiler/ppc1
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x08068760 in INITTLS () at system.pp:543
> 543case phdr^.p_type of
> (gdb) bt
> #0  0x08068760 in INITTLS () at system.pp:543
> #1  0x082a63fb in _FPC_PROC_START () at ./i386/si_prc.inc:105
> (gdb) p phdr
> $1 = (PPHDR) 0x8048034
> (gdb) p phdr^
> Cannot access memory at address 0x8048034
>

Looks like something related to the new threadvar handling. Though by
default that shouldn't be enabled... 🤔

Regards,
Sven

>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Building trunk

2018-11-24 Thread C Western

On 24/11/2018 12:30, Sven Barth via fpc-pascal wrote:
Am Sa., 24. Nov. 2018, 10:09 hat C Western > geschrieben:


On 23/11/2018 09:50, Sven Barth via fpc-pascal wrote:
> Am Fr., 23. Nov. 2018, 10:26 hat C Western mailto:l...@c-m-w.me.uk>
> >> geschrieben:
>
>     I haven't been able to build trunk i386 fpc for a couple of
weeks. Is
>     this supposed to be working, or have I misconfigured
something? (I
>     don't
>     think I have changed anything.) The output is below. I don't
think
>     it is
>     significant, but I am building on a 64 bit system, but with
a 32 bit
>     starting compiler. (The 64 bit build with the 64 bit starting
>     compiler
>     works fine.)
>
>
> We have i386 trunk building on at least one x86_64-linux
machine, so
> it can't be a principal problem. :/
> Could you check whether it's FPC itself that segfaults or something
> else and if the former try to retrieve a stacktrace, please?
>
> Regards,
> Sven
>
> ___
> fpc-pascal maillist  - fpc-pascal@lists.freepascal.org

> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Looks like the ppc1 compiler crashes during setup:

gdb) run
Starting program: /home/me/fpc/trunk/fpcsrc/compiler/ppc1

Program received signal SIGSEGV, Segmentation fault.
0x08068760 in INITTLS () at system.pp:543
543        case phdr^.p_type of
(gdb) bt
#0  0x08068760 in INITTLS () at system.pp:543
#1  0x082a63fb in _FPC_PROC_START () at ./i386/si_prc.inc:105
(gdb) p phdr
$1 = (PPHDR) 0x8048034
(gdb) p phdr^
Cannot access memory at address 0x8048034


Looks like something related to the new threadvar handling. Though by 
default that shouldn't be enabled... 🤔


Regards,
Sven

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Some more information:

It seems to work fine on Ubuntu (32 bit built on 64 bit OS, same 
machine). Comparing the binaries with objdump, it looks as though the 
Fedora one has an offset of 1000, which the Ununtu one does not, and the 
offset of 1000 needs to be applied to the program header address, but is 
not. On Fedora:


ppc1: file format elf32-i386
ppc1
architecture: i386, flags 0x0112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x082a63d0

Program Header:
    LOAD off    0x1000 vaddr 0x08049000 paddr 0x08049000 align 2**12
 filesz 0x0025d450 memsz 0x0025d450 flags r-x
    LOAD off    0x0025f000 vaddr 0x082a7000 paddr 0x082a7000 align 2**12
 filesz 0x00020f04 memsz 0x00020f04 flags r--
    LOAD off    0x0028 vaddr 0x082c8000 paddr 0x082c8000 align 2**12
 filesz 0x000f7280 memsz 0x00102d84 flags rw-
   STACK off    0x vaddr 0x paddr 0x align 2**4
 filesz 0x memsz 0x flags rw-

On Ubuntu:

./ppc1: file format elf32-i386
./ppc1
architecture: i386, flags 0x0112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x082a5470

Program Header:
    LOAD off    0x vaddr 0x08048000 paddr 0x08048000 align 2**12
 filesz 0x0027e3f4 memsz 0x0027e3f4 flags r-x
    LOAD off    0x0027f000 vaddr 0x082c7000 paddr 0x082c7000 align 2**12
 filesz 0x000f7280 memsz 0x00102d84 flags rw-
   STACK off    0x vaddr 0x paddr 0x align 2**4
 filesz 0x memsz 0x flags rw-

gdb indicates both versions try to access 0x8048034, but this is not 
mapped on the Fedora version.


Colin

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Building trunk

2018-11-24 Thread C Western

On 24/11/2018 15:19, C Western wrote:

On 24/11/2018 12:30, Sven Barth via fpc-pascal wrote:
Am Sa., 24. Nov. 2018, 10:09 hat C Western > geschrieben:


    On 23/11/2018 09:50, Sven Barth via fpc-pascal wrote:
    > Am Fr., 23. Nov. 2018, 10:26 hat C Western mailto:l...@c-m-w.me.uk>
    > >> geschrieben:
    >
    >     I haven't been able to build trunk i386 fpc for a couple of
    weeks. Is
    >     this supposed to be working, or have I misconfigured
    something? (I
    >     don't
    >     think I have changed anything.) The output is below. I don't
    think
    >     it is
    >     significant, but I am building on a 64 bit system, but with
    a 32 bit
    >     starting compiler. (The 64 bit build with the 64 bit starting
    >     compiler
    >     works fine.)
    >
    >
    > We have i386 trunk building on at least one x86_64-linux
    machine, so
    > it can't be a principal problem. :/
    > Could you check whether it's FPC itself that segfaults or 
something

    > else and if the former try to retrieve a stacktrace, please?
    >
    > Regards,
    > Sven
    >
    > ___
    > fpc-pascal maillist  - fpc-pascal@lists.freepascal.org
    
    > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

    Looks like the ppc1 compiler crashes during setup:

    gdb) run
    Starting program: /home/me/fpc/trunk/fpcsrc/compiler/ppc1

    Program received signal SIGSEGV, Segmentation fault.
    0x08068760 in INITTLS () at system.pp:543
    543        case phdr^.p_type of
    (gdb) bt
    #0  0x08068760 in INITTLS () at system.pp:543
    #1  0x082a63fb in _FPC_PROC_START () at ./i386/si_prc.inc:105
    (gdb) p phdr
    $1 = (PPHDR) 0x8048034
    (gdb) p phdr^
    Cannot access memory at address 0x8048034


Looks like something related to the new threadvar handling. Though by 
default that shouldn't be enabled... 🤔


Regards,
Sven

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Some more information:

It seems to work fine on Ubuntu (32 bit built on 64 bit OS, same 
machine). Comparing the binaries with objdump, it looks as though the 
Fedora one has an offset of 1000, which the Ununtu one does not, and 
the offset of 1000 needs to be applied to the program header address, 
but is not. On Fedora:


ppc1: file format elf32-i386
ppc1
architecture: i386, flags 0x0112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x082a63d0

Program Header:
    LOAD off    0x1000 vaddr 0x08049000 paddr 0x08049000 align 2**12
 filesz 0x0025d450 memsz 0x0025d450 flags r-x
    LOAD off    0x0025f000 vaddr 0x082a7000 paddr 0x082a7000 align 2**12
 filesz 0x00020f04 memsz 0x00020f04 flags r--
    LOAD off    0x0028 vaddr 0x082c8000 paddr 0x082c8000 align 2**12
 filesz 0x000f7280 memsz 0x00102d84 flags rw-
   STACK off    0x vaddr 0x paddr 0x align 2**4
 filesz 0x memsz 0x flags rw-

On Ubuntu:

./ppc1: file format elf32-i386
./ppc1
architecture: i386, flags 0x0112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x082a5470

Program Header:
    LOAD off    0x vaddr 0x08048000 paddr 0x08048000 align 2**12
 filesz 0x0027e3f4 memsz 0x0027e3f4 flags r-x
    LOAD off    0x0027f000 vaddr 0x082c7000 paddr 0x082c7000 align 2**12
 filesz 0x000f7280 memsz 0x00102d84 flags rw-
   STACK off    0x vaddr 0x paddr 0x align 2**4
 filesz 0x memsz 0x flags rw-

gdb indicates both versions try to access 0x8048034, but this is not 
mapped on the Fedora version.


Colin

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


And going through the versions indicates the problem is introduced by:

r40272 | florian | 2018-11-07 22:03:02 + (Wed, 07 Nov 2018) | 1 line
Changed paths:
   M /trunk/compiler/cgbase.pas
   M /trunk/compiler/x86/agx86att.pas
   M /trunk/compiler/x86/cgx86.pas
   M /trunk/compiler/x86/nx86ld.pas
   M /trunk/rtl/linux/i386/si_prc.inc
   M /trunk/rtl/linux/system.pp

+ i386-linux support for tls-based threadvars

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Building trunk

2018-11-24 Thread Florian Klämpfl
Am 24.11.2018 um 10:08 schrieb C Western:
> On 23/11/2018 09:50, Sven Barth via fpc-pascal wrote:
>> Am Fr., 23. Nov. 2018, 10:26 hat C Western > > geschrieben:
>>
>>     I haven't been able to build trunk i386 fpc for a couple of weeks. Is
>>     this supposed to be working, or have I misconfigured something? (I
>>     don't
>>     think I have changed anything.) The output is below. I don't think
>>     it is
>>     significant, but I am building on a 64 bit system, but with a 32 bit
>>     starting compiler. (The 64 bit build with the 64 bit starting
>>     compiler
>>     works fine.)
>>
>>
>> We have i386 trunk building on at least one x86_64-linux machine, so it 
>> can't be a principal problem. :/
>> Could you check whether it's FPC itself that segfaults or something else and 
>> if the former try to retrieve a
>> stacktrace, please?
>>
>> Regards,
>> Sven
>>
>> ___
>> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
>> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
> 
> Looks like the ppc1 compiler crashes during setup:
> 
> gdb) run
> Starting program: /home/me/fpc/trunk/fpcsrc/compiler/ppc1
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x08068760 in INITTLS () at system.pp:543
> 543        case phdr^.p_type of
> (gdb) bt
> #0  0x08068760 in INITTLS () at system.pp:543
> #1  0x082a63fb in _FPC_PROC_START () at ./i386/si_prc.inc:105
> (gdb) p phdr
> $1 = (PPHDR) 0x8048034
> (gdb) p phdr^
> Cannot access memory at address 0x8048034

Can you please check what value phdr has at the crash location after applying 
the following patch?

diff --git a/rtl/linux/system.pp b/rtl/linux/system.pp
index 0d7ed2b152..74b4592ace 100644
--- a/rtl/linux/system.pp
+++ b/rtl/linux/system.pp
@@ -525,6 +525,8 @@ procedure InitTLS; [public,alias:'FPC_INITTLS'];
 while assigned(auxp^) do
   inc(auxp);
 inc(auxp);
+phdr:=nil;
+phnum:=0;
 { now we are at the auxillary vector }
 while assigned(auxp^) do
   begin
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal