spec tests + PWD=

Hi David,

It looks like you added the PWD= magic to Makefile.spec. It is preventing me from running bugpoint on the desktop, with errors like this:

/Users/sabre/llvm/projects/llvm-test/External/SPEC/Sandbox.sh bugpoint-train Output/176.gcc.bugpoint-opt /Users/sabre/cvs/benchmarks/speccpu2000/benchspec/CINT2000/176.gcc/data/train/input/ \
      PWD=/Volumes/Data/Users/sabre/llvm/projects/llvm-test/External/SPEC/CINT2000/176.gcc /Users/sabre/llvm/Debug/bin/bugpoint -llc-safe ../176.gcc.noopt-llvm.bc -std-compile-opts \
      -append-exit-code -Xlinker=-lm -input=/dev/null -output=../176.gcc.out-nat -timeout=500 --tool-args -asm-verbose=false -O3 --args -- cp-decl.i -o - -quiet
Running: PWD=/Volumes/Data/Users/sabre/llvm/projects/llvm-test/External/SPEC/CINT2000/176.gcc /Users/sabre/llvm/Debug/bin/bugpoint -llc-safe ../176.gcc.noopt-llvm.bc -std-compile-opts -append-exit-code -Xlinker=-lm -input=/dev/null -output=../176.gcc.out-nat -timeout=500 --tool-args -asm-verbose=false -O3 --args -- cp-decl.i -o - -quiet
/Users/sabre/llvm/projects/llvm-test/External/SPEC/Sandbox.sh: line 36: /Volumes/Data/Users/sabre/llvm/projects/llvm-test/External/SPEC/CINT2000/176.gcc/Output/bugpoint-train/PWD=/Volumes/Data/Users/sabre/llvm/projects/llvm-test/External/SPEC/CINT2000/176.gcc: No such file or directory
/Users/sabre/llvm/projects/llvm-test/External/SPEC/Sandbox.sh: line 36: exec: /Volumes/Data/Users/sabre/llvm/projects/llvm-test/External/SPEC/CINT2000/176.gcc/Output/bugpoint-train/PWD=/Volumes/Data/Users/sabre/llvm/projects/llvm-test/External/SPEC/CINT2000/176.gcc: cannot execute: No such file or directory

I think this comes down to SPEC/Sandbox.sh turning around and exec'ing its arguments, which include the PWD= line. This is failing, but I'm not sure why (maybe it's because I'm using tcsh as my shell, not bash). Is there a way to fix this without reverting the patch?


I did make that change to support the following code in ToolRunner.cpp. I found that if I did not explicitly set PWD when invoking bugpoint, then it would not be in the environment. I'm not sure why PWD is not being inherited... perhaps some make weirdness... or bash??? and I don't know how it ever worked before my change.

     // Full path to the binary. We need to cd to the exec directory because
     // there is a dylib there that the exec expects to find in the CWD
     char* env_pwd = getenv("PWD");
     std::string Exec = "cd ";
     Exec += env_pwd;

Perhaps I shouldn't have added it to Makefile.spec? At the least it seems like it should probably move to the beginning of the command, like this:

  PWD=$(CURDIR) $(SPEC_SANDBOX) bugpoint-$(RUN_TYPE) $@ $(REF_IN_DIR) \
      $(LBUGPOINT) -llc-safe ../$*.noopt-llvm.bc -std-compile-opts $(OPTPASSES) \


I changed Makefile.spec to use 'env' at Shantonu's suggestion and it works for me. :slight_smile:

Thanks David,