From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 14674 invoked from network); 30 Jan 2021 20:12:47 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 30 Jan 2021 20:12:47 -0000 Received: (qmail 22512 invoked by uid 550); 30 Jan 2021 20:12:44 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 22491 invoked from network); 30 Jan 2021 20:12:43 -0000 Date: Sat, 30 Jan 2021 15:12:31 -0500 From: Rich Felker To: Jiahao XU Cc: "musl@lists.openwall.com" Message-ID: <20210130201227.GP23432@brightrain.aerifal.cx> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] =?utf-8?B?Q2Fu4oCZ?= =?utf-8?Q?t?= build musl with lto=thin On Fri, Jan 29, 2021 at 12:19:42PM +0000, Jiahao XU wrote: > musl-1.2.2 compilation with clang-11 failed to build libc.so at the final linking stage: > > ld.lld: error: undefined hidden symbol: __dls2 > >>> referenced by ld-temp.o > >>> lto.tmp:(_dlstart_c) > >>> did you mean: __dls3 > >>> defined in: lto.tmp > > I am using CFLAGS=‘-march=native -mtune=native -Oz -flto > -fmerge-all-constants -fomit-frame-pointer’ and LDFLAGS=‘-flto ^^^^^^^^^^^^^^^^^^^^^ The -fmerge-all-constants option gives non-conforming language semantics and should not be used, but that's a separate issue. > -fuse-ld=lld -Wl,—plugin-opt=O3,-O3,—icf=safe’. > No configure option is supplied. Otherwise, it's a known issue that LTO misses references from asm (both top-level and in functions). I think dlstart.lo and a few other files should just be built with LTO disabled; any LTO-type optimization in code that runs at this stage is inherently invalid, anyway. So something like (in config.mak): obj/ldso/dlstart.lo: CFLAGS_ALL += -fno-lto Rich