Module Name: src
Committed By: christos
Date: Sat Nov 14 21:24:03 UTC 2020
Modified Files:
src/external/gpl3/gcc/dist/gcc: file-prefix-map.c
Log Message:
PR/55802: Andreas Gustafsson: Unbreak reproducible builds.
For reproducible builds to work we need to have a consistent command
line (because the command line gets recorded in dwarf). So we can't
do:
-ffile-prefix-map=/joe/random/src=/usr/src
because then /joe/random/src gets recorded. We do instead:
-ffile-prefix-map=\$NETBSDSRCDIR=/usr/src
The patch restores the environment variable parsing that got lost
in the last 2 gcc upgrades.
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/gpl3/gcc/dist/gcc/file-prefix-map.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/gpl3/gcc/dist/gcc/file-prefix-map.c
diff -u src/external/gpl3/gcc/dist/gcc/file-prefix-map.c:1.4 src/external/gpl3/gcc/dist/gcc/file-prefix-map.c:1.5
--- src/external/gpl3/gcc/dist/gcc/file-prefix-map.c:1.4 Sat Sep 5 05:12:23 2020
+++ src/external/gpl3/gcc/dist/gcc/file-prefix-map.c Sat Nov 14 16:24:03 2020
@@ -40,7 +40,8 @@ static void
add_prefix_map (file_prefix_map *&maps, const char *arg, const char *opt)
{
file_prefix_map *map;
- const char *p;
+ const char *p, *old;
+ size_t oldlen;
/* Note: looking for the last '='. The thinking is we can control the paths
inside our projects but not where the users build them. */
@@ -50,9 +51,28 @@ add_prefix_map (file_prefix_map *&maps,
error ("invalid argument %qs to %qs", arg, opt);
return;
}
+ if (*arg == '$')
+ {
+ char *env = xstrndup (arg + 1, p - (arg + 1));
+ old = getenv(env);
+ if (!old)
+ {
+ warning (0, "environment variable %qs not set in argument to "
+ "%s", env, opt);
+ free(env);
+ return;
+ }
+ oldlen = strlen(old);
+ free(env);
+ }
+ else
+ {
+ old = xstrndup (arg, p - arg);
+ oldlen = p - arg;
+ }
map = XNEW (file_prefix_map);
- map->old_prefix = xstrndup (arg, p - arg);
- map->old_len = p - arg;
+ map->old_prefix = old;
+ map->old_len = oldlen;
p++;
map->new_prefix = xstrdup (p);
map->new_len = strlen (p);