From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12170 Path: news.gmane.org!.POSTED!not-for-mail From: John Starks Newsgroups: gmane.linux.lib.musl.general Subject: RE: [PATCH] Wasm support patch 2 (static syscalls) Date: Tue, 28 Nov 2017 16:51:19 +0000 Message-ID: References: <20171128125948.GK15263@port70.net> ,<20171128140531.GM15263@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1511887898 24662 195.159.176.226 (28 Nov 2017 16:51:38 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 28 Nov 2017 16:51:38 +0000 (UTC) To: "musl@lists.openwall.com" Original-X-From: musl-return-12186-gllmg-musl=m.gmane.org@lists.openwall.com Tue Nov 28 17:51:33 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1eJj6W-0005kQ-Ri for gllmg-musl@m.gmane.org; Tue, 28 Nov 2017 17:51:29 +0100 Original-Received: (qmail 3668 invoked by uid 550); 28 Nov 2017 16:51:33 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 3650 invoked from network); 28 Nov 2017 16:51:32 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=G5pPnz2AFosn0HdqtNHB2IhUdfU81MgDvXHalv9ojW0=; b=kqYXdPOvfxmdV+5vxLQGKliJIEG8gYMxWl80GeIb6JoZt3TvoITk/KIU3ptDyIVuiT5gtwJlAO+soTlb9ea8HGcQx7+eoLD2lF3/V4Bq0Y/hgUyqMH2TAGkAYVUf9UVq6qCl0b2QLH3wWfMAQpVoEzuTIHO90qlOvD+KPWTdptY= Thread-Topic: [musl] [PATCH] Wasm support patch 2 (static syscalls) Thread-Index: AQHTaEFVgDgYeA7kVEKWz4n1+gEDaKMpwQcAgAACxiWAAA+XgIAABULSgAAlMPA= In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Owner=jostarks@ntdev.microsoft.com; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2017-11-28T16:51:17.0679328Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Application=Microsoft Azure Information Protection; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Extended_MSFT_Method=Automatic; Sensitivity=General x-originating-ip: [2001:4898:80e8:3::44c] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR21MB0857;6:ktIi6tTHy9e87Fn5F/tTjTvHe/v1vHcbqgh97PhbHhw9OP6Suw+2GfZjFTuUAL1sl+56pvfcjPWXmQZKA0MXrtMd3BXR/44N6D5BK5FfpISpFgqz8ciCZRemBBs1WvtNskD6In6rFIUxil+v8KR0ax/XfUC2aL5IliDG9vPW8OYTNZjywRP/t6CDqJNa8kFPu0g7rAgmQ9QKyaXAoR/1Aigv08uu3V+MsJPhjjZPCvCeBvI3RoIv6/x9RTlTg/dqoIrdYJa01+OPWDl85AWnD3vCHdm5/sCWe333GtNyq9SaVgz4ReOMLMbsWkhdaSY0XhoVB5qs0rt+FY2BmLRGdF8tjAeTahdf9f24igCwrI0=;5:f0yTN3FhfXX2xVRn3JUADkldssLi6MOHTNhWkZOq2RpjXebbrA+Ja5NXy2X4brF/djwTfsoVNLuQPwPj6T/ORvkmIS9wBsO1NMtj4kjB2qgf8+mM5btx06UGvVQBfg6mZyCYOUqcVfmcHnSPotKO13EocX+V12Shn1YwH6YS9As=;24:XdoD172ZJvo5e0O0FpCk9/FZOoyYl86JtRxK7t1kC/zw0XsENugg4dsc0Psu2ikH2DX1E3Sf+2H6CVyRAy0Yhqmr0weR+YNWMoeDQvElCoc=;7:1mzwboFDm/iiEZwZng0hSAfB6yerG5Ixe8XxAxvBv57BCcCrtjIfMCuqkwoFczkRmQ6nWcUBcGnqSRziqpX95NhDixpYHr 3HbPthqiVlDonas1f1iQIxah8BcsMtpU+AjxLGkTo2IbLtBZxFmuH4sYpmHBaEPcdCLzKPgseTH0hIxTax/F9yCUIrWLISaTYT x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 62cf826a-aede-4054-4464-08d536803f9d x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(48565401081)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603258);SRVR:DM5PR21MB0857; x-ms-traffictypediagnostic: DM5PR21MB0857: authentication-results: spf=none (sender IP is ) smtp.mailfrom=John.Starks@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040450)(2401047)(8121501046)(5005006)(3002001)(3231022)(93006095)(93001095)(10201501046)(6055026)(61426038)(61427038)(6041248)(20161123560025)(20161123558100)(20161123555025)(20161123564025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR21MB0857;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:DM5PR21MB0857; x-forefront-prvs: 0505147DDB x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(39860400002)(346002)(366004)(376002)(47760400005)(199003)(13464003)(377424004)(189002)(68736007)(53546010)(86362001)(86612001)(7736002)(305945005)(74316002)(72206003)(105586002)(8936002)(10290500003)(106356001)(101416001)(33656002)(478600001)(2351001)(77096006)(6436002)(229853002)(6506006)(50986999)(14454004)(54356999)(76176999)(5640700003)(6246003)(10090500001)(53936002)(9686003)(8990500004)(25786009)(55016002)(102836003)(6116002)(2906002)(81156014)(81166006)(8676002)(1730700003)(3660700001)(3280700002)(6916009)(2950100002)(99286004)(5660300001)(2900100001)(7696005)(189998001)(22452003)(316002)(93886005)(4001150100001)(2501003)(97736004);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR21MB0857;H:DM5PR21MB0188.namprd21.prod.outlook.com;FPR:;SP F:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 62cf826a-aede-4054-4464-08d536803f9d X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Nov 2017 16:51:19.2997 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR21MB0857 Xref: news.gmane.org gmane.linux.lib.musl.general:12170 Archived-At: What if you redefine the syscall numbers in wasm to be function pointers to= the actual syscalls, e.g. #define SYS_unlink ((long)&__syscall_unlink). Th= en __syscall and friends can just apply the arguments to the function point= er. This should play nice with the linker and probably optimizes well. -----Original Message----- From: Nicholas Wilson [mailto:nicholas.wilson@realvnc.com]=20 Sent: Tuesday, November 28, 2017 6:35 AM To: musl@lists.openwall.com Subject: Re: [musl] [PATCH] Wasm support patch 2 (static syscalls) That's some sophisticated link-time optimisation you're expecting there! DC= E on a single source file wouldn't do it. When you have callers like __setxid, it's not until the final link that tha= t kind of elimination could be run; just by examining setxid.c there's no w= ay the compiler could eliminate anything. And, it would rely on several sta= ges of inlining taking place, which you really can't guarantee. (Not to men= tion that the Clang LLD linker doesn't do LTO.) The traditional unix linkin= g model isn't really geared up for this level of link-time inlining and opt= imising. The current Emscripten fork of Musl implements the "static syscalls" a litt= le differently. They have retained the numeric constants for the syscalls, = but the calls are redirected to functions with names like "__syscall_42" in= stead of "__syscall_getpid". At the end of the day, there isn't a big diffe= rence between my approach here and the current Emscripten one - I've just r= educed the amount of Musl code that needs to be touched to support the stat= ic syscalls, and I can't see how to reduce the changes further... Nick ________________________________________ From: Szabolcs Nagy Sent: 28 November 2017 14:05:31 To: musl@lists.openwall.com Subject: Re: [musl] [PATCH] Wasm support patch 2 (static syscalls) * Nicholas Wilson [2017-11-28 13:23:15 +0000]= : > With a jump table like that, you can't get static linkage. The compiler w= ill link in *every* syscall. use a better compiler with dce then.