From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CBACD384605A; Tue, 6 Apr 2021 14:16:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CBACD384605A From: "matz at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug driver/99896] g++ drops -lc Date: Tue, 06 Apr 2021 14:16: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: matz 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: cc 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: Tue, 06 Apr 2021 14:16:55 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99896 Michael Matz changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |matz at gcc dot gnu.org --- Comment #7 from Michael Matz --- (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 > If you need it before foo.o then -Wl,-lc seems like the right workaround = for > me. Workaround is the correct term here. The correct thing would be for g++ to= not reorder -l arguments. The similarity to -I is superficial: duplicated -l arguments have meaning (with static archives for instance) and their positi= on in relation to object and source files matters. g++ can validly tack on additional -l arguments to the end, and arguably also replace a lone -lc argument that was originally at the end of the command line or implicit (e.= g. to inject its unwinder), but it shouldn't otherwise reorder such arguments. I will of course agree that the issue that the added -lc "solves" is actual= ly a bug in the testcase (and gdb). But that should be immaterial here. At t= he very least gcc and g++ should behave the same in this respect.=