Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 84033 Details for
Bug 128810
Moving handling of ccache, distcc and GCC_SPECS into the gcc wrapper.
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch against 1.4.7c of gcc-config's wrapper
wrapper.diff (text/plain), 5.89 KB, created by
Kevin F. Quinn (RETIRED)
on 2006-04-05 15:27:49 UTC
(
hide
)
Description:
Patch against 1.4.7c of gcc-config's wrapper
Filename:
MIME Type:
Creator:
Kevin F. Quinn (RETIRED)
Created:
2006-04-05 15:27:49 UTC
Size:
5.89 KB
patch
obsolete
>--- wrapper-1.4.7.c 2006-04-04 15:51:39.000000000 +0200 >+++ wrapper.c 2006-04-06 00:06:52.000000000 +0200 >@@ -24,6 +24,13 @@ > #define GCC_CONFIG "/usr/bin/gcc-config" > #define ENVD_BASE "/etc/env.d/05gcc" > >+#ifndef FALSE >+#define FALSE 0 >+#endif >+#ifndef TRUE >+#define TRUE 1 >+#endif >+ > struct wrapper_data { > char name[MAXPATHLEN + 1]; > char fullname[MAXPATHLEN + 1]; >@@ -300,12 +307,155 @@ > return retargv; > } > >+ >+/** Prepend SPECS to the argv list */ >+static char **buildNewArgvSpecs(char **argv, const char *newSpecsStr) { >+#define MAX_NEWSPECS 32 >+ char *newSpecs[MAX_NEWSPECS]; >+ char **retargv; >+ unsigned int argc; >+ size_t nspecs; >+ char *state, *flagsTokenized; >+ char *spec; >+ >+ for (argc = 0; argv[argc]; ++argc); >+ >+ /* Tokenize the flag list and put it into newflags array */ >+ flagsTokenized = strdup(newSpecsStr); >+ if (flagsTokenized == NULL) >+ return argv; >+ nspecs = 0; >+ for (spec = strtok_r(flagsTokenized, ":", &state); >+ spec != NULL & nspecs < MAX_NEWSPECS; >+ spec = strtok_r(NULL, ":", &state)) { >+ newSpecs[nspecs] = (char *)malloc((strlen(spec)+8) * sizeof(char)); >+ if (newSpecs[nspecs] == NULL) { >+ free(flagsTokenized); >+ return argv; >+ } >+ snprintf(newSpecs[nspecs], strlen(spec)+8, "-specs=%s", spec); >+ nspecs++; >+ } >+ >+ /* allocate memory for our spiffy new argv */ >+ retargv = (char**)calloc(argc + nspecs + 1, sizeof(char*)); >+ if (retargv == NULL) { >+ free(flagsTokenized); >+ return argv; >+ } >+ /* start building retargv */ >+ retargv[0] = argv[0]; >+ /* insert the ABI flags first so cmdline always overrides ABI flags */ >+ memcpy(retargv+1, newSpecs, nspecs * sizeof(char*)); >+ /* copy over the old argv */ >+ if (argc > 1) >+ memcpy(retargv+1+nspecs, argv+1, (argc-1) * sizeof(char*)); >+ >+ free(flagsTokenized); >+ >+ return retargv; >+} >+ >+/** Add path to the environment variable envVar */ >+static int addPathToEnv(char *envVar, char *path) { >+ char *envVal; >+ char *newEnvVal; >+ >+ envVal = getenv(envVar); >+ if (envVal == NULL) { >+ newEnvVal=strdup(path); >+ if (newEnvVal == NULL) >+ return FALSE; >+ } else { >+ newEnvVal = (char *)malloc((strlen(envVal)+1+strlen(path)+1)*sizeof(char)); >+ if (newEnvVal == NULL) >+ return FALSE; >+ snprintf(newEnvVal, strlen(envVal)+1+strlen(path)+1, "%s:%s", envVal,path); >+ } >+ setenv(envVar,newEnvVal,TRUE); >+ return TRUE; >+} >+ >+static char **prependArgv(char **argv, char *bin) { >+ int argc; >+ char **newArgv; >+ for (argc=0; argv[argc]; argc++); >+ newArgv = (char**)calloc(argc + 2, sizeof(char*)); >+ if (newArgv == NULL) >+ return argv; >+ newArgv[0]=bin; >+ memcpy(newArgv+1,argv,argc * sizeof(char *)); >+ return newArgv; >+} >+ >+/** Return TRUE iff word is in COMPILER_FEATURES and -word is not (last wins) */ >+static int inFeatures(char *word) { >+ char *features, *feature; >+ char *state, *featuresTokenised; >+ int on; >+ >+ features = getenv("COMPILER_FEATURES"); >+ if (features==NULL) >+ return FALSE; >+ featuresTokenised = strdup(features); >+ if (featuresTokenised == NULL) >+ return FALSE; >+ on = FALSE; >+ for (feature = strtok_r(featuresTokenised, " \t\n", &state); >+ feature != NULL; >+ feature = strtok_r(NULL, " \t\n", &state)) { >+ if (strcmp(feature,word)==0) { >+ on = TRUE; >+ } else if (word[0]=='-' && strcmp(feature,word+1)==0) { >+ on = FALSE; >+ } >+ } >+ return on; >+} >+ >+/** Return TRUE iff distcc is wanted */ >+static int distccRequired(void) { >+ return inFeatures("distcc"); >+} >+ >+/** Return TRUE iff distcc is wanted */ >+static int ccacheRequired(void) { >+ return inFeatures("ccache"); >+} >+ >+/** Set environment variable envVar to environment variable envDir >+ * suffixed with , provided envVar is empty or not defined. >+ * Returns TRUE if the envVar is already set, or if it is >+ * successfully set. */ >+static int appendEnv(char *envVar, char *envDir, char *suffix) { >+ char *envVarVal; >+ char *envDirVal; >+ envVarVal = getenv (envVar); >+ if (envVarVal == NULL || strlen(envVarVal)==0) { >+ if (envDir == NULL) { >+ setenv(envVar,suffix,TRUE); >+ } else { >+ envDirVal = getenv(envDir); >+ if (envDirVal == NULL) >+ return FALSE; >+ envVarVal = (char *)malloc((strlen(envDirVal)+strlen(suffix)+1)*sizeof(char)); >+ if (envVarVal == NULL) >+ return FALSE; >+ if (snprintf(envVarVal, strlen(envDirVal)+strlen(suffix)+1,"%s%s",envDirVal,suffix) < 0) >+ return FALSE; >+ setenv(envVar,envVarVal,TRUE); >+ } >+ } >+ return TRUE; >+} >+ > int main(int argc, char *argv[]) > { > struct wrapper_data *data; > size_t size; > int i; > char **newargv = argv; >+ char *gcc_specs; > > data = alloca(sizeof(*data)); > if (data == NULL) >@@ -369,8 +519,43 @@ > } > } > >- /* Ok, lets do it one more time ... */ >- if (execv(data->bin, newargv) < 0) >+ /* Convert env specs or config specs into arguments >+ * Env GCC_SPECS is honoured for native compiler only >+ */ >+ gcc_specs = getenv("GCC_SPECS"); >+ if (gcc_specs) { >+/* TODO: && not cross-compiler >+ * && strcmp(data->ctarget, data->selectionConf->defaultCtarget) == 0) { >+ */ >+ newargv = buildNewArgvSpecs(newargv, gcc_specs); >+ } >+ unsetenv("GCC_SPECS"); >+ >+ /* Prepend distcc, if enabled. >+ * Set DISTCC_DIR to PORTAGE_TMPDIR/.distcc if not already set >+ * Append DISTCC_DIR to SANDBOX_WRITE >+ * Shuffle argv and set argv[0] to /usr/bin/distcc >+ */ >+ if (distccRequired() && >+ appendEnv("DISTCC_DIR", "PORTAGE_TMPDIR", "/.distcc") && >+ addPathToEnv("SANDBOX_WRITE",getenv("DISTCC_DIR"))) { >+ newargv = prependArgv(newargv, "/usr/bin/distcc"); >+ } >+ >+ /* Prepend ccache, if enabled. >+ * Set CCACHE_DIR to /var/tmp/ccache if not already set >+ * Append CCACHE_DIR to SANDBOX_WRITE, SANDBOX_READ >+ * Shuffle argv and set argv[0] to /usr/bin/ccache >+ */ >+ if (ccacheRequired() && >+ appendEnv("CCACHE_DIR", NULL, "/var/tmp/ccache") && >+ addPathToEnv("SANDBOX_READ",getenv("CCACHE_DIR")) && >+ addPathToEnv("SANDBOX_WRITE",getenv("CCACHE_DIR"))) { >+ newargv = prependArgv(newargv, "/usr/bin/ccache"); >+ } >+ >+ /* Ok, lets exec it. */ >+ if (execv(newargv[0], newargv) < 0) > wrapper_exit("Could not run/locate \"%s\"\n", data->name); > > return 0;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 128810
:
83908
|
83909
|
84032
|
84033
|
86738