From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by sourceware.org (Postfix) with ESMTPS id 424B438708DD for ; Tue, 22 Sep 2020 17:16:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 424B438708DD Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=maskray.me Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=emacsray@gmail.com Received: by mail-pf1-f175.google.com with SMTP id o20so13045258pfp.11 for ; Tue, 22 Sep 2020 10:16:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=suxN127AnwbMYlplbuYJAyDbVpk/lk3mNcxLEax45Ag=; b=rMsci90Ou1EHykK3XIWPp2/2v7AbvyamQmJCPtrLW+uytGifO3bnUTSJ4jv+d5/rbV NSb4Mq1UgnA+WQ+gmn/eMlesIk01NBOEsm6bWc5pkGjkzanCyWjCJWFNiGmbBSLN5Do1 oycBRJ+r0n0HRC0m3k+6CzARC9Ul5fzF8NV8gViFnlccaCGpOU/VzsYRL62NU6w6dhpX Rq1zlYimpY7tSpGGtBi4Hb2NLPyNwJ9o9WXdyRG815vZbwZ1EWXrAQRfG//mQnTlLnb+ dHKP6CgAvm+iYl8IBEKTtAOUhL2zY0YL7ddbZ4E4WSklVQminS3+vnW9Jera5PrwGCA8 Thjw== X-Gm-Message-State: AOAM531oftRKJTE9bm9Xi87GvNSYKu3VXuBGCAJ1YOqHNQmlcJVOS06f 3OW1gViR9RphZW4euNQbAXZHmhX1Lvve9Q== X-Google-Smtp-Source: ABdhPJxXplRrHoM54WQRnEp1KutW8xAEAiCpPzu0lHTSLoAAqG6uj6Vrr5qH4WMeguOr7JRc2yC9iw== X-Received: by 2002:a63:1408:: with SMTP id u8mr3970811pgl.297.1600795000427; Tue, 22 Sep 2020 10:16:40 -0700 (PDT) Received: from localhost ([2601:647:4b01:ae80::51fb]) by smtp.gmail.com with ESMTPSA id q190sm16111669pfc.176.2020.09.22.10.16.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2020 10:16:39 -0700 (PDT) Date: Tue, 22 Sep 2020 10:16:38 -0700 From: Fangrui Song To: Howard Chu Cc: Nick Clifton , binutils@sourceware.org Subject: Re: [PATCH] dependency list for static libraries Message-ID: <20200922171638.kkapdimub5iled5o@gmail.com> References: <53b8973b-40a4-2550-3307-66d7f13707d5@symas.com> <64fe82bd-9c00-b232-98d2-f46182fb16ba@symas.com> <9889c54b-4dd3-2275-6621-c2391cfd268d@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_INFOUSMEBIZ, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, URI_HEX autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Sep 2020 17:16:43 -0000 Did the thread start at https://sourceware.org/legacy-ml/binutils/2017-09/msg00158.html ? If all dependencies are specified on the command line but there are "backward references", we can step back and think about loosing the requirement like some other binary formats: https://sourceware.org/pipermail/binutils/2020-September/113194.html "Memoryless" archive processing of ld If some archives want system libraries (e.g. -lm -lpthread), MSVC style #pragma comment(lib, "pthread") may be convenient. clang supports the syntax for ELF and the syntax has been used in several places in libc++. LLD supports .deplibs ( http://lists.llvm.org/pipermail/llvm-dev/2019-March/131004.html http://llvm.1065342.n5.nabble.com/llvm-dev-RFC-ELF-Autolinking-td126998.html ) On 2020-09-22, Howard Chu wrote: >Nick Clifton wrote: >> Hi Howard, >> >>>> * It is not clear to me why you create a binary bfd for Libdeps_bfd but >>>> then convert it to a plugin type bfd. Can you explain what you are >>>> doing here ? >>> >>> This was a major hassle, I should have commented it. The bfd gets created >>> with type "plugin", and that refuses the bfd_bwrite() call. (Just fails.) >>> The write only succeeded if I set it to "binary" type first. But then, trying >>> to add this bfd to the archive failed unless I changed the type back to "plugin." >> >> OK - please could you add a comment to this effect to enlighten future readers. > >OK, new patch attached. Added comments, NEWS entry, texi doc, test case. > >>>> * The change to the code to call ar_emul_replace() inside replace_members() >>>> looks wrong to me. The current code will try to replace all of the entries >>>> on the files_to_move list, and will set changed to TRUE if any of the >>>> replacements succeeds. The patched code will changed to FALSE if any >>>> replacement fails, even if earlier ones succeeded. >>> >>> No, that's not correct. The patched code ORs in the result, so it will not >>> change any previous success into a failure. >> >> Doh - OK, I misread this. But I think that there is still a possible problem. >> Since the result is ORed in, if there is a failed call to ar_emul_replace after >> a successful one, changed will still be TRUE, and the failed element will be >> removed from the chain. This differs from the old behaviour where the element >> would not be removed if ar_emul_replace() fails. (I am not sure however what >> the impact of this change will be). > >OK, fixed this to preserve the original behavior for failed elements. > >>> OK. Any suggestions on what exactly to check? >> >> Sure. I would suggest adding a test that checks to see that: >> >> ar cvL libfoo.a "/foo/bar/" foo.o >> >> (something like that) actually creates a library with a libdeps element >> in it. Take a look at binutils/testsuite/binutils-all/ar.exp where other >> tests on ar are run. Basically you need to create a new proc to the file >> and then invoke it at the end of the file. The new proc would probably >> look something like this: > >Thanks. Had to tweak 2 lines but otherwise this worked. > >> proc test_add_dependencies { } {