From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oo1-xc2c.google.com (mail-oo1-xc2c.google.com [IPv6:2607:f8b0:4864:20::c2c]) by sourceware.org (Postfix) with ESMTPS id 506143850427 for ; Tue, 5 Jan 2021 23:34:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 506143850427 Received: by mail-oo1-xc2c.google.com with SMTP id q6so358416ooo.8 for ; Tue, 05 Jan 2021 15:34:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=edDP7hp+8NukcbLLcoMrqZGVTbPDT0d6Dm+mD/mBiHE=; b=Pw1AVugUFudSXfaK0JUx/X9S0IUl3fb50U8s8ccJ5RzEWbWDwyigQOhCzONg+E1y/b T+jQu8wz3QEIU967U/wNY+dViUKHlCvuOt3nLu7/NRvi2eRN3CApTOfLR4lPKBsDc3pN nMr6IO+pNWaZ3HJFZfvMQh5iu1J8u/Rn4BMMXjx5xHjivzdoIporr/2PmIPzBIP1ezuK QOiMVvIWq0hw01kG0HR9hm18CpIgfRi2nuddzipSOSjrcgOQdFVJ5SPv2k9eUh0bOLy3 /0zUGJCCMNNM6DpSi4qMWUFrMH0aQnr9IKlvWcuDqVzFotVysDQ3iSgX4k2AXqFy2gav 4tBQ== X-Gm-Message-State: AOAM530T4wtMfaZaqzNLMOPDG76TdMH4akLVbZWo2/hDbEKV00Ysnqos RPzZyJvv6Jz52knjbK8GtBPonOps41nk8dFNKao= X-Google-Smtp-Source: ABdhPJw+VfSKeuI9eEyX7ckeNn9t5h2umrgGi9ZSSuroWgzbRFkrGz5haB2sBT4CVLjDrdsZ7MiV1DctEYvPZoq/IMc= X-Received: by 2002:a4a:1e42:: with SMTP id 63mr1012901ooq.57.1609889657736; Tue, 05 Jan 2021 15:34:17 -0800 (PST) MIME-Version: 1.0 References: <20201228194855.510315-1-maskray@google.com> <20201228214541.phbfjgv2ft3mgikj@google.com> In-Reply-To: From: "H.J. Lu" Date: Tue, 5 Jan 2021 15:33:41 -0800 Message-ID: Subject: Re: [PATCH 0/3] Make glibc build with LLD To: =?UTF-8?B?RsSBbmctcnXDrCBTw7JuZw==?= Cc: GNU C Library Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3031.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jan 2021 23:34:20 -0000 On Tue, Jan 5, 2021 at 3:03 PM F=C4=81ng-ru=C3=AC S=C3=B2ng wrote: > > On Mon, Dec 28, 2020 at 2:54 PM H.J. Lu wrote: > > > > On Mon, Dec 28, 2020 at 1:49 PM H.J. Lu wrote: > > > > > > On Mon, Dec 28, 2020 at 1:45 PM Fangrui Song wro= te: > > > > > > > > On 2020-12-28, H.J. Lu wrote: > > > > >On Mon, Dec 28, 2020 at 11:49 AM Fangrui Song via Libc-alpha > > > > > wrote: > > > > >> > > > > >> I sent the first two in April. Resending in a patch series to be > > > > >> clearer. > > > > >> > > > > >> install: Replace scripts/output-format.sed with objdump -f > > > > >> > > > > >> replaced https://sourceware.org/pipermail/libc-alpha/2020-April/= 112733.html > > > > >> by leveraging objdump -f. > > > > >> > > > > >> With this patch series (available in https://sourceware.org/git/= ?p=3Dglibc.git;a=3Dshortlog;h=3Drefs/heads/maskray/lld), > > > > >> `make` with ld pointing to ld.lld (LLVM linker) works. > > > > > > > > > >I tried your branch with "LLD 11.0.0 (compatible with GNU linkers)= " on > > > > >Fedora 33/x86-64, > > > > >"make check" generated: > > > > > > > > > >make[4]: *** [../Makerules:767: > > > > >/export/users/hjl/build/gnu/tools-build/glibc-gitlab-lld/build-x86= _64-linux/elf/tst-tlsmod2.so] > > > > >Error 1 > > > > >make[4]: *** [../Makerules:767: > > > > >/export/users/hjl/build/gnu/tools-build/glibc-gitlab-lld/build-x86= _64-linux/elf/tst-tlsmod4.so] > > > > >Error 1 > > > > >make[4]: *** [../Makerules:767: > > > > >/export/users/hjl/build/gnu/tools-build/glibc-gitlab-lld/build-x86= _64-linux/elf/tst-absolute-sym-lib.so] > > > > >Error 1 > > > > >make[4]: *** [../Makerules:767: > > > > >/export/users/hjl/build/gnu/tools-build/glibc-gitlab-lld/build-x86= _64-linux/elf/tst-absolute-zero-lib.so] > > > > >Error 1 > > > > >make[4]: *** [../Makerules:767: > > > > >/export/users/hjl/build/gnu/tools-build/glibc-gitlab-lld/build-x86= _64-linux/elf/tst-tlsmod6.so] > > > > >Error 1 > > > > >make[4]: *** [../Makerules:767: > > > > >/export/users/hjl/build/gnu/tools-build/glibc-gitlab-lld/build-x86= _64-linux/elf/tst-tlsmod5.so] > > > > >Error 1 > > > > >make[4]: *** [../Rules:226: > > > > >/export/users/hjl/build/gnu/tools-build/glibc-gitlab-lld/build-x86= _64-linux/elf/tst-audit16] > > > > >Error 1 > > > > >make[4]: *** [../Rules:226: > > > > >/export/users/hjl/build/gnu/tools-build/glibc-gitlab-lld/build-x86= _64-linux/elf/tst-audit14] > > > > >Error 1 > > > > >make[4]: *** [../Rules:226: > > > > >/export/users/hjl/build/gnu/tools-build/glibc-gitlab-lld/build-x86= _64-linux/elf/tst-audit15] > > > > >Error 1 > > > > >make[4]: *** [../Rules:226: > > > > >/export/users/hjl/build/gnu/tools-build/glibc-gitlab-lld/build-x86= _64-linux/elf/tst-tls1] > > > > >Error 1 > > > > >make[4]: *** [../Rules:226: > > > > >/export/users/hjl/build/gnu/tools-build/glibc-gitlab-lld/build-x86= _64-linux/elf/ifuncmain5] > > > > >Error 1 > > > > >make[4]: *** [../Rules:226: > > > > >/export/users/hjl/build/gnu/tools-build/glibc-gitlab-lld/build-x86= _64-linux/elf/ifuncmain1] > > > > >Error 1 > > > > >make[3]: *** [Makefile:479: elf/tests] Error 2 > > > > > > > > > >with error messages, like > > > > > > > > > >ld: error: /export/users/hjl/build/gnu/tools-build/glibc-gitlab-ll= d/build-x86_64-linux/elf/tst-tlsmod2.os > > > > >has an STT_TLS symbol but doesn't have an SHF_TLS section > > > > >ld: error: /export/users/hjl/build/gnu/tools-build/glibc-gitlab-ll= d/build-x86_64-linux/elf/tst-tlsmod4.os > > > > >has an STT_TLS symbol but doesn't have an SHF_TLS section > > > > > > > > tst-tls* tests appear to be similar to .tls_common which looks very > > > > obsoleted and not supported by Clang. I don't think ifuncmain* or > > > > tst-audit* matters for typical usage (most users) but I can take a = look. > > > > > > "make check" should be clean on Fedora 33/x86-64. > > > > Because this lld error, "make check" didn't report test summary: > > > > Summary of test results: > > 4322 PASS > > 8 UNSUPPORTED > > 13 XFAIL > > 6 XPASS > > > > > > >When glibc is configured with --enable-static-pie, I got > > > > > > > > > >[hjl@gnu-skx-1 build-x86_64-linux]$ ./elf/ldconfig > > > > >Segmentation fault (core dumped) > > > > >[hjl@gnu-skx-1 build-x86_64-linux]$ > > > > > > > > > >You need to fix lld first and give the working lld a proper versio= n so that > > > > >configure can check it. > > > > > > > > I cherry picked "Make _dl_relocate_static_pie return an int indicat= ing whether it applied relocs." > > > > in google/grte/v5-2.27/master, which has fixed the issue. > > > > > > Why isn't it needed for ld? > > > > > > > Also re-order your patches to place the enabling lld patch the last so = that any > > commits can build a working glibc. > > > > Thanks. > > > > -- > > H.J. > > Without "configure: Allow LD to be LLD 9.0.0 or above", configure > rejects LLD at configure time and the other commits cannot be tested > at all... > > The other commits are general improvement and useful on their own, and > they are independent and can be merged separately. > > As I mentioned in the other reply, LLD does not want to special case > the definition of __rela_iplt_start depending on -no-pie (available in > gold and LLD, not available in GNU ld yet) ; -pie/-shared... > The TLS common issues are obsoleted features that do not make sense nowad= ays. > Any case, the LLD produced executables are functional. The code in question is static void apply_irel (void) { # ifdef IREL /* We use weak references for these so that we'll still work with a linke= r that doesn't define them. Such a linker doesn't support IFUNC at all and so uses won't work, but a statically-linked program that doesn't use any IFUNC symbols won't have a problem. */ extern const IREL_T IPLT_START[] __attribute__ ((weak)); extern const IREL_T IPLT_END[] __attribute__ ((weak)); for (const IREL_T *ipltent =3D IPLT_START; ipltent < IPLT_END; ++ipltent) IREL (ipltent); # endif } Since IPLT_START and IPLT_END are undefined, linker should set them to zero and the loop should be skipped. Why doesn't LLD do that? -- H.J.