From patchwork Mon Nov 19 20:46:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramsay Jones X-Patchwork-Id: 10689415 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0939513AD for ; Mon, 19 Nov 2018 20:46:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED03929CAE for ; Mon, 19 Nov 2018 20:46:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DE3D92A1A4; Mon, 19 Nov 2018 20:46:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A7D329CAE for ; Mon, 19 Nov 2018 20:46:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730796AbeKTHLn (ORCPT ); Tue, 20 Nov 2018 02:11:43 -0500 Received: from avasout04.plus.net ([212.159.14.19]:52262 "EHLO avasout04.plus.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730795AbeKTHLn (ORCPT ); Tue, 20 Nov 2018 02:11:43 -0500 Received: from [10.0.2.15] ([146.198.133.33]) by smtp with ESMTPA id OqR0g9p9bYyh2OqR1gYlqs; Mon, 19 Nov 2018 20:46:20 +0000 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.3 cv=MoN8FVSe c=1 sm=1 tr=0 a=VCDsReDbrwk4B7AcQzWGLw==:117 a=VCDsReDbrwk4B7AcQzWGLw==:17 a=IkcTkHD0fZMA:10 a=oLey91sEAAAA:8 a=EBOSESyhAAAA:8 a=ZZy4cI5PI3BVP3g4BsgA:9 a=QEXdDO2ut3YA:10 a=D44SYiUWUjHgSrmoHUtb:22 a=yJM6EZoI5SlJf8ks9Ge_:22 X-AUTH: ramsayjones@:2500 To: Luc Van Oostenryck Cc: Sparse Mailing-list From: Ramsay Jones Subject: [PATCH 1/9] sparsec: use a compatible exception model on cygwin Message-ID: <3003b5b7-1307-9d12-870b-213111d8ee3a@ramsayjones.plus.com> Date: Mon, 19 Nov 2018 20:46:17 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 Content-Language: en-GB X-CMAE-Envelope: MS4wfKTTl3kx4hfmXPmfUDDTb9Smc18ZUo1/1uTrV+m4H/xbFKYkuw6tFSAWw+8r2CoKAcbfYLDJEEIu4LIcyU/DA96syS0cXyp3LlRcnyQ8WD2NEqCiZFaw kEW4jIqESOaqNo/HzFcrxgny5lCWVvfbYmSyEz63wG/W/6x0G2yi7VwKdbBheZ7OzHuTFphEdy5AvQ== Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- sparsec | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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