Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #239645

Re: gcc-10: options order important?

From Sven Joachim <svenjoac@gmx.de>
Newsgroups linux.debian.user
Subject Re: gcc-10: options order important?
Date 2021-09-03 21:00 +0200
Message-ID <CTmzV-K1-11@gated-at.bofh.it> (permalink)
References <CTeCm-42y-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 2021-09-03 12:24 +0200, Piotr A. Dybczyński wrote:

> Hi,
>
> in contrary to previous versions, now in Debian 11 with gcc-10:
>
> gcc aa.c -lm -o aa           works, but
>
> gcc -lm aa.c -o aa           does not work, saying: 
>
> /usr/bin/ld: /tmp/ccWyhudO.o: in function `main':
> aa.c:(.text+0x1f): undefined reference to `sqrt'
> collect2: error: ld returned 1 exit status
>
> It seems that an option -lm cannot be placed in an arbitrary place which I used to
> do. Is this intentional ?

Yes, gcc now invokes ld with the --as-needed option.  This reduces
unnecessary linking and thereby Debian package dependencies, but it also
has the effect you are seeing, as mentioned in the binutils
documentation:

,----
| Object files or libraries appearing on the command line _after_ the
| library in question do not affect whether the library is seen as needed.
| This is similar to the rules for extraction of object files from
| archives.  '--no-as-needed' restores the default behaviour.
`----

Cheers,
       Sven

Back to linux.debian.user | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

gcc-10: options order important? "Piotr A. Dybczyński" <piotr@dybczynski.pl> - 2021-09-03 12:30 +0200
  Re: gcc-10: options order important? Greg Wooledge <greg@wooledge.org> - 2021-09-03 13:40 +0200
  Re: gcc-10: options order important? Tixy <tixy@yxit.co.uk> - 2021-09-03 15:20 +0200
    Re: gcc-10: options order important? Greg Wooledge <greg@wooledge.org> - 2021-09-03 19:00 +0200
      Re: gcc-10: options order important? <tomas@tuxteam.de> - 2021-09-03 20:50 +0200
  Re: gcc-10: options order important? Tixy <tixy@yxit.co.uk> - 2021-09-03 15:20 +0200
  Re: gcc-10: options order important? Sven Joachim <svenjoac@gmx.de> - 2021-09-03 21:00 +0200

csiph-web