reproductible builds: remove most install paths in c code
In order to speed up test bot work it would be helpful to check for identical build outputs and skip tests if required. This removes most use of the install path in c code: - ql_mpi uses /proc/self/exe and looks for talker/server in same directory as itself - mcexec looks for libihk.so in /proc/self/maps and use that path for LD_PRELOAD prefix path - rootfsdir is not used right now but until a better fix happens just hardcode it, someone who wants to change it can set it through cmake There is one last occurence of the install directory, MCEXEC_PATH in mcctrl's binfmt code, for which the build system will just overwrite it to a constant string at build time instead of trying to remove it too hard. It would be possible to pass it as a kernel parameter or look for mcexec in PATH but this is too much work for now. Change-Id: I5d1352bc5748a1ea10dcae4be630f30a07609296
This commit is contained in:
committed by
Masamichi Takagi
parent
a48a2cd3e8
commit
b87ac8b8c0
@@ -1975,7 +1975,7 @@ opendev()
|
||||
}
|
||||
|
||||
#define LD_PRELOAD_PREPARE(name) do { \
|
||||
sprintf(elembuf, "%s%s/" name, nelem > 0 ? ":" : "", MCKERNEL_LIBDIR); \
|
||||
sprintf(elembuf, "%s%s/" name, nelem > 0 ? ":" : "", libdir); \
|
||||
} while (0)
|
||||
|
||||
#define LD_PRELOAD_APPEND do { \
|
||||
@@ -1988,6 +1988,57 @@ opendev()
|
||||
nelem++; \
|
||||
} while (0)
|
||||
|
||||
static ssize_t find_libdir(char *libdir, size_t len)
|
||||
{
|
||||
FILE *filep;
|
||||
ssize_t rc;
|
||||
size_t linelen = 0;
|
||||
char *line = NULL;
|
||||
char *ihklib, *slash;
|
||||
|
||||
filep = fopen("/proc/self/maps", "r");
|
||||
if (!filep) {
|
||||
rc = -errno;
|
||||
fprintf(stderr, "could not open /proc/self/maps: %d\n", -rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
while ((rc = getline(&line, &linelen, filep)) > 0) {
|
||||
ihklib = strstr(line, "libihk.so");
|
||||
if (ihklib)
|
||||
break;
|
||||
}
|
||||
if (!ihklib) {
|
||||
fprintf(stderr, "mcexec does not have libihk.so loaded?\n");
|
||||
rc = -ENOENT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
slash = strchr(line, '/');
|
||||
if (!slash) {
|
||||
rc = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* leave / iff root of filesystem */
|
||||
if (slash + 1 != ihklib)
|
||||
ihklib--;
|
||||
|
||||
*ihklib = 0;
|
||||
|
||||
rc = snprintf(libdir, len, "%s", slash);
|
||||
|
||||
if (rc > len) {
|
||||
rc = -ERANGE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
out:
|
||||
fclose(filep);
|
||||
free(line);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void ld_preload_init()
|
||||
{
|
||||
char envbuf[PATH_MAX];
|
||||
@@ -1995,6 +2046,12 @@ static void ld_preload_init()
|
||||
size_t remainder = PATH_MAX;
|
||||
int nelem = 0;
|
||||
char elembuf[PATH_MAX];
|
||||
char libdir[PATH_MAX];
|
||||
|
||||
if (find_libdir(libdir, sizeof(libdir)) < 0) {
|
||||
fprintf(stderr, "warning: did not set LD_PRELOAD\n");
|
||||
return;
|
||||
}
|
||||
|
||||
memset(envbuf, 0, PATH_MAX);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user