From owner-freebsd-toolchain@FreeBSD.ORG Sun Nov 21 15:23:05 2010 Return-Path: Delivered-To: freebsd-toolchain@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 350CA1065674 for ; Sun, 21 Nov 2010 15:23:05 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (cl-327.ede-01.nl.sixxs.net [IPv6:2001:7b8:2ff:146::2]) by mx1.freebsd.org (Postfix) with ESMTP id A8E968FC14 for ; Sun, 21 Nov 2010 15:23:04 +0000 (UTC) Received: from [IPv6:2001:7b8:3a7:0:b9a3:5f94:4931:f43f] (unknown [IPv6:2001:7b8:3a7:0:b9a3:5f94:4931:f43f]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id DE9E15C5A; Sun, 21 Nov 2010 16:22:58 +0100 (CET) Message-ID: <4CE93959.7070600@FreeBSD.org> Date: Sun, 21 Nov 2010 16:23:05 +0100 From: Dimitry Andric Organization: The FreeBSD Project User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.13pre) Gecko/20101118 Lanikai/3.1.7pre MIME-Version: 1.0 To: Erik Cederstrand References: <4CE06C4F.7000002@FreeBSD.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-toolchain@freebsd.org Subject: Re: Clang and -frandom-seed X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Nov 2010 15:23:05 -0000 On 2010-11-15 11:10, Erik Cederstrand wrote: > I was thinking of something along the same lines. I think we agree > that it only needs to be random across files, not across builds. > Someone on llvm-dev also suggested using the path (either full or > relative to src/) as a seed. The path should relative, to guarantee the same result for every location you can put the source. > Where in the build scripts would I need to add this flag? Something like: > > CXXFLAGS += -frandom-seed=${.TARGET} Rather use: CXXFLAGS+=-frandom-seed=${.IMPSRC:S/^${.CURDIR}\///} which is rather contorted, but I see no other way to generate a relative path. :) Also, this generates an empty '-frandom-seed=' option for every command that uses CXXFLAGS but isn't a compilation at all, such as most linking commands. It is probably not harmful, though. From owner-freebsd-toolchain@FreeBSD.ORG Sun Nov 21 15:25:04 2010 Return-Path: Delivered-To: freebsd-toolchain@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5F8C5106566C for ; Sun, 21 Nov 2010 15:25:04 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (cl-327.ede-01.nl.sixxs.net [IPv6:2001:7b8:2ff:146::2]) by mx1.freebsd.org (Postfix) with ESMTP id C31808FC0C for ; Sun, 21 Nov 2010 15:25:03 +0000 (UTC) Received: from [IPv6:2001:7b8:3a7:0:b9a3:5f94:4931:f43f] (unknown [IPv6:2001:7b8:3a7:0:b9a3:5f94:4931:f43f]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 0D55E5C5A; Sun, 21 Nov 2010 16:25:03 +0100 (CET) Message-ID: <4CE939D6.7090307@FreeBSD.org> Date: Sun, 21 Nov 2010 16:25:10 +0100 From: Dimitry Andric Organization: The FreeBSD Project User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.13pre) Gecko/20101118 Lanikai/3.1.7pre MIME-Version: 1.0 To: Erik Cederstrand References: <4CE06C4F.7000002@FreeBSD.org> <68B6258D-6853-4FF0-BE09-13B8E99BC874@cederstrand.dk> In-Reply-To: <68B6258D-6853-4FF0-BE09-13B8E99BC874@cederstrand.dk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-toolchain@freebsd.org Subject: Re: Clang and -frandom-seed X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Nov 2010 15:25:04 -0000 On 2010-11-19 16:51, Erik Cederstrand wrote: > Poking around, I decided to add this patch: > > # svn diff lib/clang/clang.build.mk > Index: lib/clang/clang.build.mk > =================================================================== > --- lib/clang/clang.build.mk (revision 215422) > +++ lib/clang/clang.build.mk (working copy) > @@ -28,6 +28,13 @@ > CXXFLAGS+=-fno-rtti > .endif > > +.ifdef WITH_DETERMINISTIC > +CXXFLAGS+=-frandom-seed=0 > +.endif This will probably not work as expected. The -frandom-seed option must be different for each source file. > and added "WITH_DETERMINISTIC=true" to /etc/src.conf. The "random-seed=0" should ensure that the same random elements are generated every time. > > I then ran two buildworlds with the same MAKEOBJDIRPREFIX but two different DESTDIRs, and compared the two clang binaries. The random-seed option does show up un the log, so it's getting picked up, but apparently it was not enough, as the random elements are still different. > > Any hints on where in the build infrastructure I should add the flag, or what to grep for in the buildworld log to find out what's wrong? > > Also, how can I compile just clang? I tried "cd src/usr.bin/clang; make" but it dies violently: > > /usr/home/erik/freebsd/head/src/usr.bin/clang/clang/../../../contrib/llvm/tools/clang/include/clang/Basic/Diagnostic.h: At global scope: > /usr/home/erik/freebsd/head/src/usr.bin/clang/clang/../../../contrib/llvm/tools/clang/include/clang/Basic/Diagnostic.h:999: error: expected ',' or '...' before '&' token > /usr/home/erik/freebsd/head/src/usr.bin/clang/clang/../../../contrib/llvm/tools/clang/include/clang/Basic/Diagnostic.h:1000: error: ISO C++ forbids declaration of 'LangOptions' with no type > /usr/home/erik/freebsd/head/src/usr.bin/clang/clang/../../../contrib/llvm/tools/clang/include/clang/Basic/Diagnostic.h:1019: error: expected declaration before '}' token I don't see this error if I repeat your commands, but in any case you must first build in lib/clang, before you can build in usr.bin/clang, e.g.: make -C $SRCDIR/lib/clang && make -C $SRCDIR/usr.bin/clang From owner-freebsd-toolchain@FreeBSD.ORG Mon Nov 22 14:05:27 2010 Return-Path: Delivered-To: freebsd-toolchain@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0DDC8106564A; Mon, 22 Nov 2010 14:05:27 +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 889FE8FC12; Mon, 22 Nov 2010 14:05:26 +0000 (UTC) Received: from [192.168.0.22] (0x573fa596.cpe.ge-1-1-0-1109.ronqu1.customer.tele.dk [87.63.165.150]) by csmtp2.one.com (Postfix) with ESMTPA id A9C474BC07C27; Mon, 22 Nov 2010 14:05:24 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1081) Content-Type: multipart/signed; boundary=Apple-Mail-2732-742395410; protocol="application/pkcs7-signature"; micalg=sha1 From: Erik Cederstrand In-Reply-To: <4CE93959.7070600@FreeBSD.org> Date: Mon, 22 Nov 2010 15:05:24 +0100 Message-Id: <1F5D7910-3AC6-4ACA-A7C5-EC28B9EABF52@cederstrand.dk> References: <4CE06C4F.7000002@FreeBSD.org> <4CE93959.7070600@FreeBSD.org> To: Dimitry Andric X-Mailer: Apple Mail (2.1081) X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-toolchain@freebsd.org Subject: Re: Clang and -frandom-seed X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Nov 2010 14:05:27 -0000 --Apple-Mail-2732-742395410 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Den 21/11/2010 kl. 16.23 skrev Dimitry Andric: > On 2010-11-15 11:10, Erik Cederstrand wrote: >=20 >> Where in the build scripts would I need to add this flag? Something = like: >>=20 >> CXXFLAGS +=3D -frandom-seed=3D${.TARGET} >=20 > Rather use: >=20 > CXXFLAGS+=3D-frandom-seed=3D${.IMPSRC:S/^${.CURDIR}\///} >=20 > which is rather contorted, but I see no other way to generate a = relative > path. :) >=20 > Also, this generates an empty '-frandom-seed=3D' option for every = command > that uses CXXFLAGS but isn't a compilation at all, such as most = linking > commands. It is probably not harmful, though. I added .ifdef WITH_DETERMINISTIC CXXFLAGS+=3D-frandom-seed=3D\"${.IMPSRC:S/^${.CURDIR}\///}\" .endif to lib/clang/clang.build.mk and "WITH_DETERMINISTIC=3Dtrue" to src.conf, but apparently the flag = isn't being propagated to clang.build.mk. However it is being picked up = if I pass it on the command-line: make WITH_DETERMINISTIC=3Dtrue buildworld Why isn't the flag available in clang.build.mk? Erik= --Apple-Mail-2732-742395410-- From owner-freebsd-toolchain@FreeBSD.ORG Mon Nov 22 14:24:06 2010 Return-Path: Delivered-To: freebsd-toolchain@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E4EDC1065673 for ; Mon, 22 Nov 2010 14:24:06 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (cl-327.ede-01.nl.sixxs.net [IPv6:2001:7b8:2ff:146::2]) by mx1.freebsd.org (Postfix) with ESMTP id A13D38FC1D for ; Mon, 22 Nov 2010 14:24:06 +0000 (UTC) Received: from [IPv6:2001:7b8:3a7:0:7d0d:79cb:e810:42f5] (unknown [IPv6:2001:7b8:3a7:0:7d0d:79cb:e810:42f5]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id ACF175C5A; Mon, 22 Nov 2010 15:24:04 +0100 (CET) Message-ID: <4CEA7D0D.7030309@FreeBSD.org> Date: Mon, 22 Nov 2010 15:24:13 +0100 From: Dimitry Andric Organization: The FreeBSD Project User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.13pre) Gecko/20101118 Lanikai/3.1.7pre MIME-Version: 1.0 To: Erik Cederstrand References: <4CE06C4F.7000002@FreeBSD.org> <4CE93959.7070600@FreeBSD.org> <1F5D7910-3AC6-4ACA-A7C5-EC28B9EABF52@cederstrand.dk> In-Reply-To: <1F5D7910-3AC6-4ACA-A7C5-EC28B9EABF52@cederstrand.dk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-toolchain@freebsd.org Subject: Re: Clang and -frandom-seed X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Nov 2010 14:24:07 -0000 On 2010-11-22 15:05, Erik Cederstrand wrote: > .ifdef WITH_DETERMINISTIC > CXXFLAGS+=-frandom-seed=\"${.IMPSRC:S/^${.CURDIR}\///}\" > .endif > > to lib/clang/clang.build.mk > > and "WITH_DETERMINISTIC=true" to src.conf, but apparently the flag isn't being propagated to clang.build.mk. However it is being picked up if I pass it on the command-line: > > make WITH_DETERMINISTIC=true buildworld > > Why isn't the flag available in clang.build.mk? Well, src.conf is only picked up if you .include , or another bsd.*.mk file that includes bsd.own.mk in turn. So normally, you would have a Makefile in e.g. usr.bin/clang/clang, which includes bsd.own.mk, and then includes clang.build.mk. Only in that case the variables from src.conf are available. In contrast, make.conf is read from sys.mk, so its contents are always available. Same if you put variables on the command line; those even override *any* assignment in the Makefiles themselves... From owner-freebsd-toolchain@FreeBSD.ORG Mon Nov 22 14:48:00 2010 Return-Path: Delivered-To: freebsd-toolchain@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6EE0B106566B; Mon, 22 Nov 2010 14:48:00 +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 F2E528FC0C; Mon, 22 Nov 2010 14:47:59 +0000 (UTC) Received: from [192.168.0.22] (0x573fa596.cpe.ge-1-1-0-1109.ronqu1.customer.tele.dk [87.63.165.150]) by csmtp2.one.com (Postfix) with ESMTPA id 9470A42A9B926; Mon, 22 Nov 2010 14:47:58 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1081) Content-Type: multipart/signed; boundary=Apple-Mail-2734-744949381; protocol="application/pkcs7-signature"; micalg=sha1 From: Erik Cederstrand In-Reply-To: <4CEA7D0D.7030309@FreeBSD.org> Date: Mon, 22 Nov 2010 15:47:58 +0100 Message-Id: References: <4CE06C4F.7000002@FreeBSD.org> <4CE93959.7070600@FreeBSD.org> <1F5D7910-3AC6-4ACA-A7C5-EC28B9EABF52@cederstrand.dk> <4CEA7D0D.7030309@FreeBSD.org> To: Dimitry Andric X-Mailer: Apple Mail (2.1081) X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-toolchain@freebsd.org Subject: Re: Clang and -frandom-seed X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Nov 2010 14:48:00 -0000 --Apple-Mail-2734-744949381 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Den 22/11/2010 kl. 15.24 skrev Dimitry Andric: > Well, src.conf is only picked up if you .include , or > another bsd.*.mk file that includes bsd.own.mk in turn. >=20 > So normally, you would have a Makefile in e.g. usr.bin/clang/clang, > which includes bsd.own.mk, and then includes clang.build.mk. Only in > that case the variables from src.conf are available. >=20 > In contrast, make.conf is read from sys.mk, so its contents are always > available. Same if you put variables on the command line; those even > override *any* assignment in the Makefiles themselves... I was wondering, since the first thing usr.bin/clang/clang/Makefile does = is import bsd.own.mk. It then imports src/usr.bin/clang/clang.prog.mk = which again imports lib/clang/clang.build.mk. The Makefiles in lib/clang/[subdir] import lib/clang/clang.lib.mk, which = imports bsd.lib.mk, which in turn imports bsd.own.mk. But = lib/clang/clang.build.mk is imported first, which is probably why = src.conf isn't available in clang.build.mk. Would it be possible to swap = the two .includes around in lib/clang/clang.lib.mk? Erik= --Apple-Mail-2734-744949381-- From owner-freebsd-toolchain@FreeBSD.ORG Mon Nov 22 14:55:31 2010 Return-Path: Delivered-To: freebsd-toolchain@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2575710656A4; Mon, 22 Nov 2010 14:55:31 +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 A6C2D8FC2F; Mon, 22 Nov 2010 14:55:30 +0000 (UTC) Received: from [192.168.0.22] (0x573fa596.cpe.ge-1-1-0-1109.ronqu1.customer.tele.dk [87.63.165.150]) by csmtp2.one.com (Postfix) with ESMTPA id 716185996F61F; Mon, 22 Nov 2010 14:55:29 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1081) Content-Type: multipart/signed; boundary=Apple-Mail-2735-745400249; protocol="application/pkcs7-signature"; micalg=sha1 From: Erik Cederstrand In-Reply-To: Date: Mon, 22 Nov 2010 15:55:29 +0100 Message-Id: <9427F549-F8CF-418A-8FE4-4ED81D2942A6@cederstrand.dk> References: <4CE06C4F.7000002@FreeBSD.org> <4CE93959.7070600@FreeBSD.org> <1F5D7910-3AC6-4ACA-A7C5-EC28B9EABF52@cederstrand.dk> <4CEA7D0D.7030309@FreeBSD.org> To: Dimitry Andric X-Mailer: Apple Mail (2.1081) X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-toolchain@freebsd.org Subject: Re: Clang and -frandom-seed X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Nov 2010 14:55:32 -0000 --Apple-Mail-2735-745400249 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Den 22/11/2010 kl. 15.47 skrev Erik Cederstrand: > Den 22/11/2010 kl. 15.24 skrev Dimitry Andric: >=20 >> Well, src.conf is only picked up if you .include , or >> another bsd.*.mk file that includes bsd.own.mk in turn. >>=20 >> So normally, you would have a Makefile in e.g. usr.bin/clang/clang, >> which includes bsd.own.mk, and then includes clang.build.mk. Only in >> that case the variables from src.conf are available. >>=20 >> In contrast, make.conf is read from sys.mk, so its contents are = always >> available. Same if you put variables on the command line; those even >> override *any* assignment in the Makefiles themselves... >=20 > I was wondering, since the first thing usr.bin/clang/clang/Makefile = does is import bsd.own.mk. It then imports = src/usr.bin/clang/clang.prog.mk which again imports = lib/clang/clang.build.mk. >=20 > The Makefiles in lib/clang/[subdir] import lib/clang/clang.lib.mk, = which imports bsd.lib.mk, which in turn imports bsd.own.mk. But = lib/clang/clang.build.mk is imported first, which is probably why = src.conf isn't available in clang.build.mk. Would it be possible to swap = the two .includes around in lib/clang/clang.lib.mk? If not, I added my CXXFLAGS to share/mk/bsd.own.mk which seems logical = anyway since other C++ programs may benefit from it. Erik= --Apple-Mail-2735-745400249--