From patchwork Wed Dec 21 17:13:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Torvalds X-Patchwork-Id: 9483545 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 01BAC601B3 for ; Wed, 21 Dec 2016 17:13:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E6AD827C0B for ; Wed, 21 Dec 2016 17:13:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB73B2841B; Wed, 21 Dec 2016 17:13:22 +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=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID,T_TVD_MIME_EPI 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 72E7C2847A for ; Wed, 21 Dec 2016 17:13:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757758AbcLURNL (ORCPT ); Wed, 21 Dec 2016 12:13:11 -0500 Received: from mail-io0-f196.google.com ([209.85.223.196]:36268 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757659AbcLURNJ (ORCPT ); Wed, 21 Dec 2016 12:13:09 -0500 Received: by mail-io0-f196.google.com with SMTP id b194so26327314ioa.3 for ; Wed, 21 Dec 2016 09:13:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=bOu0s+2nUqicfsZCTjmJcyoPAXZyN2KFq6jrNEbpWjs=; b=LVsMwUnX1/u41LeW0Xz4rX4spS3jVovoOi1HJaccAnURGTIdqtigbhiWiwR6Jdd6HT X3Zcyr65SzjR8jDzySiIgc8u+UEtKypJRR+ZX4LUnG9nqj5lrZZXowDKBzCcNhjHEwTN TuoYI2CFrQfTFjCPdQPpzATd8UKan3h6tJ8QRIEfniwQjdUBKdLZC+DOUQx3GUWjg/gQ vT+TEVIET48JVlSmBuV3YdMSE7b3KfAYBqfYfXjbqCmIylaaIHO7VjwlAo1O+5J3DDQd +PEHlVGYUqP4DoKrbK+eGUC0ZOe2z+63NfJsISW2udSCuGXCLKhIOfcOe3qbyKlCXjEP 3PIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=bOu0s+2nUqicfsZCTjmJcyoPAXZyN2KFq6jrNEbpWjs=; b=GT4u8AlDCeg3zst6O2HYXlhGDfMvItvNHDY9HINHu+wW574+ST8aNkv2PzpBLWJuMX IqzRpbhhZm4/Mv0yYb1LO/eQRyQuN6XJwVRaqcy3jNc/wqaQJovoGjviRqd/5lmKp+wS qxPGLzoTEESJOJHEebDgXey93FU4xxtPpl+TU+SkEdBcXwDcpa+xffUHWw/55Z8VmlIN BaTWw2b6oH9ADkHc2vRENeK39L9yn2XyoDgtQjM7oPopFSOjeTFcH1bOTLCUJ18sztnP B7Ucuk+b+yS9noG3VSFRScvU5Sa0YU2BD1zpmybV1ZDAMciHBCWn4Uvuy3X/b8QmGW1U fZlA== X-Gm-Message-State: AIkVDXKBbBEPxFc+x/RNh3vdxILZ985S4Jpc9sJ+VBUW9SbqSp6M+fYGKofLsDvSpmLhU+xLJtLKjfrj06mYXg== X-Received: by 10.107.188.197 with SMTP id m188mr5982502iof.50.1482340388490; Wed, 21 Dec 2016 09:13:08 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.146.65 with HTTP; Wed, 21 Dec 2016 09:13:07 -0800 (PST) In-Reply-To: <13736b0d-b29a-0118-6846-f08bb3bb76f4@redhat.com> References: <13736b0d-b29a-0118-6846-f08bb3bb76f4@redhat.com> From: Linus Torvalds Date: Wed, 21 Dec 2016 09:13:07 -0800 X-Google-Sender-Auth: nb-4KkcvwykglfIBi8Qh3buA3Fg Message-ID: Subject: Re: cgcc and -Dx86_64 To: Joe Lawrence Cc: Sparse Mailing-list 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 Wed, Dec 21, 2016 at 8:07 AM, Joe Lawrence wrote: > > I was trying to run sparse against the upstream kpatch project and ran > into problems with an include file that defined an "x86_64" variable: Yeah,. that's bogus. It should be removed. It goes back to the original x86-64 specific cgcc patch from 2007 (commit 0fcbcbf: "Implement x86-64 support in cgcc"). It may be that old versions of gcc did the same, who knows. They definitely don't any more, I checked: $ gcc -dM -E - < /dev/null | grep -v 'define __' #define _STDC_PREDEF_H 1 #define unix 1 #define linux 1 #define _LP64 1 and so gcc itself definitely doesn't do the x86_64 thing (it does pre-define versions with double underscores before and after): $ gcc -dM -E - < /dev/null | grep x86 #define __x86_64 1 #define __x86_64__ 1 > I can avoid this by renaming the structure member to something like > "foo_x86_64". I believe the problem stems from cgcc passing "-Dx86_64" > to gcc... sparse later gets confused as there is now a preprocessor > variable defined with the same name. You shouldn't need that. > We could s/x86_64/something_else/g across the whole project to avoid > this glitch, but was wondering if there was a better way. The fix it so just remove x86_64 from cgcc. It already does define the underscored versions. Same for the other architectures, for that matter. Obvios trivial (and totally untested) patch attached. Linus cgcc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cgcc b/cgcc index d7b1c99..c29fa58 100755 --- a/cgcc +++ b/cgcc @@ -250,25 +250,25 @@ sub add_specs { " -D'__fastcall=__attribute__((__fastcall__))'" . " -D'__declspec(x)=__attribute__((x))'"; } elsif ($spec eq 'i86') { - return (' -Di386=1 -D__i386=1 -D__i386__=1' . + return (' -D__i386=1 -D__i386__=1' . &integer_types (8, 16, 32, $m64 ? 64 : 32, 64) . &float_types (1, 1, 21, [24,8], [53,11], [64,15]) . &define_size_t ($m64 ? "long unsigned int" : "unsigned int") . ' -D__SIZEOF_POINTER__=' . ($m64 ? '8' : '4')); } elsif ($spec eq 'sparc') { - return (' -Dsparc=1 -D__sparc=1 -D__sparc__=1' . + return (' -D__sparc=1 -D__sparc__=1' . &integer_types (8, 16, 32, $m64 ? 64 : 32, 64) . &float_types (1, 1, 33, [24,8], [53,11], [113,15]) . &define_size_t ($m64 ? "long unsigned int" : "unsigned int") . ' -D__SIZEOF_POINTER__=' . ($m64 ? '8' : '4')); } elsif ($spec eq 'sparc64') { - return (' -Dsparc=1 -D__sparc=1 -D__sparc__=1 -D__sparcv9__=1 -D__sparc64__=1 -D__arch64__=1 -D__LP64__=1' . + return (' -D__sparc=1 -D__sparc__=1 -D__sparcv9__=1 -D__sparc64__=1 -D__arch64__=1 -D__LP64__=1' . &integer_types (8, 16, 32, 64, 64, 128) . &float_types (1, 1, 33, [24,8], [53,11], [113,15]) . &define_size_t ("long unsigned int") . ' -D__SIZEOF_POINTER__=8'); } elsif ($spec eq 'x86_64') { - return (' -Dx86_64=1 -D__x86_64=1 -D__x86_64__=1' . ($m32 ? '' : ' -D__LP64__=1') . + return (' -D__x86_64=1 -D__x86_64__=1' . ($m32 ? '' : ' -D__LP64__=1') . &integer_types (8, 16, 32, $m32 ? 32 : 64, 64, 128) . &float_types (1, 1, 33, [24,8], [53,11], [113,15]) . &define_size_t ($m32 ? "unsigned int" : "long unsigned int") .