Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Disable/enable the stack-cleaner from a CLI argument (-f[no-]stack-cleaner)
authorGabriel Corona <gabriel.corona@loria.fr>
Mon, 24 Nov 2014 14:33:47 +0000 (15:33 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Mon, 24 Nov 2014 14:33:52 +0000 (15:33 +0100)
tools/stack-cleaner/c++
tools/stack-cleaner/cc
tools/stack-cleaner/compiler-wrapper [new file with mode: 0755]
tools/stack-cleaner/fortran

index 516d36c..51082b0 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
 path="$(dirname $0)"
-exec "${FILTER_CXX:-c++}" -B "$path" "$@"
+exec "$path"/compiler-wrapper c++ "$@"
index 3cfd378..d6da0f2 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
 path="$(dirname $0)"
-exec "${FILTER_CC:-cc}" -B "$path" "$@"
+exec "$path"/compiler-wrapper cc "$@"
diff --git a/tools/stack-cleaner/compiler-wrapper b/tools/stack-cleaner/compiler-wrapper
new file mode 100755 (executable)
index 0000000..8b8a62f
--- /dev/null
@@ -0,0 +1,32 @@
+#!/usr/bin/perl -w
+# Compiler wrapper with stack-cleaner support (enabled by default).
+# Usage: ./compiler-wrapper target-compiler args [-f[no-]stack-cleaner]
+
+use File::Basename;
+
+my $compiler = shift(@ARGV);
+
+my $enable = 1;
+
+my @args;
+my $arg;
+while($arg=shift(@ARGV)) {
+  if ($arg eq "-fno-stack-cleaner") {
+    $enable = 0;    
+  } elsif ($arg eq "-fstack-cleaner") {
+    $enable = 1;
+  }
+  else {
+    push @args, $arg;
+  }
+}
+
+if ($enable) {
+  if (basename($0) =~ /^clang/) {
+    unshift @args, "-no-integrated-as"
+  }
+  unshift @args, dirname($0);
+  unshift @args, "-B";
+}
+
+exec $compiler, @args
index c435b4a..62087fd 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
 path="$(dirname $0)"
-exec "${FILTER_CC:-gfortran}" -B "$path" "$@"
+exec "$path"/compiler-wrapper gfortran "$@"