From owner-freebsd-toolchain@FreeBSD.ORG Thu Dec 13 12:36:33 2012 Return-Path: Delivered-To: toolchain@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 27349356 for ; Thu, 13 Dec 2012 12:36:33 +0000 (UTC) (envelope-from erik@cederstrand.dk) Received: from csmtp3.one.com (csmtp3.one.com [91.198.169.23]) by mx1.freebsd.org (Postfix) with ESMTP id D37F48FC12 for ; Thu, 13 Dec 2012 12:36:32 +0000 (UTC) Received: from [192.168.1.18] (unknown [217.157.7.221]) by csmtp3.one.com (Postfix) with ESMTPA id 62F4A2403B87; Thu, 13 Dec 2012 12:36:25 +0000 (UTC) From: Erik Cederstrand Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: Using non-standard linker Date: Thu, 13 Dec 2012 13:36:25 +0100 Message-Id: <089FCDB5-C0D2-4675-AB71-FD7089BFA031@cederstrand.dk> To: "toolchain@freebsd.org" Mime-Version: 1.0 (Mac OS X Mail 6.2 \(1499\)) X-Mailer: Apple Mail (2.1499) Cc: Pete chou X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Dec 2012 12:36:33 -0000 Hi folks, I'm working with Pete Chou from MCLinker (actually, he's doing almost = all the work) to get mclinker to survive a buildworld. The goal is to = allow mclinker to be a drop-in replacement for GNU ld. My first suggestion was to just add LD=3D/usr/local/bin/mclinker to = src.conf. But this only works when ld is invoked explicitly (and only = when 'ld' is not hard-coded, of course). When ld is invoked internally by the compiler, Pete has tested that = gcc(collect2) and clang do not respect the LD variable, but search for = 'ld' in COMPILER_PATH and then PATH instead. Since mclinker is not part = of the build process, it isn't found in COMPILER_PATH, and GNU ld is = used instead. Instead, he can add an additional compiler search path via = the "-B" flag, which seems to work. I'm worried that 'ld' is so hard-wired everywhere that it's impossible = to specify another name. In that case, my suggestion would be to use = build knobs, e.g. WITH_GNU_LD and WITH_MCLINKER_LD to install either GNU = ld or mclinker as 'ld', but that wouldn't work unless mclinker is = imported into base. What's the FreeBSD way of doing this? What do other toolchains do if = they use a non-GNU ld linker? Thanks, Erik= From owner-freebsd-toolchain@FreeBSD.ORG Thu Dec 13 13:10:54 2012 Return-Path: Delivered-To: toolchain@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 74524CBE for ; Thu, 13 Dec 2012 13:10:54 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from theravensnest.org (theraven.freebsd.your.org [216.14.102.27]) by mx1.freebsd.org (Postfix) with ESMTP id 1D2DA8FC12 for ; Thu, 13 Dec 2012 13:10:53 +0000 (UTC) Received: from c120.sec.cl.cam.ac.uk (c120.sec.cl.cam.ac.uk [128.232.18.120]) (authenticated bits=0) by theravensnest.org (8.14.5/8.14.5) with ESMTP id qBDDAiBS096643 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO); Thu, 13 Dec 2012 13:10:45 GMT (envelope-from theraven@FreeBSD.org) Subject: Re: Using non-standard linker Mime-Version: 1.0 (Apple Message framework v1278) Content-Type: text/plain; charset=us-ascii From: David Chisnall In-Reply-To: <089FCDB5-C0D2-4675-AB71-FD7089BFA031@cederstrand.dk> Date: Thu, 13 Dec 2012 13:10:43 +0000 Content-Transfer-Encoding: quoted-printable Message-Id: <5880F938-A9EC-4B2D-8079-42504DFA87F9@FreeBSD.org> References: <089FCDB5-C0D2-4675-AB71-FD7089BFA031@cederstrand.dk> To: Erik Cederstrand X-Mailer: Apple Mail (2.1278) Cc: "toolchain@freebsd.org" , Pete chou X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Dec 2012 13:10:54 -0000 Hi Eric, The easiest way of doing this is to make /usr/bin/ld (in the host system = and in the bootstrap) into a symbolic link that points to whatever the = selected linker is. I had to do this when testing gold as well (we end = up with ld-gold and ld-bfd and ld being a symlink to one of them). =20 A better solution would be to teach clang about mclinker. I was = pondering adding a linker selection flag, along the lines of the = existing -stdlib=3D for selecting the C++ standard library, as you may = want to pass different options to different linkers. David On 13 Dec 2012, at 12:36, Erik Cederstrand wrote: > Hi folks, >=20 > I'm working with Pete Chou from MCLinker (actually, he's doing almost = all the work) to get mclinker to survive a buildworld. The goal is to = allow mclinker to be a drop-in replacement for GNU ld. >=20 > My first suggestion was to just add LD=3D/usr/local/bin/mclinker to = src.conf. But this only works when ld is invoked explicitly (and only = when 'ld' is not hard-coded, of course). >=20 > When ld is invoked internally by the compiler, Pete has tested that = gcc(collect2) and clang do not respect the LD variable, but search for = 'ld' in COMPILER_PATH and then PATH instead. Since mclinker is not part = of the build process, it isn't found in COMPILER_PATH, and GNU ld is = used instead. Instead, he can add an additional compiler search path via = the "-B" flag, which seems to work. >=20 > I'm worried that 'ld' is so hard-wired everywhere that it's impossible = to specify another name. In that case, my suggestion would be to use = build knobs, e.g. WITH_GNU_LD and WITH_MCLINKER_LD to install either GNU = ld or mclinker as 'ld', but that wouldn't work unless mclinker is = imported into base. >=20 > What's the FreeBSD way of doing this? What do other toolchains do if = they use a non-GNU ld linker? >=20 > Thanks, > Erik > _______________________________________________ > freebsd-toolchain@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-toolchain > To unsubscribe, send any mail to = "freebsd-toolchain-unsubscribe@freebsd.org" From owner-freebsd-toolchain@FreeBSD.ORG Thu Dec 13 13:18:49 2012 Return-Path: Delivered-To: toolchain@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4B1DAED8; Thu, 13 Dec 2012 13:18:49 +0000 (UTC) (envelope-from erik@cederstrand.dk) Received: from csmtp2.one.com (csmtp2.one.com [91.198.169.22]) by mx1.freebsd.org (Postfix) with ESMTP id 014E58FC14; Thu, 13 Dec 2012 13:18:48 +0000 (UTC) Received: from [192.168.187.69] (unknown [87.54.33.251]) by csmtp2.one.com (Postfix) with ESMTPA id 8353C3043C3B; Thu, 13 Dec 2012 13:18:42 +0000 (UTC) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 6.2 \(1499\)) Subject: Re: Using non-standard linker From: Erik Cederstrand In-Reply-To: <5880F938-A9EC-4B2D-8079-42504DFA87F9@FreeBSD.org> Date: Thu, 13 Dec 2012 14:18:42 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <5337BAB6-7EEE-4A1E-9660-902544CCE3EE@cederstrand.dk> References: <089FCDB5-C0D2-4675-AB71-FD7089BFA031@cederstrand.dk> <5880F938-A9EC-4B2D-8079-42504DFA87F9@FreeBSD.org> To: David Chisnall X-Mailer: Apple Mail (2.1499) Cc: "toolchain@freebsd.org" , Pete chou X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Dec 2012 13:18:49 -0000 Den 13/12/2012 kl. 14.10 skrev David Chisnall : > Hi Eric, >=20 > The easiest way of doing this is to make /usr/bin/ld (in the host = system and in the bootstrap) into a symbolic link that points to = whatever the selected linker is. I had to do this when testing gold as = well (we end up with ld-gold and ld-bfd and ld being a symlink to one of = them). Yes, a symlink is of course an easy solution post-install. But 'ld' is = built as part of 'make toolchain', I believe, so this approach wouldn't = work if I wanted mclinker to be used as the linker in 'make buildworld'. = The newly built 'ld' in /usr/obj/ would be used as the linker instead. Erik= From owner-freebsd-toolchain@FreeBSD.ORG Thu Dec 13 13:20:16 2012 Return-Path: Delivered-To: toolchain@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D91ADF2C for ; Thu, 13 Dec 2012 13:20:16 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from theravensnest.org (theraven.freebsd.your.org [216.14.102.27]) by mx1.freebsd.org (Postfix) with ESMTP id 903AE8FC18 for ; Thu, 13 Dec 2012 13:20:15 +0000 (UTC) Received: from c120.sec.cl.cam.ac.uk (c120.sec.cl.cam.ac.uk [128.232.18.120]) (authenticated bits=0) by theravensnest.org (8.14.5/8.14.5) with ESMTP id qBDDKC4P096683 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO); Thu, 13 Dec 2012 13:20:13 GMT (envelope-from theraven@FreeBSD.org) Subject: Re: Using non-standard linker Mime-Version: 1.0 (Apple Message framework v1278) Content-Type: text/plain; charset=us-ascii From: David Chisnall In-Reply-To: <5337BAB6-7EEE-4A1E-9660-902544CCE3EE@cederstrand.dk> Date: Thu, 13 Dec 2012 13:20:11 +0000 Content-Transfer-Encoding: quoted-printable Message-Id: <99D2C6D2-4C56-4724-875D-31FF41CFA2A4@FreeBSD.org> References: <089FCDB5-C0D2-4675-AB71-FD7089BFA031@cederstrand.dk> <5880F938-A9EC-4B2D-8079-42504DFA87F9@FreeBSD.org> <5337BAB6-7EEE-4A1E-9660-902544CCE3EE@cederstrand.dk> To: Erik Cederstrand X-Mailer: Apple Mail (2.1278) Cc: "toolchain@freebsd.org" , Pete chou X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Dec 2012 13:20:16 -0000 On 13 Dec 2012, at 13:18, Erik Cederstrand wrote: >> The easiest way of doing this is to make /usr/bin/ld (in the host = system and in the bootstrap) into a symbolic link that points to = whatever the selected linker is. I had to do this when testing gold as = well (we end up with ld-gold and ld-bfd and ld being a symlink to one of = them). >=20 > Yes, a symlink is of course an easy solution post-install. But 'ld' is = built as part of 'make toolchain', I believe, so this approach wouldn't = work if I wanted mclinker to be used as the linker in 'make buildworld'. = The newly built 'ld' in /usr/obj/ would be used as the linker instead. That's why I said 'and in the bootstrap'. You'd also need to ensure = that the bootstrap build of clang and binutils set up the symlink. = Purely for testing, I think you can do this manually by doing the = bootstrap and then the buildworld as separate make invocations. David= From owner-freebsd-toolchain@FreeBSD.ORG Thu Dec 13 14:48:34 2012 Return-Path: Delivered-To: toolchain@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 41182A95 for ; Thu, 13 Dec 2012 14:48:34 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from mail-da0-f54.google.com (mail-da0-f54.google.com [209.85.210.54]) by mx1.freebsd.org (Postfix) with ESMTP id 03CA08FC17 for ; Thu, 13 Dec 2012 14:48:33 +0000 (UTC) Received: by mail-da0-f54.google.com with SMTP id n2so798389dad.13 for ; Thu, 13 Dec 2012 06:48:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer :x-gm-message-state; bh=JrfrRcYdipTTVhDmk92HSANbamZHU2pLCbKd3JLwvBY=; b=l4fcPBQFSNn0Iqv0isGXq5TUIht4hp7lKu5GGZS4xB9vRVhJ3exWgJPkPfAzsjqIJt 39+C11SqzCKzwEFx9mmwBTBZdJxHJSUyEa9yyYgDlhc61YtcgXz6IGUSWJmhzZ5/fUGV axoGO8VIAZPfGfekcMLTXlPFkOCYgYa6qwTrVqnCKivKdfVcQe4zrW2spo8Zw/ppgYJT ygD+EbdC7rBcZghZpM/T+ATecc3A2sXrveuNeRyP76erXRyxx2Ci2xiZq0YVev4doLlX 47SuI5ODDFxinQ9laQ1ZB68mn83M9iSXI1bKQr8HuLM7NzSEPgT3L/zU1RkpzvzLY6Fr Jr+A== Received: by 10.68.190.38 with SMTP id gn6mr6422761pbc.6.1355410113130; Thu, 13 Dec 2012 06:48:33 -0800 (PST) Received: from [10.0.0.53] (50-78-194-198-static.hfc.comcastbusiness.net. [50.78.194.198]) by mx.google.com with ESMTPS id zv10sm1128607pbc.76.2012.12.13.06.48.29 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 13 Dec 2012 06:48:31 -0800 (PST) Sender: Warner Losh Subject: Re: Using non-standard linker Mime-Version: 1.0 (Apple Message framework v1085) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: <5337BAB6-7EEE-4A1E-9660-902544CCE3EE@cederstrand.dk> Date: Thu, 13 Dec 2012 07:48:26 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <8450A192-367E-4577-97C5-114EDD094BD4@bsdimp.com> References: <089FCDB5-C0D2-4675-AB71-FD7089BFA031@cederstrand.dk> <5880F938-A9EC-4B2D-8079-42504DFA87F9@FreeBSD.org> <5337BAB6-7EEE-4A1E-9660-902544CCE3EE@cederstrand.dk> To: Erik Cederstrand X-Mailer: Apple Mail (2.1085) X-Gm-Message-State: ALoCoQm5453VtfSmmCP66hYoORXEDZVhrVx37CmgqD9dOAIh77HkhIH/fabyza19/hOH8If7g1Mn Cc: "toolchain@freebsd.org" , Pete chou X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Dec 2012 14:48:34 -0000 On Dec 13, 2012, at 6:18 AM, Erik Cederstrand wrote: > Den 13/12/2012 kl. 14.10 skrev David Chisnall : >=20 >> Hi Eric, >>=20 >> The easiest way of doing this is to make /usr/bin/ld (in the host = system and in the bootstrap) into a symbolic link that points to = whatever the selected linker is. I had to do this when testing gold as = well (we end up with ld-gold and ld-bfd and ld being a symlink to one of = them). >=20 > Yes, a symlink is of course an easy solution post-install. But 'ld' is = built as part of 'make toolchain', I believe, so this approach wouldn't = work if I wanted mclinker to be used as the linker in 'make buildworld'. = The newly built 'ld' in /usr/obj/ would be used as the linker instead. Install ld as ld.gnu during the build and after. Make ld a small shell = script that invokes ld.gnu by default, or something else if a variable = is set. Much like the way we have different mail backends to a common = mail front end. Then ld does what people want, and you have a hook to do = different things. Warner From owner-freebsd-toolchain@FreeBSD.ORG Fri Dec 14 08:15:50 2012 Return-Path: Delivered-To: toolchain@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id CC6E2775; Fri, 14 Dec 2012 08:15:50 +0000 (UTC) (envelope-from erik@cederstrand.dk) Received: from csmtp2.one.com (csmtp2.one.com [91.198.169.22]) by mx1.freebsd.org (Postfix) with ESMTP id 818A98FC08; Fri, 14 Dec 2012 08:15:50 +0000 (UTC) Received: from [192.168.1.18] (unknown [217.157.7.221]) by csmtp2.one.com (Postfix) with ESMTPA id 9914B3076404; Fri, 14 Dec 2012 08:15:48 +0000 (UTC) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 6.2 \(1499\)) Subject: Re: Using non-standard linker From: Erik Cederstrand In-Reply-To: <8450A192-367E-4577-97C5-114EDD094BD4@bsdimp.com> Date: Fri, 14 Dec 2012 09:15:49 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: References: <089FCDB5-C0D2-4675-AB71-FD7089BFA031@cederstrand.dk> <5880F938-A9EC-4B2D-8079-42504DFA87F9@FreeBSD.org> <5337BAB6-7EEE-4A1E-9660-902544CCE3EE@cederstrand.dk> <8450A192-367E-4577-97C5-114EDD094BD4@bsdimp.com> To: Warner Losh X-Mailer: Apple Mail (2.1499) Cc: "toolchain@freebsd.org" , Pete chou X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Dec 2012 08:15:50 -0000 Hello Warner, Den 13/12/2012 kl. 15.48 skrev Warner Losh : >=20 > Install ld as ld.gnu during the build and after. Make ld a small = shell script that invokes ld.gnu by default, or something else if a = variable is set. Much like the way we have different mail backends to a = common mail front end. Then ld does what people want, and you have a = hook to do different things. Thanks for the suggestion. Would this be acceptable in FreeBSD if I = created a patch, or are you just suggesting it for my local testing? Thanks, Erik= From owner-freebsd-toolchain@FreeBSD.ORG Fri Dec 14 08:17:36 2012 Return-Path: Delivered-To: toolchain@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E60D87CC for ; Fri, 14 Dec 2012 08:17:36 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from theravensnest.org (theraven.freebsd.your.org [216.14.102.27]) by mx1.freebsd.org (Postfix) with ESMTP id 991D28FC13 for ; Fri, 14 Dec 2012 08:17:36 +0000 (UTC) Received: from [192.168.0.2] (cpc39-cmbg15-2-0-cust69.5-4.cable.virginmedia.com [81.101.138.70]) (authenticated bits=0) by theravensnest.org (8.14.5/8.14.5) with ESMTP id qBE8HRLL001339 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO); Fri, 14 Dec 2012 08:17:28 GMT (envelope-from theraven@FreeBSD.org) Subject: Re: Using non-standard linker Mime-Version: 1.0 (Apple Message framework v1278) Content-Type: text/plain; charset=us-ascii From: David Chisnall In-Reply-To: Date: Fri, 14 Dec 2012 08:17:23 +0000 Content-Transfer-Encoding: quoted-printable Message-Id: <4292EBED-F73B-43E7-A496-5345462B0021@FreeBSD.org> References: <089FCDB5-C0D2-4675-AB71-FD7089BFA031@cederstrand.dk> <5880F938-A9EC-4B2D-8079-42504DFA87F9@FreeBSD.org> <5337BAB6-7EEE-4A1E-9660-902544CCE3EE@cederstrand.dk> <8450A192-367E-4577-97C5-114EDD094BD4@bsdimp.com> To: Erik Cederstrand X-Mailer: Apple Mail (2.1278) Cc: "toolchain@freebsd.org" , Pete chou X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Dec 2012 08:17:37 -0000 On 14 Dec 2012, at 08:15, Erik Cederstrand wrote: > Would this be acceptable in FreeBSD if I created a patch, or are you = just suggesting it for my local testing? I think that we will probably want to import MCLinker as soon as it is = able to (correctly) link the base system, and at that point a patch is = probably a good idea. I'll try to ensure that there is infrastructure = in clang for selecting the linker by that time as well. David=