From patchwork Mon Oct 7 13:20:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Shigorin X-Patchwork-Id: 11177451 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2246D1599 for ; Mon, 7 Oct 2019 13:20:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0B62920867 for ; Mon, 7 Oct 2019 13:20:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727742AbfJGNUX (ORCPT ); Mon, 7 Oct 2019 09:20:23 -0400 Received: from vmicros1.altlinux.org ([194.107.17.57]:33236 "EHLO vmicros1.altlinux.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727324AbfJGNUX (ORCPT ); Mon, 7 Oct 2019 09:20:23 -0400 Received: from imap.altlinux.org (imap.altlinux.org [194.107.17.38]) by vmicros1.altlinux.org (Postfix) with ESMTP id 8BF0D72CC6C; Mon, 7 Oct 2019 16:20:20 +0300 (MSK) Received: by imap.altlinux.org (Postfix, from userid 705) id 7F24E4A4AE9; Mon, 7 Oct 2019 16:20:20 +0300 (MSK) Date: Mon, 7 Oct 2019 16:20:20 +0300 From: Michael Shigorin To: selinux@vger.kernel.org Cc: Daniel J Walsh , Nicolas Iooss Subject: [PATCH] non-gcc-specific exception.sh Message-ID: <20191007132020.GG4928@imap.altlinux.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Sender: selinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Hello, please find attached the patch to (hopefully) improve self-surgery script that uses gcc-specific -aux-info now. Should help clang, icc and the like (in my case there's no proper gcc port for the target platform just yet). From ccfa41adf46367e132ba7556fad53dfce9ddffaf Mon Sep 17 00:00:00 2001 From: Michael Shigorin Date: Mon, 7 Oct 2019 16:00:39 +0300 Subject: [PATCH] exception.sh: fixed to work with non-gcc -aux-info is a gccism absent in clang, icc and the like; let's reimplement this in a slightly cleaner way with -E. Suggested-by: Evgeny Mareev --- libselinux/src/exception.sh | 12 +++++------- libsemanage/src/exception.sh | 12 +++++------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/libselinux/src/exception.sh b/libselinux/src/exception.sh index d6c8c71..459295c 100755 --- a/libselinux/src/exception.sh +++ b/libselinux/src/exception.sh @@ -15,10 +15,8 @@ echo " ;; esac } -if ! ${CC:-gcc} -x c -c -I../include - -aux-info temp.aux < ../include/selinux/selinux.h -then - # clang does not support -aux-info so fall back to gcc - gcc -x c -c -I../include - -aux-info temp.aux < ../include/selinux/selinux.h -fi -for i in `awk '/.*extern int/ { print $6 }' temp.aux`; do except $i ; done -rm -f -- temp.aux -.o + +# equivalent of gcc-specific -aux-info +${CC:-gcc} -E -I../include -xc ../include/selinux/selinux.h | + sed -n 's/^extern * int *\(\w*\) *(.*$/\1/p' | + while read f; do except $f; done diff --git a/libsemanage/src/exception.sh b/libsemanage/src/exception.sh index 97bc2ae..11586a1 100644 --- a/libsemanage/src/exception.sh +++ b/libsemanage/src/exception.sh @@ -9,10 +9,8 @@ echo " } " } -if ! ${CC:-gcc} -x c -c -I../include - -aux-info temp.aux < ../include/semanage/semanage.h -then - # clang does not support -aux-info so fall back to gcc - gcc -x c -c -I../include - -aux-info temp.aux < ../include/semanage/semanage.h -fi -for i in `awk '/extern int/ { print $6 }' temp.aux`; do except $i ; done -rm -f -- temp.aux -.o + +# equivalent of gcc-specific -aux-info +${CC:-gcc} -E -I../include -xc ../include/semanage/semanage.h | + sed -n 's/^extern * int *\(\w*\) *(.*$/\1/p' | + while read f; do except $f; done -- 2.10.4