summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorRamsay Jones <ramsay@ramsayjones.plus.com>2018-11-19 20:46:17 +0000
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-11-22 14:49:03 +0100
commit885d147cd27dd5e05cfbb8217414993e654a5b5a (patch)
tree05a67ddeb92b417698cc0432dde4414abe7227ac
parent0eb8175d3e9c0d20354763d07ce3d4c0e543d988 (diff)
downloadsparse-885d147cd27dd5e05cfbb8217414993e654a5b5a.tar.gz
sparsec: use a compatible exception model on cygwin
On the cygwin platform, some of the backend tests fail due to the 'llc' tool using win32 'structured exception' assembler directives, which the platform assembler 'as' does not accept: $ make check ... TEST 'hello, world' code generation (backend/hello.c) error: actual error text does not match expected error text. error: see backend/hello.c.error.* for further investigation. --- backend/hello.c.error.expected 2018-06-03 17:14:30.550972400 +0100 +++ backend/hello.c.error.got 2018-06-03 17:14:30.478731900 +0100 @@ -0,0 +1,6 @@ +{standard input}: Assembler messages: +{standard input}:14: Error: invalid register for .seh_pushreg +{standard input}:14: Error: junk at end of line, first unrecognized character is `5' +{standard input}:20: Error: invalid register for .seh_setframe +{standard input}:20: Error: missing separator +mv: cannot stat '/tmp/tmp.oTA6mS.o': No such file or directory ... Out of 288 tests, 275 passed, 13 failed (10 of them are known to fail) make: *** [Makefile:236: check] Error 1 $ The exception model used by 'llc' can be changed from the command line to be one of 'default', 'dwarf', 'sjlj', 'arm' or 'wineh'. In this case the default is 'wineh' (windows exception handling). The 'sjlj' model is the older (setjmp,longjmp) stack-based model, which is no longer used on Linux. The newer 'dwarf' model uses a 'zero cost' table based method. (The 'arm' model is not relevant here). For more information, see [1]. After some experiments, using small test programs compiled with gcc and g++, comparing the output of tools like 'nm' and 'objdump', it seems that cygwin binutils are employing the 'sjlj' model. (Using the 'dwarf' model on 'llc' also works on simple programs). In order to fix the test failures, add an '-exception-model=sjlj' option to the 'llc' invocation when executing sparsec on the cygwin platform. [1] http://www.hexblog.com/wp-content/uploads/2012/06/Recon-2012-Skochinsky-Compiler-Internals.pdf Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rwxr-xr-xsparsec12
1 files changed, 11 insertions, 1 deletions
diff --git a/sparsec b/sparsec
index 6c609901..bafe2da5 100755
--- a/sparsec
+++ b/sparsec
@@ -34,7 +34,17 @@ TMPFILE=`mktemp -t tmp.XXXXXX`
LLC=`"${LLVM_CONFIG:-llvm-config}" --bindir`/llc
-$DIRNAME/sparse-llvm $SPARSEOPTS | $LLC | as -o $TMPFILE
+LLC_ARCH_OPTS=
+case "$(uname -s)" in
+*CYGWIN*)
+ # cygwin uses the sjlj (setjmp-longjmp) exception model
+ LLC_ARCH_OPTS="-exception-model=sjlj"
+ ;;
+*)
+ ;;
+esac
+
+$DIRNAME/sparse-llvm $SPARSEOPTS | $LLC ${LLC_ARCH_OPTS} | as -o $TMPFILE
if [ $NEED_LINK -eq 1 ]; then
if [ -z $OUTFILE ]; then