All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Machata <petrm@nvidia.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: Roi Dayan <roid@nvidia.com>, Petr Machata <petrm@nvidia.com>,
	<netdev@vger.kernel.org>, David Ahern <dsahern@gmail.com>,
	Petr Machata <me@pmachata.org>
Subject: Re: [PATCH iproute2] build: Fix link errors on some systems
Date: Wed, 6 Jan 2021 17:08:08 +0100	[thread overview]
Message-ID: <87ft3eujyv.fsf@nvidia.com> (raw)
In-Reply-To: <20210106080020.44ffd4d9@hermes.local>


Stephen Hemminger <stephen@networkplumber.org> writes:

> On Wed, 6 Jan 2021 10:42:35 +0200
> Roi Dayan <roid@nvidia.com> wrote:
>
>> > 
>> > I think that just adding an unnecessary -lm is more of a tidiness issue
>> > than anything else. One way to avoid it is to split the -lm deps out
>> > from util.c / json_print.c to like util_math.c / json_print_math.c. That
>> > way they will be in an .o of their own, and won't be linked in unless
>> > the binary in question needs the code. Then the binaries that do call it
>> > can keep on linking in -lm like they did so far.
>> > 
>> > Thoughts?
>> >   
>
> Adding -lm to just some tools is not really required.
> The linker will ignore the shared library if not used.

I don't think that's true.

$ echo 'int main() {}' | gcc -x c /dev/stdin -lm
$ ldd a.out
	linux-vdso.so.1 (0x00007fff903e5000)
	libm.so.6 => /lib64/libm.so.6 (0x00007fa475d75000)
	libc.so.6 => /lib64/libc.so.6 (0x00007fa475bab000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fa475ee4000)

Anyway, without the split to math / non-math modules, the DSO will
actually end up being necessary, because the undefined references to
floor() etc. in util.o / json_print.o will bring it in. Except of course
not everybody actually uses the code...

      reply	other threads:[~2021-01-06 16:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-30 19:11 [PATCH iproute2] build: Fix link errors on some systems Roi Dayan
2021-01-04 16:07 ` Petr Machata
2021-01-06  8:42   ` Roi Dayan
2021-01-06 12:51     ` Roi Dayan
2021-01-06 13:16       ` Petr Machata
2021-01-06 14:20         ` Roi Dayan
2021-01-06 14:24           ` Petr Machata
2021-01-07  6:52             ` Roi Dayan
2021-01-06 16:00     ` Stephen Hemminger
2021-01-06 16:08       ` Petr Machata [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ft3eujyv.fsf@nvidia.com \
    --to=petrm@nvidia.com \
    --cc=dsahern@gmail.com \
    --cc=me@pmachata.org \
    --cc=netdev@vger.kernel.org \
    --cc=roid@nvidia.com \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.