From nobody Mon Jul 19 14:40:56 2021 X-Original-To: toolchain@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7F4FE1270059 for ; Mon, 19 Jul 2021 14:41:00 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GT4K835tzz3MqD for ; Mon, 19 Jul 2021 14:41:00 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from smtp.theravensnest.org (smtp.theravensnest.org [45.77.103.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: theraven) by smtp.freebsd.org (Postfix) with ESMTPSA id 4BDC11711 for ; Mon, 19 Jul 2021 14:41:00 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from [192.168.1.202] (host86-191-32-244.range86-191.btcentralplus.com [86.191.32.244]) by smtp.theravensnest.org (Postfix) with ESMTPSA id C36872AE28 for ; Mon, 19 Jul 2021 15:40:58 +0100 (BST) Subject: Re: Why is main's system clang (12.0.1-rc2) using /usr/local/bin/aarch64-unknown-freebsd14.0-ld ? (such breaks things) To: toolchain@freebsd.org References: <7073D16F-4505-4948-8232-A9618DF2FE5F.ref@yahoo.com> <7073D16F-4505-4948-8232-A9618DF2FE5F@yahoo.com> <77803112-7C05-40EA-9A46-8A5EB419950C@FreeBSD.org> <3B5C7A3A-344F-4CC7-A50D-56E391D04E59@yahoo.com> <0563fd33-75bd-ff16-2d37-ce62f15fa4a9@FreeBSD.org> From: David Chisnall Message-ID: Date: Mon, 19 Jul 2021 15:40:56 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 List-Id: Maintenance of FreeBSD s integrated toolchain List-Archive: https://lists.freebsd.org/archives/freebsd-toolchain List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-toolchain@freebsd.org X-BeenThere: freebsd-toolchain@freebsd.org MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit X-ThisMailContainsUnwantedMimeParts: N On 19/07/2021 13:35, Mark Millard via toolchain wrote: > gcc is not documented to do automatically do such that I've > found. GCC is not Clang. GCC does not allow dynamically choosing the target. If you want a GCC that targets aarch64-unknown-freebsd, then you must build a copy of GCC that targets that triple. If you want a version of clang that targets aarch64-unknown-freebsd, then you pass that to the -target argument. The clang driver will provide a *default* value for the -target argument if one is not provided. >> -flto requires LLD. You can force that with -fuse-ld=lld. Clang then will only find things called [{target triple}-]ld.lld > If I specify -flto (which I did), why is the command invalid > by definition (produces an error message) and so require more > command line options to correct the behavior to not get an > error? Why should the installation or removal of a incompatible > tool chain change the status of the system's clang++ command > line? Clang does not know if ld is lld. It expects that the linker that you provide is compatible with the linker arguments that you provide. If lld is installed as {target}-ld, or if no {target}-ld exists and lld is installed as {somewhere on the search path}/ld, then it will work. If the linker installed on the search path is BFD or some other mostly compatible ld, then it will work unless -flto is or some other linker flag that is not compatible with that linker is specified. I am aware of at least three other non-lld linkers that do support LTO with LLVM, clang doesn't know, for all possible linkers you might have installed, which ones support which flags. > > (The message is far from an obvious one as well, complaining > about a missing file path.) Note that this error comes from your linker, not clang. It is a bit odd that the base system clang tries to use the gold plugin but we don't install it. It should probably check for the existence of LLVMgold.so and not pass it to the linker if it doesn't exist. > There is another message from me where I note that I'd figured > out the -fuse-ld=lld hack, although I omitted "ld." in the > example: should have been aarch64-unknown-freebsd14.0-ld.lld . > I'm actively using this technique because it seems to have the > minimal other potential consequences. If you do anything that depends on a specific linker or linker behaviour (e.g. LTO) then specifying the linker to use is good practice, not a 'hack'. > In the industry, it is fairly normal for a tool chain to > have a place unique to it that wins unless something > special is specified. (And that is after lots of > variations have been tried over the decades.) I've tried > to illustrate that with gcc but it is just one point and > I do not claim there is universal following of such. It is also normal in the industry for a toolchain to be non-modular and to support a single target. Both of these were considered anti-features by LLVM. David