Smart link in FreeBSD multi-arch ?

classic Classic list List threaded Threaded
31 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Smart link in FreeBSD multi-arch ?

fredvs
Hello.

I will try to explain the problem...

In a multi-arch system (64 bit system that can run 32 bit apps too) FreeBSD 64, there is problem if a fpc 32 bit application was compiled with smart link (-XX).

This because FreeBSD call ld-elf32.so.1 for 32 bit applications, in place of ld-elf.so.1 in his multi-arch sytsem.

On mono-arch system (32 bit or 64 bit), FreeBSD call ld-elf.so.1 (that for 32 or 64 bit).

So, to resume, with smart link (-XX) in a 32 bit FreeBSD app, the link would search first for ld-elf32.so.1 and if not exist, search for  ld-elf.so.1.

And it is not the case, with -XX, the program search only for ld-elf.so.1, even if it is on a multi-arch system.

Hope somebody has understood.

Thanks.

Fre;D

Many thanks ;-)
Reply | Threaded
Open this post in threaded view
|

Re: Smart link in FreeBSD multi-arch ?

Graeme Geldenhuys-6
On 2016-09-21 18:07, fredvs wrote:
> Hope somebody has understood.

I didn't actually see a question in your post. Are you saying FPC is at
fault or 64-bit FreeBSD is at fault? If the latter, I would raise the
issue in their web forums.

I would have expected a 64-bit FreeBSD system to have different search
paths, but consistent library naming. For example (this is just an
example, I don't know if this really exists):

  /compat/linux/lib          <---|
  /compat/linux/user/lib/    <---+- denotes 32-bit by default (could
                                    be other way round too)
  /compat/linux/lib64/
  /usr/local/lib/            <-- denotes 64-bit on 64-bit FreeBSD OS.
  /usr/local/lib32/          <-- 32-bit FreeBSD libraries


Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Smart link in FreeBSD multi-arch ?

fredvs
Hello Graeme.

Thanks for answer.

I do not know who is the guilty...

In FreeBSD 64 multi-arch all the libraries 64 bit are in /lib/ or /usr/lib/ or /usr/local/lib
 and all 32 bit libraries are in  /usr/lib32 or /usr/local/lib32.

But for ld-elf*.so both ld-elf.so and ld-elf32.so are in same directory /libexec/.

I have try to put ld-elf32.so in /usr/lib32 or /usr/local/lib32 but it does not work.

It is clear that the smart link links to the wrong ld-elf but I do not know who or what is the cause.

It seems to me that fpc is not 100 % white in that history.

Fre;D
Many thanks ;-)
Reply | Threaded
Open this post in threaded view
|

Re: Smart link in FreeBSD multi-arch ?

fredvs
Re-hello.

Note that in FreeBSD 64 multi-arch, the Linuxator is working perfectly, for Linux 64 and Linux 32, even with smart-linking 32 bit too.

Fre;D
Many thanks ;-)
Reply | Threaded
Open this post in threaded view
|

Re: Smart link in FreeBSD multi-arch ?

fredvs
Hello.

Once again (like always) fpc is whiter than white.

FreeBSD has decided to stop FreeBSD 32 bit and that smart-link problem is known but they do not want to fix it because of stopping FreeBSD 32 bit development.

It is extremely sad and I do not understand why to stop 32 bit development.

Fre;D
Many thanks ;-)
Reply | Threaded
Open this post in threaded view
|

Re: Smart link in FreeBSD multi-arch ?

Graeme Geldenhuys-6
On 2016-10-07 14:38, fredvs wrote:
> It is extremely sad and I do not understand why to stop 32 bit development.

But they just recently added support for RaspberryPi. Does that mean
FreeBSD on RaspberryPi will now also discontinue? If so, there goes my
idea of using RPi's as small stand-alone servers. :-/

Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Smart link in FreeBSD multi-arch ?

Sven Barth-2

Am 07.10.2016 17:19 schrieb "Graeme Geldenhuys" <[hidden email]>:
>
> On 2016-10-07 14:38, fredvs wrote:
> > It is extremely sad and I do not understand why to stop 32 bit development.
>
> But they just recently added support for RaspberryPi. Does that mean
> FreeBSD on RaspberryPi will now also discontinue? If so, there goes my
> idea of using RPi's as small stand-alone servers. :-/

Probably they merely want to kick out x86 32-bit support.

Regards,
Sven


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Smart link in FreeBSD multi-arch ?

