From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 298213858429 for ; Thu, 11 Aug 2022 14:54:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 298213858429 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-138-OgGARvOvOmOzf6KVIC8DSw-1; Thu, 11 Aug 2022 10:54:53 -0400 X-MC-Unique: OgGARvOvOmOzf6KVIC8DSw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6508A1824605; Thu, 11 Aug 2022 14:54:53 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.85]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D8B12C15BA8; Thu, 11 Aug 2022 14:54:52 +0000 (UTC) From: Florian Weimer To: Adhemerval Zanella Cc: libc-alpha@sourceware.org Subject: Re: [PATCH v4] glibcextract.py: Add compile_c_snippet References: <20220811112136.62369-1-adhemerval.zanella@linaro.org> Date: Thu, 11 Aug 2022 16:54:51 +0200 In-Reply-To: <20220811112136.62369-1-adhemerval.zanella@linaro.org> (Adhemerval Zanella's message of "Thu, 11 Aug 2022 08:21:36 -0300") Message-ID: <87bksqu8xw.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Aug 2022 14:54:58 -0000 * Adhemerval Zanella: > It might be used on tests to check if a snippet build with the provided > compiler and flags. > --- > scripts/glibcextract.py | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/scripts/glibcextract.py b/scripts/glibcextract.py > index 43ab58ffe2..33463087da 100644 > --- a/scripts/glibcextract.py > +++ b/scripts/glibcextract.py > @@ -17,6 +17,7 @@ > # License along with the GNU C Library; if not, see > # . > > +import collections > import os.path > import re > import subprocess > @@ -173,3 +174,20 @@ def compare_macro_consts(source_1, source_2, cc, macro_re, exclude_re=None, > if not allow_extra_2: > ret = 1 > return ret > + > +CompileResult = collections.namedtuple("CompileResult", "returncode output") > + > +def compile_c_snippet(snippet, cc, extra_cc_args=''): > + """Compile and return whether the SNIPPET can be build with CC along > + EXTRA_CC_ARGS compiler flags. Return a CompileResult with RETURNCODE > + being 0 for success, or the failure value and the compiler output. > + """ > + with tempfile.TemporaryDirectory() as temp_dir: > + c_file_name = os.path.join(temp_dir, 'test.c') > + obj_file_name = os.path.join(temp_dir, 'test.o') > + with open(c_file_name, 'w') as c_file: > + c_file.write(snippet + '\n') > + cmd = cc.split() + extra_cc_args.split() + ['-c', '-o', obj_file_name, > + c_file_name] > + r = subprocess.run(cmd, capture_output=True) > + return CompileResult(r.returncode, r.stderr) Meh. Traceback (most recent call last): File "../sysdeps/unix/sysv/linux/tst-mount-compile.py", line 66, in main() File "../sysdeps/unix/sysv/linux/tst-mount-compile.py", line 38, in main args.cc).returncode != 0: File "/home/bmg/src/glibc/scripts/glibcextract.py", line 192, in compile_c_snippet r = subprocess.run(cmd, capture_output=True) File "/usr/lib64/python3.6/subprocess.py", line 423, in run with Popen(*popenargs, **kwargs) as process: TypeError: __init__() got an unexpected keyword argument 'capture_output' That's with Python 3.6. Thanks, Florian