Sign in Join

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

Mailing lists / fpc-pascal / 2008-08

Manual smartlinking

8 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

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

leledumbo

How to manually smartlink programs? I have a bunch of units and a program entry point defined in asm file. Currently, I only link all the *.o files. Though I've used -CX, I don't think the executable is smartlinked as it is quite big. There's also a bunch of *.a generated, but I can't just rename all the *.o to libp*.a. Using -Cn, I got ppas.bat and link.res. I think I can find it out by examining link.res. But when I call ppas.bat, the resulting binaries are not the same (e.g. bigger) as if it's compiled directly.

PS: I'm cross-compiling from i386-win32 to i386-linux

View this message in context: http://www.nabble.com/Manual-smartlinking-tp19063152p19063152.html Sent from the Free Pascal - General mailing list .

Reply by email

Vincent Snijders
to leledumbo
leledumbo wrote
How to manually smartlink programs? I have a bunch of units and a program entry point defined in asm file. Currently, I only link all the *.o files. Though I've used -CX, I don't think the executable is smartlinked as it is quite big. T

The -XX compiler parameter enables smartlinking.

Vincent

Reply by email

Jonas Maebe
to leledumbo
leledumbo wrote 8 lines
Vincent Snijders wrote: > > The -XX compiler parameter enables smartlinking. > I know that one (and I already use it), but the problem is that I need to do it manually due to external entry point.

Pass the --gc-sections parameter to the linker (and use object files compiled with -CX).

Jonas

Reply by email

Jonas Maebe
to leledumbo
leledumbo wrote 6 lines
Jonas Maebe-2 wrote: > > Pass the --gc-sections parameter to the linker (and use object files > compiled with -CX). > OK, I'll try. What about the *.a's?

It depends on the platform. If you have *.a, you files, you should link against those instead (no need to use --gc-sections in that case).

Jonas

Reply by email

Peter Vreman
> Pass the --gc-sections parameter to the linker (and use object files > compiled with -CX). > OK, I'll try. What about the *.a's?

--gc-sectiosn will not help. FPC does not generate .o files with multiple sections for linux. Smartlinking for linux will create libp*.a files instead. You need to link with the libp*.a instead of the *.o files.

It can't be written down what is required for your program to link manual. But you can compile with -s to generate a link.res and ppas.sh to see the commands that are use by fpc for linking.

Peter

Reply by email