Marco van de Voort
In reply to this post by Graeme Geldenhuys-6
In our previous episode, Graeme Geldenhuys said:
>
> But they just recently added support for RaspberryPi. Does that mean
> FreeBSD on RaspberryPi will now also discontinue? If so, there goes my
> idea of using RPi's as small stand-alone servers. :-/

Well, that would probably only involve current, and stable branches would
cover existing targets for several years. Fred's post seems to mainly
be about biarchs though, and that is a completely different story.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Smart link in FreeBSD multi-arch ?

fredvs
 Fred's post seems to mainly
Marco van de Voort wrote
 Fred's post seems to mainly
be about biarchs though, and that is a completely different story.
Sadly no.
No more biarch because no more FreeBSD32.

Fre;D
Many thanks ;-)
Reply | Threaded
Open this post in threaded view
|

Re: Smart link in FreeBSD multi-arch ?

Michael Schnell
In reply to this post by Graeme Geldenhuys-6
On 07.10.2016 17:19, Graeme Geldenhuys wrote:

>   there goes my
> idea of using RPi's as small stand-alone servers. :-/
>
>
Pi 3 does feature a 64 Bit CPU. (AFAIK, no 64 Bit Linux for same, yet.
BSD: no idea)

-Michael
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Smart link in FreeBSD multi-arch ?

Graeme Geldenhuys-6
In reply to this post by fredvs
On 2016-10-07 14:38, fredvs wrote:
> FreeBSD has decided to stop FreeBSD 32 bit

I just saw the FreeBSD 11.0 release announcement. In the "Availability"
list, i386 is still mentioned.

  https://www.freebsd.org/releases/11.0R/announce.html


Regards,
  Graeme

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Smart link in FreeBSD multi-arch ?

fredvs
Thanks Graeme.

To know what is sent to the linker, there is the -s parameter.

# fpc -XX -s test.pas

This will compile the object and create a script file for the linker.
Here the script with -XX parameter:

/usr/bin/ld -b elf32-i386-freebsd -m elf_i386_fbsd --gc-sections -s -L. -0 ./test ./link.res


If seems to me then that --gc-sections has to do with smart-link too.

From site https://sourceware.org/binutils/docs/ld/Options.html:

