From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4100D3858004; Sat, 3 Apr 2021 16:57:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4100D3858004 From: "vries at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug driver/99896] g++ drops -lc Date: Sat, 03 Apr 2021 16:57:55 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: driver X-Bugzilla-Version: 10.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Apr 2021 16:57:55 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99896 --- Comment #2 from Tom de Vries --- (In reply to Jonathan Wakely from comment #1) > (In reply to Tom de Vries from comment #0) > > With g++, we have instead: > > ... > > collect2 ... main.o foo.o -lpcre2-posix ... > > ... >=20 > It isn't dropped, it's moved to the end: >=20 > main.o foo.o -lpcre2-posix -lstdc++ -lm -lc -lgcc_s -lgcc -lc -lgcc_s -lg= cc >=20 I don't understand. AFAICT, it's dropped. It's not moved to the end, becau= se -lc is already at the end without specifying -lc.=20 > If you need it before foo.o then -Wl,-lc seems like the right workaround = for > me. >=20 Um, for my understanding, does that mean you agree this is a bug in g++? > Why is it needed there anyway though? main.o is intended to use regcomp from glibc. Foo.o is intended to use pcre2_regcomp from pcre2-posix (which is also accessible using plain regcom= p).=20 When -lc is droppend, regcomp from pcre2-posix is used by main instead, whi= ch is incompatible with using re_search from glibc.=