From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 577661F463 for ; Tue, 17 Dec 2019 14:31:33 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:in-reply-to:references :message-id:date:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=TfRvAdXLViKFUiZc fmu9DrBQpDXAC/ryJNd/zxpnjVhe99+h93yoG6WMugUmpLvzo3tZtwB+Bfv59oA7 htddE5m3KFP5MB0hXr0rj1r2QAWYPqHdFUmOEuJlOxbZlKRKu8ub0mx1P2Ry8Qa8 OYQ04167Pru58TiqqdfjSGTbdec= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:in-reply-to:references :message-id:date:mime-version:content-type :content-transfer-encoding; s=default; bh=1faRzXwaCC6h7GnquE5BuR VMA8A=; b=BhZm8yliRfMmStoB5W6fbaL+bXlFlCPJd9y8CpMmFLgeKMDTdS/Sx5 kob3By3u+SSiZB/5F1Xzl1eLHLeaxnfzsyIvi7das5Gt08L1NhcCV7gv1x3bpqqe woIhAxdw4LCdzRYmOl+OqiJXm+/J7VobywadglYyLXsVi1YLAlilY= Received: (qmail 6146 invoked by alias); 17 Dec 2019 14:31:15 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 6085 invoked by uid 89); 17 Dec 2019 14:31:15 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: us-smtp-1.mimecast.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576593071; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y9RxjTesZyAGc3+Po44Bkmrt91TptqybCN56cD0JbrA=; b=EX/ZGJwdRYO8wtY2pQkaJodKd2cQirPhmNULJkwdHNrggX60Q8y+YpqPZ5SDRp5ODOT2J/ 1ykqmH57dWuK4+7D/BQAeTTvDgIxkl1I4HSxluPTpDcek3ilDD7mxBk5zx1pJlvu5rdkJO 7+cRA1rJeJ2Ou38/3QJdgxLhU5mVooQ= From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH 4/5] build-many-glibcs.py: Introduce glibc build policy classes In-Reply-To: References: Message-Id: Date: Tue, 17 Dec 2019 15:31:05 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable The new classes GlibcPolicyForCompiler and GlibcPolicyForBuild allow customization of the Glibc.build_glibc method, replacing the existing for_compiler flag. --- scripts/build-many-glibcs.py | 129 ++++++++++++++++++++++------------- 1 file changed, 80 insertions(+), 49 deletions(-) diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py index 56160a16fc..58f2409b1d 100755 --- a/scripts/build-many-glibcs.py +++ b/scripts/build-many-glibcs.py @@ -1274,7 +1274,7 @@ class Config(object): for g in self.compiler_glibcs: cmdlist.push_subdesc('glibc') cmdlist.push_subdesc(g.name) - g.build_glibc(cmdlist, True) + g.build_glibc(cmdlist, GlibcPolicyForCompiler(g)) cmdlist.pop_subdesc() cmdlist.pop_subdesc() self.build_gcc(cmdlist, False) @@ -1395,6 +1395,76 @@ class Config(object): '--enable-shared', '--enable-threads'] self.build_cross_tool(cmdlist, 'gcc', tool_build, cfg_opts) =20 +class GlibcPolicyDefault(object): + """Build policy for glibc: common defaults.""" + + def __init__(self, glibc): + self.srcdir =3D glibc.ctx.component_srcdir('glibc') + self.use_usr =3D glibc.os !=3D 'gnu' + self.prefix =3D '/usr' if self.use_usr else '' + self.configure_args =3D [ + '--prefix=3D%s' % self.prefix, + '--enable-profile', + '--build=3D%s' % glibc.ctx.build_triplet, + '--host=3D%s' % glibc.triplet, + 'CC=3D%s' % glibc.tool_name('gcc'), + 'CXX=3D%s' % glibc.tool_name('g++'), + 'AR=3D%s' % glibc.tool_name('ar'), + 'AS=3D%s' % glibc.tool_name('as'), + 'LD=3D%s' % glibc.tool_name('ld'), + 'NM=3D%s' % glibc.tool_name('nm'), + 'OBJCOPY=3D%s' % glibc.tool_name('objcopy'), + 'OBJDUMP=3D%s' % glibc.tool_name('objdump'), + 'RANLIB=3D%s' % glibc.tool_name('ranlib'), + 'READELF=3D%s' % glibc.tool_name('readelf'), + 'STRIP=3D%s' % glibc.tool_name('strip'), + ] + if glibc.os =3D=3D 'gnu': + self.configure_args.append('MIG=3D%s' % glibc.tool_name('mig')= ) + self.configure_args +=3D glibc.cfg + + def configure(self, cmdlist): + """Invoked to add the configure command to the command list.""" + cmdlist.add_command('configure', + [os.path.join(self.srcdir, 'configure'), + *self.configure_args]) + + def extra_commands(self, cmdlist): + """Invoked to inject additional commands (make check) after build.= """ + pass + +class GlibcPolicyForCompiler(GlibcPolicyDefault): + """Build policy for glibc during the compilers stage.""" + + def __init__(self, glibc): + super().__init__(glibc) + self.builddir =3D glibc.ctx.component_builddir( + 'compilers', glibc.compiler.name, 'glibc', glibc.name) + self.installdir =3D glibc.compiler.sysroot + +class GlibcPolicyForBuild(GlibcPolicyDefault): + """Build policy for glibc during the glibcs stage.""" + + def __init__(self, glibc): + super().__init__(glibc) + self.builddir =3D glibc.ctx.component_builddir( + 'glibcs', glibc.name, 'glibc') + self.installdir =3D glibc.ctx.glibc_installdir(glibc.name) + if glibc.ctx.strip: + self.strip =3D glibc.tool_name('strip') + else: + self.strip =3D None + self.save_logs =3D glibc.ctx.save_logs + + def extra_commands(self, cmdlist): + if self.strip: + cmdlist.add_command('strip', + ['sh', '-c', + ('%s $(find %s/lib* -name "*.so")' % + (self.strip, self.installdir))]) + cmdlist.add_command('check', ['make', 'check']) + cmdlist.add_command('save-logs', [self.save_logs], always_run=3DTr= ue) + =20 class Glibc(object): """A configuration for building glibc.""" @@ -1442,66 +1512,27 @@ class Glibc(object): ['test', '-f', os.path.join(self.compiler.installdir, 'ok')]= ) cmdlist.use_path(self.compiler.bindir) - self.build_glibc(cmdlist, False) + self.build_glibc(cmdlist, GlibcPolicyForBuild(self)) self.ctx.add_makefile_cmdlist('glibcs-%s' % self.name, cmdlist, logsdir) =20 - def build_glibc(self, cmdlist, for_compiler): + def build_glibc(self, cmdlist, policy): """Generate commands to build this glibc, either as part of a comp= iler build or with the bootstrapped compiler (and in the latter case, r= un tests as well).""" - srcdir =3D self.ctx.component_srcdir('glibc') - if for_compiler: - builddir =3D self.ctx.component_builddir('compilers', - self.compiler.name, 'gl= ibc', - self.name) - installdir =3D self.compiler.sysroot - else: - builddir =3D self.ctx.component_builddir('glibcs', self.name, - 'glibc') - installdir =3D self.ctx.glibc_installdir(self.name) - cmdlist.create_use_dir(builddir) - use_usr =3D self.os !=3D 'gnu' - prefix =3D '/usr' if use_usr else '' - cfg_cmd =3D [os.path.join(srcdir, 'configure'), - '--prefix=3D%s' % prefix, - '--enable-profile', - '--build=3D%s' % self.ctx.build_triplet, - '--host=3D%s' % self.triplet, - 'CC=3D%s' % self.tool_name('gcc'), - 'CXX=3D%s' % self.tool_name('g++'), - 'AR=3D%s' % self.tool_name('ar'), - 'AS=3D%s' % self.tool_name('as'), - 'LD=3D%s' % self.tool_name('ld'), - 'NM=3D%s' % self.tool_name('nm'), - 'OBJCOPY=3D%s' % self.tool_name('objcopy'), - 'OBJDUMP=3D%s' % self.tool_name('objdump'), - 'RANLIB=3D%s' % self.tool_name('ranlib'), - 'READELF=3D%s' % self.tool_name('readelf'), - 'STRIP=3D%s' % self.tool_name('strip')] - if self.os =3D=3D 'gnu': - cfg_cmd +=3D ['MIG=3D%s' % self.tool_name('mig')] - cfg_cmd +=3D self.cfg - cmdlist.add_command('configure', cfg_cmd) + cmdlist.create_use_dir(policy.builddir) + policy.configure(cmdlist) cmdlist.add_command('build', ['make']) cmdlist.add_command('install', ['make', 'install', - 'install_root=3D%s' % installdir]) + 'install_root=3D%s' % policy.insta= lldir]) # GCC uses paths such as lib/../lib64, so make sure lib # directories always exist. mkdir_cmd =3D ['mkdir', '-p', - os.path.join(installdir, 'lib')] - if use_usr: - mkdir_cmd +=3D [os.path.join(installdir, 'usr', 'lib')] + os.path.join(policy.installdir, 'lib')] + if policy.use_usr: + mkdir_cmd +=3D [os.path.join(policy.installdir, 'usr', 'lib')] cmdlist.add_command('mkdir-lib', mkdir_cmd) - if not for_compiler: - if self.ctx.strip: - cmdlist.add_command('strip', - ['sh', '-c', - ('%s $(find %s/lib* -name "*.so")' % - (self.tool_name('strip'), installdir= ))]) - cmdlist.add_command('check', ['make', 'check']) - cmdlist.add_command('save-logs', [self.ctx.save_logs], - always_run=3DTrue) + policy.extra_commands(cmdlist) cmdlist.cleanup_dir() =20 =20 --=20 2.23.0