--gc-sections
--no-gc-sections
Enable garbage collection of unused input sections. It is ignored on targets that do not support this option. The default behaviour (of not performing this garbage collection) can be restored by specifying `--no-gc-sections' on the command line. Note that garbage collection for COFF and PE format targets is supported, but the implementation is currently considered to be experimental.
`--gc-sections' decides which input sections are used by examining symbols and relocations. The section containing the entry symbol and all sections containing symbols undefined on the command-line will be kept, as will sections containing symbols referenced by dynamic objects. Note that when building shared libraries, the linker must assume that any visible symbol is referenced. Once this initial set of sections has been determined, the linker recursively marks as used any section referenced by their relocations. See `--entry' and `--undefined'.

This option can be set when doing a partial link (enabled with option `-r'). In this case the root of symbols kept must be explicitly specified either by an `--entry' or `--undefined' option or by a ENTRY command in the linker script.

___________________

There, in FreeBSD forum, they do not agree.

https://forums.freebsd.org/threads/57931/page-3

Fre;D



Many thanks ;-)
Reply | Threaded
Open this post in threaded view
|

Re: Smart link in FreeBSD multi-arch ?

fredvs
I feel so lonely.

Nobody in the world to confirm (or not) that --gc-sections option is added to ld when -XX is used ?

Did I do something wrong against fpc community ?

If yes I apologize a lot and a lot and a lot.

Fre;D

Many thanks ;-)
Reply | Threaded
Open this post in threaded view
|

Re: Smart link in FreeBSD multi-arch ?

Michael Van Canneyt


On Sun, 16 Oct 2016, fredvs wrote:

> I feel so lonely.

I'm told this can help: http://www.tinder.com

>
> Nobody in the world to confirm (or not) that *--gc-sections* option is added
> to ld when -XX is used ?
>
> Did I do something wrong against fpc community ?

No, simply probably no-one knows the answer or the few knowledgable people
didn't see your message.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Smart link in FreeBSD multi-arch ?

fredvs
Thanks Michael.

> No, simply probably no-one knows the answer or the few knowledgable people didn't see your message.

OK I agree the problem is complicated it is the reason why I ask this to fpc + freebsd forum.

But here I ask something simple : What option is added to linker when -XX parameter is used?

If you do:

fpc -s -XX test.pas, in the ppas.sh produced, *--gc-sections* option is added to ld option.

So it seems that garbage collection must be enabled to do a smartlink.

And if this is right, using  garbage collection in FreeBSD 32 bit produce code not usable in Multi-arch.

There in FreeBSD forum, they cannot admit that fpc uses  *--gc-sections* option in ld when fpc -XX is used.

Fre;D
 

Many thanks ;-)
Reply | Threaded
Open this post in threaded view
|

Re: Smart link in FreeBSD multi-arch ?

Graeme Geldenhuys-6
On 2016-10-17 13:55, fredvs wrote:
> So it seems that garbage collection must be enabled to do a smartlink.

I'm not sure I follow you. From what I understand from the FPC
documentation, is that FPC (when smartlinking is enabled) generates
multiple object files per unit, trying to make a object file per procedure.

It is then the linkers job to link only the object files that are needed
(and really used in the application) to make the executable. How the
linker does that is beyond my knowledge.


> There in FreeBSD forum, they cannot admit that fpc uses  *--gc-sections*
> option in ld when fpc -XX is used.

I guess showing them the content of the ppas.sh file is all that they
should need as proof. The alternative (if you know exactly what the
problem is), is to modify the ld linker yourself and see if it then
works on your system. If so, send them a patch.

Some developers are harder to convince about potential problems or bugs.
The FreeBSD developers are definitely not the only ones.


Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Smart link in FreeBSD multi-arch ?

fredvs
Yeh, the cavalry finally arrives, I am saved. ;-)

> it is then the linkers job to link only the object files that are needed (and really used in the application) to make the executable.

Yes, yes, yes and re-yes.

> I guess showing them the content of the ppas.sh file is all that they should need as proof.

Huh, it is already one week (7 days) that I repeat it on each answer.

> Some developers are harder to convince about potential problems or bugs.

Yes but here it is different. Did you see that they do not want that I answer any more?

Sincerely, if it was for one of my project, I never will fight and accept to be insulted in each of their answer, this more than a week.

But here it is about the honor of fpc who was accused to produce bad code.

> The alternative (if you know exactly what the problem is), is to modify the ld linker yourself and see if it then works on your system.

Yep or prove that a gcc or clang or llvm compiler that use ld + --gc-sections produce binary not usable in multi-arch.

==> https://forums.freebsd.org/threads/58060/

Thanks Graeme, I was beginning to think that I was in a nightmare without end.

 
Fre;D

Many thanks ;-)
Reply | Threaded
Open this post in threaded view
|

Re: Smart link in FreeBSD multi-arch ?

Graeme Geldenhuys-6
In reply to this post by fredvs
On 2016-09-21 18:07, fredvs wrote:
> In a multi-arch system (64 bit system that can run 32 bit apps too) FreeBSD
> 64, there is problem if a fpc 32 bit application was compiled with smart
> link (-XX).

Just curious. If you don't compile with Smart-Linking enabled, does your
binary then run fine?

Is only Smart-Linking causing the problem?


Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Smart link in FreeBSD multi-arch ?

Martin Schreiber-2
In reply to this post by Graeme Geldenhuys-6
On Monday 17 October 2016 15:30:36 Graeme Geldenhuys wrote:
> On 2016-10-17 13:55, fredvs wrote:
> > So it seems that garbage collection must be enabled to do a smartlink.
>
> I'm not sure I follow you. From what I understand from the FPC
> documentation, is that FPC (when smartlinking is enabled) generates
> multiple object files per unit, trying to make a object file per procedure.
>
Doesn't it use function-sections nowadays?

Martin
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Smart link in FreeBSD multi-arch ?

Sven Barth-2

Am 17.10.2016 17:11 schrieb "Martin Schreiber" <[hidden email]>:
>
> On Monday 17 October 2016 15:30:36 Graeme Geldenhuys wrote:
> > On 2016-10-17 13:55, fredvs wrote:
> > > So it seems that garbage collection must be enabled to do a smartlink.
> >
> > I'm not sure I follow you. From what I understand from the FPC
> > documentation, is that FPC (when smartlinking is enabled) generates
> > multiple object files per unit, trying to make a object file per procedure.
> >
> Doesn't it use function-sections nowadays?

It depends on the target. Most targets indeed used section based smartlinking while AFAIK targets like go32v2 use the file based approach.

Regards,
Sven


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
12