gcc-spec-env.patch 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. Add support for external spec file via the GCC_SPECS env var. This
  2. allows us to easily control pie/ssp defaults with gcc-config profiles.
  3. Original patch by Rob Holland
  4. Extended to support multiple entries separated by ':' by Kevin F. Quinn
  5. Modified to use getenv instead of poisoned GET_ENVIRONMENT by Ryan Hill
  6. --- gcc-4/gcc/gcc.c
  7. +++ gcc-4/gcc/gcc.c
  8. @@ -6482,6 +6482,32 @@
  9. /* Process any user specified specs in the order given on the command
  10. line. */
  11. +#if !(defined (__MSDOS__) || defined (OS2) || defined (VMS) || defined (WIN32))
  12. + /* Add specs listed in GCC_SPECS. Note; in the process of separating
  13. + * each spec listed, the string is overwritten at token boundaries
  14. + * (':') with '\0', an effect of strtok_r().
  15. + */
  16. + specs_file = getenv ("GCC_SPECS");
  17. + if (specs_file && (strlen(specs_file) > 0))
  18. + {
  19. + char *spec, *saveptr;
  20. + for (spec=strtok_r(specs_file,":",&saveptr);
  21. + spec!=NULL;
  22. + spec=strtok_r(NULL,":",&saveptr))
  23. + {
  24. + struct user_specs *user = (struct user_specs *)
  25. + xmalloc (sizeof (struct user_specs));
  26. +
  27. + user->next = (struct user_specs *) 0;
  28. + user->filename = spec;
  29. + if (user_specs_tail)
  30. + user_specs_tail->next = user;
  31. + else
  32. + user_specs_head = user;
  33. + user_specs_tail = user;
  34. + }
  35. + }
  36. +#endif
  37. for (uptr = user_specs_head; uptr; uptr = uptr->next)
  38. {
  39. char *filename = find_a_file (&startfile_prefixes, uptr->filename,