Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2007-01

support for FreeBSD4 broken in fpc 2.0.4

8 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marc Santhoff

Hi,

I haven't noticed up to now, but using fpc-2.0.4 on FreeBSD does not work completely in FreeBSD 4.11 any more.

Observations:

- Compiling fpc 2.0.4 works.

- Compiling programs does not work with the new startup code (rtl/freebsd/i386/cprto.as)
error: failure in _init_tls()
couldn't find info on what that is ...

- blindly switching to fpc 2.0.2s cprt0.as does make most things work again ...

- ... but multitasking isn't possible, the old cprt0.as does not work with threads at all
errors:

(gdb) bt
#0 0x2821e88b in pth_cancel_point () from /usr/local/lib/pth/libpthread.so.20 #1 0x28217938 in pthread_testcancel () from /usr/local/lib/pth/libpthread.so.20 #2 0x28536768 in _thread_enter_cancellation_point () from /usr/lib/libc_r.so.4 #3 0x2852a954 in fcntl () from /usr/lib/libc_r.so.4 #4 0x2821da45 in pth_fdmode () from /usr/local/lib/pth/libpthread.so.20 #5 0x2821a86f in __pth_scheduler_init () from /usr/local/lib/pth/libpthread.so.20 #6 0x2821ca76 in pth_init () from /usr/local/lib/pth/libpthread.so.20 #7 0x28217fa0 in pthread_mutex_init () from /usr/local/lib/pth/libpthread.so.20 #8 0x285020c2 in _thread_init () from /usr/lib/libc_r.so.4 #9 0x285384a8 in _thread_init_invoker::_thread_init_invoker () from /usr/lib/libc_r.so.4 #10 0x285384e1 in _thread_init_invoker::_thread_init_invoker () from /usr/lib/libc_r.so.4 #11 0x2853850a in _thread_init_invoker::_thread_init_invoker () from /usr/lib/libc_r.so.4 #12 0x28538538 in _thread_init_invoker::_thread_init_invoker () from /usr/lib/libc_r.so.4 #13 0x284bd6d6 in _init () from /usr/lib/libc_r.so.4 #14 0x281ecb5c in _rtld () from /usr/libexec/ld-elf.so.1

Is there any chance of having support for FreeBSD 4 integrated into newer compilers?

What would it require to do so?

If the difference in initializing threads between 2.0.2 and 2.0.4 would be put into makefiles or ifdef's I think it could work ... but my knowledge of compiler internals and startup code is very limited.

TIA,
Marc

Marco van de Voort
to Marc Santhoff
I haven't noticed up to now, but using fpc-2.0.4 on FreeBSD does not work completely in FreeBSD 4.11 any more.

This is by design. The default changed from FreeBSD4 to FreeBSD5 here.

The meaning of the compat switch -Xf changed accordingly afaik.

Show quoted text 5 lines
- Compiling fpc 2.0.4 works. - Compiling programs does not work with the new startup code (rtl/freebsd/i386/cprto.as) error: failure in _init_tls() couldn't find info on what that is ...

initialise the 5.x TLS supporting threading libs.

- ... but multitasking isn't possible, the old cprt0.as does not work with threads at all errors:

Make sure nothing defines FreeBSD5, and use -Xd.

Is there any chance of having support for FreeBSD 4 integrated into newer compilers?

Afaik, all support is still there, except maybe the startup code. Just make sure that FreeBSD

If the difference in initializing threads between 2.0.2 and 2.0.4 would be put into makefiles or ifdef's I think it could work ... but my knowledge of compiler internals and startup code is very limited.

