[PATCH 2/9] sparsei: add the --[no-]jit options

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

 



On the cygwin platform, a 'sparsei' backend test, which uses the llvm
'lli' tool, fails due to a dynamic linking error:

  $ make check
  ...
       TEST    sum from 1 to n (backend/sum.c)
  error: actual output text does not match expected output text.
  error: see backend/sum.c.output.* for further investigation.
  --- backend/sum.c.output.expected	2018-06-03 18:27:11.502760500 +0100
  +++ backend/sum.c.output.got	2018-06-03 18:27:11.307670000 +0100
  @@ -1,2 +0,0 @@
  -15
  -5050
  error: actual error text does not match expected error text.
  error: see backend/sum.c.error.* for further investigation.
  --- backend/sum.c.error.expected	2018-06-03 18:27:11.562997400 +0100
  +++ backend/sum.c.error.got	2018-06-03 18:27:11.481038800 +0100
  @@ -0,0 +1 @@
  +LLVM ERROR: Program used external function 'printf' which could not be resolved!
  error: Actual exit value does not match the expected one.
  error: expected 0, got 1.
  ...
  Out of 288 tests, 277 passed, 11 failed (10 of them are known to fail)
  make: *** [Makefile:236: check] Error 1
  $

Note the 'LLVM ERROR' about the 'printf' external function which could
not be resolved (linked).  On Linux, it seems that the 'lli' tool (JIT
compiler) can resolve the 'printf' symbol, with the help of the dynamic
linker, since the tool itself is linked to the (dynamic) C library.
On windows (hence also on cygwin), the 'lli' tool fails to resolve the
external symbol, since it is not exported from the '.exe'.

The 'lli' tool can be used as an interpreter, so that the JIT compiler
is disabled, which also side-steps this external symbol linking problem.
Add the --[no-]jit options to the 'sparsei' tool, which in turn uses
(or not) the '-force-interpreter' option to 'lli'. In order to fix the
failing test-case, simply pass the '--no-jit' option to 'sparsei'.

Signed-off-by: Ramsay Jones <ramsay@xxxxxxxxxxxxxxxxxxxx>
---
 sparsei                  | 20 +++++++++++++++++++-
 validation/backend/sum.c |  2 +-
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/sparsei b/sparsei
index 3431a9f..3232200 100755
--- a/sparsei
+++ b/sparsei
@@ -2,6 +2,9 @@
 
 set +e
 
+SPARSEOPTS=
+JIT_OPT=
+
 DIRNAME=`dirname $0`
 LLI=`"${LLVM_CONFIG:-llvm-config}" --bindir`/lli
 
@@ -10,4 +13,19 @@ if [ $# -eq 0 ]; then
   exit 1
 fi
 
-$DIRNAME/sparse-llvm $@ | $LLI
+while [ $# -gt 0 ]; do
+	case $1 in
+	--jit)
+		JIT_OPT=
+		;;
+	--no-jit)
+		JIT_OPT="-force-interpreter"
+		;;
+	*)
+		SPARSEOPTS="$SPARSEOPTS $1 "
+		;;
+	esac
+	shift
+done
+
+$DIRNAME/sparse-llvm ${SPARSEOPTS} | $LLI ${JIT_OPT}
diff --git a/validation/backend/sum.c b/validation/backend/sum.c
index 0604299..fa51120 100644
--- a/validation/backend/sum.c
+++ b/validation/backend/sum.c
@@ -19,7 +19,7 @@ int main(int argc, char **argv)
 
 /*
  * check-name: sum from 1 to n
- * check-command: sparsei $file
+ * check-command: sparsei --no-jit $file
  *
  * check-output-start
 15
-- 
2.19.0



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux