Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
62504af416c2e01ab685dbf2dc8f6cf7cc5c7207
[simgrid.git] / tools / stack-cleaner / compiler-wrapper
1 #!/usr/bin/env perl
2 # Compiler wrapper with stack-cleaner support (enabled by default).
3 # Usage: ./compiler-wrapper target-compiler args [-f[no-]stack-cleaner]
4
5 use warnings;
6
7 use File::Basename;
8
9 my $compiler = shift(@ARGV);
10
11 my $enable = 1;
12
13 my @args;
14 my $arg;
15 while($arg=shift(@ARGV)) {
16   if ($arg eq "-fno-stack-cleaner") {
17     $enable = 0;    
18   } elsif ($arg eq "-fstack-cleaner") {
19     $enable = 1;
20   }
21   else {
22     push @args, $arg;
23   }
24 }
25
26 if ($enable) {
27   if (basename($0) =~ /^clang/) {
28     unshift @args, "-no-integrated-as"
29   }
30   unshift @args, dirname($0);
31   unshift @args, "-B";
32 }
33
34 exec $compiler, @args