Browse Source

Use the compiler wrapper on Amazon

refactor
Matt Godbolt 11 years ago
parent
commit
b1f70e0a8e
  1. 3
      Makefile
  2. 5
      app.js
  3. 1
      c-preload/.gitignore
  4. 2
      c-preload/compiler-wrapper
  5. BIN
      c-preload/libpreload.so
  6. 2
      c-preload/preload.c
  7. 1
      etc/config/gcc-explorer.amazon.properties

3
Makefile

@ -22,4 +22,5 @@ run: node_modules
./node_modules/.bin/supervisor ./app.js
run-amazon: node_modules
./node_modules/.bin/supervisor -- ./app.js --env amazon
$(MAKE) -C c-preload
./node_modules/.bin/supervisor -- ./app.js --env amazon

5
app.js

@ -96,6 +96,11 @@ function compile(req, res) {
}
var outputFilename = path.join(dirPath, 'output.S');
options = options.concat([ '-x', 'c++', '-o', outputFilename, '-S', '-']);
var compilerWrapper = props.get("gcc-explorer", "compiler-wrapper");
if (compilerWrapper) {
options = [compiler].concat(options);
compiler = compilerWrapper;
}
var child = child_process.spawn(
compiler,
options

1
c-preload/.gitignore vendored

@ -0,0 +1 @@
libpreload.so

2
c-preload/compiler-wrapper

@ -1,6 +1,6 @@
#/bin/sh
export LD_PRELOAD=$(pwd)/libpreload.so
export LD_PRELOAD=$(dirname $0)/libpreload.so
export ALLOWED_FOR_CREATE=/tmp
export ALLOWED_FOR_READ=/usr/local/include:/usr/include:/usr/lib

BIN
c-preload/libpreload.so

Binary file not shown.

2
c-preload/preload.c

@ -37,7 +37,7 @@ static int allowed_env(const char* pathname, const char* envvar) {
while (*okpath == ':') ++okpath;
}
fprintf(stderr, "Denying access to \"%s\"\n", pathname);
fprintf(stderr, "Access to \"%s\" denied by gcc-explorer policy\n", pathname);
errno = EACCES;
return 0;
}

1
etc/config/gcc-explorer.amazon.properties

@ -1,3 +1,4 @@
# Settings overridden for Amazon EC2 instances that power http://gcc.godbolt.org/
compileTimeoutMs=200
compilers=/usr/bin/g++-4.4:/usr/bin/g++-4.5:/usr/bin/g++-4.6:/usr/bin/g++-4.7:/usr/bin/arm-linux-gnueabi-g++-4.5:/usr/bin/clang++
compiler-wrapper=./c-preload/compiler-wrapper

Loading…
Cancel
Save