This difference is twofold:
- startup codee, which you "fixed" (some diffing between the two would also help.
- -Xf which changes to the "non-default" FreeBSD version on both 2.0.2 (where it switches to 5.x) and 2.0.4(where it tries 4.x behaviour).

Marc Santhoff
to Marco van de Voort
Marco van de Voort wrote 6 lines
> I haven't noticed up to now, but using fpc-2.0.4 on FreeBSD does not > work completely in FreeBSD 4.11 any more. This is by design. The default changed from FreeBSD4 to FreeBSD5 here. The meaning of the compat switch -Xf changed accordingly afaik.

Um, I've never heard or read of that switch, I'll try.

Show quoted text 19 lines
> - Compiling fpc 2.0.4 works. > - Compiling programs does not work with the new startup > code (rtl/freebsd/i386/cprto.as) > error: failure in _init_tls() > couldn't find info on what that is ... initialise the 5.x TLS supporting threading libs. > - ... but multitasking isn't possible, the old cprt0.as > does not work with threads at all > errors: Make sure nothing defines FreeBSD5, and use -Xd. > Is there any chance of having support for FreeBSD 4 integrated into > newer compilers? Afaik, all support is still there, except maybe the startup code. Just make sure that FreeBSD

?

However this sentence should continue, I've tried the following:

1. reconstructed the original cprt0.as
2. recompiled fpc-2.0.4 release sources
3. added "-Xf" to my .fpc.cfg
4. tried a complete compile of lazarus and a testing program of mine

But sadly I were not successful, the only error I get is the same as before, initializing tls fails:

<compiling lazarus>
$ gmake clean all
...
Compiling cleandirdlg.pas
Linking ../lazarus
/usr/lib/libc.so: WARNING! setkey(3) not present in the system! /usr/lib/libc.so: warning: this program uses gets(), which is unsafe. /usr/lib/libc.so: warning: mktemp() possibly used unsafely; consider using mkstemp() /usr/lib/libc.so: WARNING! des_setkey(3) not present in the system! /usr/lib/libc.so: WARNING! encrypt(3) not present in the system! /usr/lib/libc.so: warning: tmpnam() possibly used unsafely; consider using mkstemp() /usr/lib/libc.so: warning: this program uses f_prealloc(), which is not recommended. /usr/lib/libc.so: WARNING! des_cipher(3) not present in the system! /usr/lib/libc.so: warning: tempnam() possibly used unsafely; consider using mkstemp() /home/marc/fpc-2.0.4-fbsd/lib/fpc/2.0.4/units/i386-freebsd/rtl/cprt0.o: In function `_start': /home/marc/fpc-2.0.4-fbsd/lib/fpc/2.0.4/units/i386-freebsd/rtl/cprt0.o(.text+0xa9): undefined reference to `_init_tls' lazarus.pp(119,1) Error: Error while linking
...
</compiling lazarus>

<compiling test program>
$ fpc -Xf -Xd -Fu/home/marc/program/fpc-laz/fpc/packages/extra/hdf5/ -Fi/home/marc/program/fpc-laz/fpc/packages/extra/hdf5/ dev_mvc.lpr Free Pascal Compiler version 2.0.4 [2007/01/19] for i386 Copyright (c) 1993-2006 by Florian Klaempfl
Target OS: FreeBSD/ELF for i386
Compiling dev_mvc.lpr
Linking dev_mvc
/usr/lib/libc.so: WARNING! setkey(3) not present in the system! /usr/lib/libc.so: warning: this program uses gets(), which is unsafe. /usr/lib/libc.so: warning: mktemp() possibly used unsafely; consider using mkstemp() /usr/lib/libc.so: WARNING! des_setkey(3) not present in the system! /usr/lib/libc.so: WARNING! encrypt(3) not present in the system! /usr/lib/libc.so: warning: tmpnam() possibly used unsafely; consider using mkstemp() /usr/lib/libc.so: warning: this program uses f_prealloc(), which is not recommended. /usr/lib/libc.so: WARNING! des_cipher(3) not present in the system! /usr/lib/libc.so: warning: tempnam() possibly used unsafely; consider using mkstemp() /home/marc/fpc-2.0.4-fbsd/lib/fpc/2.0.4/units/i386-freebsd/rtl/cprt0.o: In function `_start': /home/marc/fpc-2.0.4-fbsd/lib/fpc/2.0.4/units/i386-freebsd/rtl/cprt0.o(.text+0xa9): undefined reference to `_init_tls' dev_mvc.lpr(17,1) Error: Error while linking
</compiling test program>

As you can see, the -Xf switch does not change things, even when given explicitely. Cross checking without -Xf anywhere (command line, .fpc.cfg) shows the same error, too.

Show quoted text 9 lines
> If the difference in initializing threads between 2.0.2 and 2.0.4 would > be put into makefiles or ifdef's I think it could work ... but my > knowledge of compiler internals and startup code is very limited. This difference is twofold: - startup codee, which you "fixed" (some diffing between the two would also help. - -Xf which changes to the "non-default" FreeBSD version on both 2.0.2 (where it switches to 5.x) and 2.0.4(where it tries 4.x behaviour).

How can I go on from here, should I try switching startup code again and try "-Xd"?

TIA,
Marc

Marco van de Voort
to Marc Santhoff
Show quoted text 6 lines
Am Freitag, den 26.01.2007, 22:31 +0100 schrieb Marco van de Voort: > This is by design. The default changed from FreeBSD4 to FreeBSD5 here. > > The meaning of the compat switch -Xf changed accordingly afaik. Um, I've never heard or read of that switch, I'll try.

The fix mainly switches threading libraries and other minor linking stuff.

> > errors: > > Make sure nothing defines FreeBSD5, and use -Xd.

(should have been -Xf)

Show quoted text 9 lines
> > Is there any chance of having support for FreeBSD 4 integrated into > > newer compilers? > > Afaik, all support is still there, except maybe the startup code. Just > make sure that FreeBSD However this sentence should continue, I've tried the following: 1. reconstructed the original cprt0.as

Yes. Also note the version numbers in the abitag (currently 504000 meaning 5.4).

2. recompiled fpc-2.0.4 release sources 3. added "-Xf" to my .fpc.cfg 4. tried a complete compile of lazarus and a testing program of mine

Don't. First start to get a simple file working, not directly lazarus. Start with 2.0.2 cprt0.as and start modifying that. I think that is easier than working backwards from 2.0.4

But sadly I were not successful, the only error I get is the same as before, initializing tls fails:

There is no TLS in 4.x. So you either left in the tls stuff in your cprt0.as reconstruction, or you failed to update the preinstalled version (cprt0.o).

Also try to recover link.res when linking fails.

Marc Santhoff
to Marco van de Voort
Marco van de Voort wrote
> Am Freitag, den 26.01.2007, 22:31 +0100 schrieb Marco van de Voort:

...

Show quoted text 18 lines
> 1. reconstructed the original cprt0.as Yes. Also note the version numbers in the abitag (currently 504000 meaning 5.4). > 2. recompiled fpc-2.0.4 release sources > 3. added "-Xf" to my .fpc.cfg > 4. tried a complete compile of lazarus and a testing program of mine Don't. First start to get a simple file working, not directly lazarus. Start with 2.0.2 cprt0.as and start modifying that. I think that is easier than working backwards from 2.0.4 > But sadly I were not successful, the only error I get is the same as > before, initializing tls fails: There is no TLS in 4.x. So you either left in the tls stuff in your cprt0.as reconstruction, or you failed to update the preinstalled version (cprt0.o).

Okay, now it worked. I must have been mixing up things in the first round, because using fpc 2.0.2's cprt0.as and a full "gmake clean all" and "gmake install INSTALL_PREFIX=..." did actually do the trick (verified by compiling lazarus). The missing link from the start on was the -Xf switch and a clean de- and reinstallation.

So I'm happy but there are some small questions left:

What about the other two items

fpc/share/src/fpc-2.0.4/rtl/freebsd/i386/gprt0.as
fpc/share/src/fpc-2.0.4/rtl/freebsd/i386/prt0.as

Do they have to be fetched from 2.0.2, too?
What are they good for?

Thanks for your assistance,
Marc

Marco van de Voort
to Marc Santhoff
Show quoted text 13 lines
Am Sonntag, den 28.01.2007, 22:55 +0100 schrieb Marco van de Voort: (verified by compiling lazarus). The missing link from the start on was the -Xf switch and a clean de- and reinstallation. So I'm happy but there are some small questions left: What about the other two items fpc/share/src/fpc-2.0.4/rtl/freebsd/i386/gprt0.as fpc/share/src/fpc-2.0.4/rtl/freebsd/i386/prt0.as Do they have to be fetched from 2.0.2, too? What are they good for?

gprt is for profiling.
prt is the default startup. (when NOT linking to libc).

Since the changes are for libc differences, prt0 shouldn't need much modification, probably the only "new" thing is upping the version number (diff the two)

gprt is for profiling, and hasn't been adapted to 5+

Marc Santhoff
to Marco van de Voort
Marco van de Voort wrote 22 lines
> Am Sonntag, den 28.01.2007, 22:55 +0100 schrieb Marco van de Voort: > (verified by compiling lazarus). The missing link from the start on was > the -Xf switch and a clean de- and reinstallation. > > So I'm happy but there are some small questions left: > > What about the other two items > > fpc/share/src/fpc-2.0.4/rtl/freebsd/i386/gprt0.as > fpc/share/src/fpc-2.0.4/rtl/freebsd/i386/prt0.as > > Do they have to be fetched from 2.0.2, too? > What are they good for? gprt is for profiling. prt is the default startup. (when NOT linking to libc). Since the changes are for libc differences, prt0 shouldn't need much modification, probably the only "new" thing is upping the version number (diff the two) gprt is for profiling, and hasn't been adapted to 5+

So in general I'm happy with the way it is, since I only have to keep alive some existing Installations on embedded systems (bugfixing if necessary). The new stuff is planned to work on FreeBSD 6 and FreeBSD 4 has reached is official end of life.

If noone else has a deep need I personally see no reason for putting more work into making fpc runnable on FreeBSD4. Even when no bootstrapping compiler is available a cross platform build with swapping cprt0.as should be possible.

Marc

Marc Santhoff
to Marc Santhoff
Marc Santhoff wrote 9 lines
So in general I'm happy with the way it is, since I only have to keep alive some existing Installations on embedded systems (bugfixing if necessary). The new stuff is planned to work on FreeBSD 6 and FreeBSD 4 has reached is official end of life. If noone else has a deep need I personally see no reason for putting more work into making fpc runnable on FreeBSD4. Even when no bootstrapping compiler is available a cross platform build with swapping cprt0.as should be possible.

For the records:

Using fpc 2.0.4 modified this way at least the function unix/popen stopped working.

Luckily I could use version 2.0.2 this time ...

Marc