From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Subject: bug#30395: bug#30820: Chunked store references in compiled code break grafting (again) Date: Wed, 21 Mar 2018 00:07:30 +0100 Message-ID: <87fu4uibwt.fsf@gnu.org> References: <87o9jq7j7r.fsf@gnu.org> <87efkm7eov.fsf@gnu.org> <87in9wxuwo.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47350) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eyQMR-00024x-1T for bug-guix@gnu.org; Tue, 20 Mar 2018 19:08:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eyQMN-0003tk-0f for bug-guix@gnu.org; Tue, 20 Mar 2018 19:08:07 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:36466) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eyQMM-0003tX-SU for bug-guix@gnu.org; Tue, 20 Mar 2018 19:08:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eyQMM-0004h4-HE for bug-guix@gnu.org; Tue, 20 Mar 2018 19:08:02 -0400 Sender: "Debbugs-submit" Resent-To: bug-guix@gnu.org Resent-Message-ID: In-Reply-To: <87in9wxuwo.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Fri, 16 Mar 2018 09:54:31 +0100") List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: 30820-done@debbugs.gnu.org Cc: 30395-done@debbugs.gnu.org Hello, ludo@gnu.org (Ludovic Court=C3=A8s) skribis: > So the real issue is this: > >> The second issue is that the patch only ever worked with literal >> strings. It does not =E2=80=9Csee=E2=80=9D strings in constant arrays l= ike the =E2=80=98str=E2=80=99 >> array in the example above. Good news! Commit e288572710250bcd2aa0f69ce88154d98ac69b29 adjusts =E2=80=98gcc-strmov-store-file-names.patch=E2=80=99 in =E2=80=98core-update= s=E2=80=99 to correctly deal with this case: --8<---------------cut here---------------start------------->8--- $ cat strmov.c=20 #define _GNU_SOURCE #include static const char str[] =3D "This is a /gnu/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee string in a glob= al variable."; extern char *p, *q; #ifndef MEMCPY # define MEMCPY memcpy #endif void foo (char *x, char *y) { MEMCPY (x, str, sizeof str); MEMCPY (y, "this is a literal /gnu/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee= ee string", 35); } $ ./pre-inst-env guix build -e '(@@ (gnu packages commencement) gcc-final)' /gnu/store/wzdyqkdslk1s6f0vi9qw1xha8cniijzs-gcc-5.5.0-lib /gnu/store/46ww5s9zvsw04id438c4drpnwd9m6vl8-gcc-5.5.0 $ /gnu/store/46ww5s9zvsw04id438c4drpnwd9m6vl8-gcc-5.5.0/bin/gcc -O2 -c strm= ov.c $ objdump -S strmov.o |grep movabs $ NIX_STORE=3D/foo /gnu/store/46ww5s9zvsw04id438c4drpnwd9m6vl8-gcc-5.5.0/bi= n/gcc -O2 -c strmov.c $ objdump -S strmov.o |grep movabs 0: 48 b8 54 68 69 73 20 movabs $0x2073692073696854,%rax a: 48 ba 74 6f 72 65 2f movabs $0x6565652f65726f74,%rdx 1e: 48 b8 61 20 2f 67 6e movabs $0x732f756e672f2061,%rax 30: 48 b8 65 65 65 65 65 movabs $0x6565656565656565,%rax 4a: 48 b8 65 65 65 65 65 movabs $0x2065656565656565,%rax 58: 48 b8 73 74 72 69 6e movabs $0x6920676e69727473,%rax 66: 48 b8 6e 20 61 20 67 movabs $0x626f6c672061206e,%rax 74: 48 b8 61 6c 20 76 61 movabs $0x6169726176206c61,%rax 82: 48 b8 74 68 69 73 20 movabs $0x2073692073696874,%rax 93: 48 b8 61 20 6c 69 74 movabs $0x61726574696c2061,%rax a5: 48 b8 6c 20 2f 67 6e movabs $0x732f756e672f206c,%rax --8<---------------cut here---------------end--------------->8--- I built everything about to =E2=80=98gcc-final=E2=80=99 in =E2=80=98core-up= dates=E2=80=99. I checked manually that none of the /gnu/store references in libc-2.26.so were chunked. For the record, what the patch initially did was to skip code that would otherwise emit a =E2=80=9Cblock move=E2=80=9D when expanding __builtin_memc= py & co. This patch additionally skips similar code that would replace __builtin_memcpy calls with memory moves early on, in =E2=80=98gimple_fold_builtin_memory_op=E2=80=99, before =E2=80=98expand_bui= ltin=E2=80=99 is called. In the example above, this transformation would lead to the code below (as seen with =E2=80=98-fdump-tree-all=E2=80=99 in the =E2=80=98gimple=E2= =80=99 phase output): --8<---------------cut here---------------start------------->8--- foo (char * x, char * y) { MEM[(char * {ref-all})x] =3D MEM[(char * {ref-all})&str]; memcpy (y, "this is a literal /gnu/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee= ee string", 35); } --8<---------------cut here---------------end--------------->8--- With the patch we get: --8<---------------cut here---------------start------------->8--- foo (char * x, char * y) { memcpy (x, &str, 85); memcpy (y, "this is a literal /gnu/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee= ee string", 35); } --8<---------------cut here---------------end--------------->8--- Ludo=E2=80=99.