cs at zip.com.au
Fri Dec 8 21:01:23 UTC 2006
On 08Dec2006 12:01, Luca <luca.piol at fastwebnet.it> wrote:
| How do I capture the linking time and data size of ld?
| I mean, example, when I compile a package foo from scratch, what
| commands should I use to save a log file with something like:
| /usr/bin/ld: total time in link: [time]
| /usr/bin/ld: data size [size]
Second part first: the 'size" command reports on the section sizes of
an executable, so if the ld command makes a file "bah", the command:
will report on its size. See "man size" for details.
For timing, you can get the time with the "time" command. Where you
have "ld foo...", put "time ld foo...". Time writes to standard error,
so you will need to send that somewhere:
time ld foo... 2>output-file
However, ld will write its own error messages to stderr too, and you
_don't_ want to interfere with them. This incantation
time sh -c 'exec 2>&3 3>&-; exec ld foo...' 3>&2 2>output-file
will work around that, sending time's stderr to the output-file and ld's
stderr wherever the original stderr went (usually your terminal). It
takes a copy of the original stderr and the reattaches the copy as stderr
inside the sh command.
Finally, "time" is often a builtin command in shells. You may get better
behaviour by saying "/usr/bin/time" instead of just "time". That will
run the system "time" executable rather than whatever your shell provides
Cameron Simpson <cs at zip.com.au> DoD#743
This bottle of whisky is awful. I'll be glad when it's done.
- One Scot to another
More information about the users