From: ludo@gnu.org (Ludovic Courtès)
To: 30820@debbugs.gnu.org
Subject: bug#30820: Chunked store references in compiled code break grafting (again)
Date: Wed, 14 Mar 2018 18:24:48 +0100 [thread overview]
Message-ID: <87efkm7eov.fsf@gnu.org> (raw)
In-Reply-To: <87o9jq7j7r.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Wed, 14 Mar 2018 16:47:04 +0100")
There are two issues. First the gcc-strmov-store-file-names.patch
stopped working. When we introduced it, we were at 5.3.0 and 6.2.0 (see
<https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/gcc.scm?id=8033772363b287ca529461e575ceb4a69d7af942>).
Today, with 5.5.0 and 6.3.0 it seems to have no effect (I use ‘ltrace’
here, which shows the getenv("NIX_STORE") call, which confirms that the
‘store_reference_p’ function in that patch gets called):
--8<---------------cut here---------------start------------->8---
$ cat strmov.c
#define _GNU_SOURCE
#include <string.h>
static const char str[] = "MEMpCPY /gnu/store/THIS IS A LONG STRING, A VERY, VERY, VERY LOOOOONG STRING";
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 string", 35);
}
$ guix environment --no-grafts --pure --ad-hoc -C ltrace gcc-toolchain@5 -- ltrace -f -e getenv gcc -O2 -c strmov.c
[pid 2] gcc->getenv("COLUMNS") = nil
[pid 2] gcc->getenv("TERM") = nil
[pid 2] gcc->getenv("GCC_EXEC_PREFIX") = nil
[pid 2] gcc->getenv("PATH") = "/gnu/store/c312mxd0ykdh3zi3zj13m"...
[pid 2] gcc->getenv("PATH") = "/gnu/store/c312mxd0ykdh3zi3zj13m"...
[pid 2] gcc->getenv("COMPILER_PATH") = nil
[pid 2] gcc->getenv("LIBRARY_PATH") = "/gnu/store/c312mxd0ykdh3zi3zj13m"...
[pid 2] gcc->getenv("LPATH") = nil
[pid 2] gcc->getenv("GCC_COMPARE_DEBUG") = nil
[pid 2] gcc->getenv("GCC_ROOT") = nil
[pid 2] gcc->getenv("BINUTILS_ROOT") = nil
[pid 2] gcc->getenv("TMPDIR") = "/tmp"
[pid 2] gcc->getenv("TMP") = "/tmp"
[pid 2] gcc->getenv("TEMP") = "/tmp"
[pid 3] --- Called exec() ---
[pid 3] gcc->getenv("COLUMNS") = nil
[pid 3] gcc->getenv("TERM") = nil
[pid 3] gcc->getenv("DEPENDENCIES_OUTPUT") = nil
[pid 3] gcc->getenv("SUNPRO_DEPENDENCIES") = nil
[pid 3] gcc->getenv("CPATH") = nil
[pid 3] gcc->getenv("C_INCLUDE_PATH") = "/gnu/store/c312mxd0ykdh3zi3zj13m"...
[pid 3] gcc->getenv("GCC_EXEC_PREFIX") = nil
[pid 3] gcc->getenv("PWD") = nil
[pid 3] gcc->getenv("NIX_STORE") = nil
[pid 3] +++ exited (status 0) +++
[pid 2] --- SIGCHLD (Child exited) ---
[pid 4] --- Called exec() ---
[pid 4] +++ exited (status 0) +++
[pid 2] --- SIGCHLD (Child exited) ---
[pid 2] +++ exited (status 0) +++
$ objdump -S strmov.o | grep movabs
0: 48 b8 74 68 69 73 20 movabs $0x2073692073696874,%rax
11: 48 b8 61 20 6c 69 74 movabs $0x61726574696c2061,%rax
1f: 48 b8 6c 20 2f 67 6e movabs $0x732f756e672f206c,%rax
2d: 48 b8 74 6f 72 65 20 movabs $0x7274732065726f74,%rax
$ guix environment --no-grafts --pure --ad-hoc -C ltrace gcc-toolchain@6 -- ltrace -f -e getenv gcc -O2 -c strmov.c
[pid 2] gcc->getenv("COLUMNS") = nil
[pid 2] gcc->getenv("TERM") = nil
[pid 2] gcc->getenv("GCC_EXEC_PREFIX") = nil
[pid 2] gcc->getenv("PATH") = "/gnu/store/5141337yvhhjj5fhdx660"...
[pid 2] gcc->getenv("PATH") = "/gnu/store/5141337yvhhjj5fhdx660"...
[pid 2] gcc->getenv("COMPILER_PATH") = nil
[pid 2] gcc->getenv("LIBRARY_PATH") = "/gnu/store/5141337yvhhjj5fhdx660"...
[pid 2] gcc->getenv("LPATH") = nil
[pid 2] gcc->getenv("GCC_COMPARE_DEBUG") = nil
[pid 2] gcc->getenv("GCC_ROOT") = nil
[pid 2] gcc->getenv("BINUTILS_ROOT") = nil
[pid 2] gcc->getenv("TMPDIR") = "/tmp"
[pid 2] gcc->getenv("TMP") = "/tmp"
[pid 2] gcc->getenv("TEMP") = "/tmp"
[pid 3] --- Called exec() ---
[pid 3] gcc->getenv("COLUMNS") = nil
[pid 3] gcc->getenv("TERM") = nil
[pid 3] gcc->getenv("DEPENDENCIES_OUTPUT") = nil
[pid 3] gcc->getenv("SUNPRO_DEPENDENCIES") = nil
[pid 3] gcc->getenv("CPATH") = nil
[pid 3] gcc->getenv("C_INCLUDE_PATH") = "/gnu/store/5141337yvhhjj5fhdx660"...
[pid 3] gcc->getenv("GCC_EXEC_PREFIX") = nil
[pid 3] gcc->getenv("PWD") = nil
[pid 3] gcc->getenv("NIX_STORE") = nil
[pid 3] +++ exited (status 0) +++
[pid 2] --- SIGCHLD (Child exited) ---
[pid 4] --- Called exec() ---
[pid 4] +++ exited (status 0) +++
[pid 2] --- SIGCHLD (Child exited) ---
[pid 2] +++ exited (status 0) +++
$ objdump -S strmov.o | grep movabs
0: 48 b8 74 68 69 73 20 movabs $0x2073692073696874,%rax
11: 48 b8 61 20 6c 69 74 movabs $0x61726574696c2061,%rax
1f: 48 b8 6c 20 2f 67 6e movabs $0x732f756e672f206c,%rax
2d: 48 b8 74 6f 72 65 20 movabs $0x7274732065726f74,%rax
--8<---------------cut here---------------end--------------->8---
On GCC 7.3.0, it works as intended:
--8<---------------cut here---------------start------------->8---
$ guix environment --no-grafts --pure --ad-hoc -C ltrace gcc-toolchain@7 -- ltrace -f -e getenv gcc -O2 -c strmov.c
[pid 2] gcc->getenv("COLUMNS") = nil
[pid 2] gcc->getenv("TERM") = nil
[pid 2] gcc->getenv("GCC_EXEC_PREFIX") = nil
[pid 2] gcc->getenv("PATH") = "/gnu/store/zahi3qjfnfq5z0bsxkggq"...
[pid 2] gcc->getenv("PATH") = "/gnu/store/zahi3qjfnfq5z0bsxkggq"...
[pid 2] gcc->getenv("COMPILER_PATH") = nil
[pid 2] gcc->getenv("LIBRARY_PATH") = "/gnu/store/zahi3qjfnfq5z0bsxkggq"...
[pid 2] gcc->getenv("LPATH") = nil
[pid 2] gcc->getenv("GCC_COMPARE_DEBUG") = nil
[pid 2] gcc->getenv("GCC_ROOT") = nil
[pid 2] gcc->getenv("BINUTILS_ROOT") = nil
[pid 2] gcc->getenv("TMPDIR") = "/tmp"
[pid 2] gcc->getenv("TMP") = "/tmp"
[pid 2] gcc->getenv("TEMP") = "/tmp"
[pid 3] --- Called exec() ---
[pid 3] gcc->getenv("COLUMNS") = nil
[pid 3] gcc->getenv("TERM") = nil
[pid 3] gcc->getenv("DEPENDENCIES_OUTPUT") = nil
[pid 3] gcc->getenv("SUNPRO_DEPENDENCIES") = nil
[pid 3] gcc->getenv("CPATH") = nil
[pid 3] gcc->getenv("C_INCLUDE_PATH") = "/gnu/store/zahi3qjfnfq5z0bsxkggq"...
[pid 3] gcc->getenv("GCC_EXEC_PREFIX") = nil
[pid 3] gcc->getenv("PWD") = nil
[pid 3] gcc->getenv("NIX_STORE") = nil
[pid 3] +++ exited (status 0) +++
[pid 2] --- SIGCHLD (Child exited) ---
[pid 4] --- Called exec() ---
[pid 4] +++ exited (status 0) +++
[pid 2] --- SIGCHLD (Child exited) ---
[pid 2] +++ exited (status 0) +++
$ objdump -S strmov.o | grep movabs
$ guix environment --no-grafts --pure --ad-hoc -C ltrace gcc-toolchain@6 -- /bin/sh -c 'export NIX_STORE=/foo ; ltrace -f -e getenv gcc -O2 -c strmov.c '
[pid 3] gcc->getenv("COLUMNS") = nil
[pid 3] gcc->getenv("TERM") = nil
[pid 3] gcc->getenv("GCC_EXEC_PREFIX") = nil
[pid 3] gcc->getenv("PATH") = "/gnu/store/5141337yvhhjj5fhdx660"...
[pid 3] gcc->getenv("PATH") = "/gnu/store/5141337yvhhjj5fhdx660"...
[pid 3] gcc->getenv("COMPILER_PATH") = nil
[pid 3] gcc->getenv("LIBRARY_PATH") = "/gnu/store/5141337yvhhjj5fhdx660"...
[pid 3] gcc->getenv("LPATH") = nil
[pid 3] gcc->getenv("GCC_COMPARE_DEBUG") = nil
[pid 3] gcc->getenv("GCC_ROOT") = nil
[pid 3] gcc->getenv("BINUTILS_ROOT") = nil
[pid 3] gcc->getenv("TMPDIR") = "/tmp"
[pid 3] gcc->getenv("TMP") = "/tmp"
[pid 3] gcc->getenv("TEMP") = "/tmp"
[pid 4] --- Called exec() ---
[pid 4] gcc->getenv("COLUMNS") = nil
[pid 4] gcc->getenv("TERM") = nil
[pid 4] gcc->getenv("DEPENDENCIES_OUTPUT") = nil
[pid 4] gcc->getenv("SUNPRO_DEPENDENCIES") = nil
[pid 4] gcc->getenv("CPATH") = nil
[pid 4] gcc->getenv("C_INCLUDE_PATH") = "/gnu/store/5141337yvhhjj5fhdx660"...
[pid 4] gcc->getenv("GCC_EXEC_PREFIX") = nil
[pid 4] gcc->getenv("PWD") = "/home/ludo/src/guix"
[pid 4] gcc->getenv("NIX_STORE") = "/foo"
[pid 4] gcc->getenv("NIX_STORE") = "/foo"
[pid 4] +++ exited (status 0) +++
[pid 3] --- SIGCHLD (Child exited) ---
[pid 5] --- Called exec() ---
[pid 5] +++ exited (status 0) +++
[pid 3] --- SIGCHLD (Child exited) ---
[pid 3] +++ exited (status 0) +++
$ objdump -S strmov.o | grep movabs
0: 48 b8 74 68 69 73 20 movabs $0x2073692073696874,%rax
11: 48 b8 61 20 6c 69 74 movabs $0x61726574696c2061,%rax
1f: 48 b8 6c 20 2f 67 6e movabs $0x732f756e672f206c,%rax
2d: 48 b8 74 6f 72 65 20 movabs $0x7274732065726f74,%rax
--8<---------------cut here---------------end--------------->8---
The second issue is that the patch only ever worked with literal
strings. It does not “see” strings in constant arrays like the ‘str’
array in the example above.
The gconv-module file name mentioned in the first message in this bug
report is an example of a string assigned to a static array, in
iconv/gconv_conf.c:
/* This is the default path where we look for module lists. */
static const char default_gconv_path[] = GCONV_PATH;
Ludo’.
next prev parent reply other threads:[~2018-03-14 17:25 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-14 15:47 bug#30820: Chunked store references in compiled code break grafting (again) Ludovic Courtès
2018-03-14 17:24 ` Ludovic Courtès [this message]
2018-03-16 8:54 ` bug#30395: " Ludovic Courtès
2018-03-20 23:07 ` Ludovic Courtès
2018-03-21 6:39 ` Ricardo Wurmus
2018-03-21 20:59 ` Ludovic Courtès
2018-03-19 21:22 ` Danny Milosavljevic
2018-03-19 22:29 ` Ludovic Courtès
2018-03-19 19:05 ` Mark H Weaver
2018-03-19 19:16 ` Mark H Weaver
2018-03-19 21:34 ` Danny Milosavljevic
2018-03-19 22:27 ` Ludovic Courtès
2018-03-20 1:04 ` Mark H Weaver
2018-03-20 8:50 ` Ludovic Courtès
2018-03-19 22:34 ` Ludovic Courtès
2018-03-20 0:52 ` Mark H Weaver
2018-03-20 8:56 ` Ludovic Courtès
2018-03-21 4:17 ` Mark H Weaver
2018-03-21 5:43 ` Mark H Weaver
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87efkm7eov.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=30820@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).