[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

gcc, g++ problem temporary workaround



Ok, I got annoyed with having to manually edit lots of files in
programs that I compile to change -O2 to -O for correct code
generation, so I made the following quick 'n' dirty hack.  Compile it,
and then do something like this:

cd /usr/bin
mv gcc gcc.real
mv g++ g++.real
cp ~/stub gcc
cp ~/stub g++
ls -l gcc* g++*     # to see if everything is OK

*** do not use ln or ln -s here ***

Once a new gcc or g++ comes out, the stub is automatically
overwritten.  If a new version has problems too, you'll want to redo
the above steps.

#include <unistd.h>
#include <string.h>

#define REPLACEMENT "-O"

void main(int argc, char *argv[]) {
  char newpath[5000];
  int counter;
  
  strcpy(newpath, argv[0]);
  strcat(newpath, ".real");
  
  for (counter = 1; counter < argc; counter++) {
    if (strncmp(argv[counter], "-O", 2) == 0) {
      printf("    stub: arg %d: %s -> %s\n", counter, argv[counter], REPLACEMENT);
      strcpy(argv[counter], REPLACEMENT);
    }
  }
  
  execvp(newpath, argv);
}


-- 
John Goerzen   Linux, Unix consulting & programming   jgoerzen@complete.org |
Developer, Debian GNU/Linux (Free powerful OS upgrade)       www.debian.org |
----------------------------------------------------------------------------+
Visit the Air Capital Linux Users Group on the web at http://www.aclug.org


Reply to: