Message ID | 3003b5b7-1307-9d12-870b-213111d8ee3a@ramsayjones.plus.com (mailing list archive) |
---|---|
State | Mainlined, archived |
Headers | show |
Series | misc sparse patches | expand |
diff --git a/sparsec b/sparsec index 6c60990..bafe2da 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
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> --- sparsec | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)