From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12172 Path: news.gmane.org!.POSTED!not-for-mail From: Nicholas Wilson Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] Wasm support patch 2 (static syscalls) Date: Tue, 28 Nov 2017 17:53:27 +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 1511891630 14257 195.159.176.226 (28 Nov 2017 17:53:50 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 28 Nov 2017 17:53:50 +0000 (UTC) To: "musl@lists.openwall.com" Original-X-From: musl-return-12188-gllmg-musl=m.gmane.org@lists.openwall.com Tue Nov 28 18:53:45 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 1eJk4g-0002va-QE for gllmg-musl@m.gmane.org; Tue, 28 Nov 2017 18:53:39 +0100 Original-Received: (qmail 28110 invoked by uid 550); 28 Nov 2017 17:53:43 -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 28089 invoked from network); 28 Nov 2017 17:53:42 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=realvnc.onmicrosoft.com; s=selector1-realvnc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=+vqd7mtWbYzUfalVwOGDo5JlUdBNET22v8xoL3GyMdY=; b=hgKrYkIrb+YdWYAYOLQd/7HBbx4AnVtCz9tct49Sktss87psIyh2nFMsC1UJipwUC4Ji1p9EYh4A1K9EQGh59K1VA7a4BmUejZuoHeV0fehxDKX0C4Q83CwLiKa9aBSUS4oFxXP4RMtmWFE9StBRyLjeasOFOWsQYYKIRWS5LRc= Thread-Topic: [musl] [PATCH] Wasm support patch 2 (static syscalls) Thread-Index: AQHTaEFVgDgYeA7kVEKWz4n1+gEDaKMpwQcAgAACxiWAAA+XgIAABULSgAAlMPCAABJGdQ== In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=nicholas.wilson@realvnc.com; x-originating-ip: [2a02:390:a001:192:d6be:d9ff:fe9c:1892] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;VI1PR0502MB3885;6:uUjvjR7VAsalA4ta6YDa4LjLI2G0KnhyXAKS/jo6TCxwIKtuCChi6KPOr39Ff9LYxW8WWXzxZrZciuk+Hyk1Q4hQsXOCAianJqu/yhWxh9KkVc7kqPR0L1zY2iq8DN575TVElkQH99ybRvtEvgvLkSvPz/Un4IwiW26vF+5xqH0vrR3nIuQCVX/J4UTzF51zHJHwTbrkI8VPznUNL3QRFFGIwLI/5RTpeNg4XqjPKcvexq83uMas2o54K7PGw6zvttA3Z59CqR/7MKm2D8cshOBqHX1Djpze1CHylHeYk+wYk8AAJbQBcPuz7Wa65y+99UebJN/rwhfDAUVh1g9f9B8dXeySepJ3RRGcbUMSxWI=;5:0maJGzdl8zBmelJMRRxxBRdm260dyQiJtTw4aRyhdDBcfwpwmd9sF8oXkNYFUoZmJTeL6Abw1uWtMPtqKXIbM2okJnXyj5YAkOxjMl8EAND8y3G34x57uFfDNAEo4xCVcC0wl1ZeB8a2bmfDegxWKVEC+pYCpH9AjonMNPSHcoU=;24:Eu3qtWxZLkAMIQyPErnJGP+O3jynnxIXcCBSH4ggb1NzmfelSsPVD2whE7LdMK6hZBHL27CY9aC6u4QPBmMGRz6uw7I+xOpcUVVp8BvLF74=;7:Cp5zCiNOPjWOAfrBvGbPd4Ue/zCn2MlddK6kaCRbD+cbgn70GmI1ca/nkgrd7jOkQzNQc9dU7Frm08fhszf3UxnmfFmQ NUp6ydoo/a5VxU18I+ysSQ7Y3+waTA9SDQQqg/vzKkhBHM2s142Wa6fWcMxA1qfbpGGa1Q/S055HgK5wkZ7PugT++njTFt3Dpv x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 5085ab53-2d98-4c46-fd67-08d53688ee04 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4602075)(4603075)(4627115)(201702281549075)(5600026)(4604075)(2017052603258);SRVR:VI1PR0502MB3885; x-ms-traffictypediagnostic: VI1PR0502MB3885: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040450)(2401047)(8121501046)(5005006)(10201501046)(3231022)(3002001)(93006095)(93001095)(6041248)(2016111802025)(20161123560025)(20161123564025)(20161123562025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(6072148)(6043046)(201708071742011);SRVR:VI1PR0502MB3885;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:VI1PR0502MB3885; x-forefront-prvs: 0505147DDB x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(366004)(346002)(376002)(199003)(13464003)(377424004)(189002)(3280700002)(7736002)(3660700001)(102836003)(305945005)(14454004)(81166006)(316002)(7696005)(478600001)(93886005)(5250100002)(97736004)(6436002)(6116002)(74316002)(189998001)(2950100002)(8676002)(5640700003)(6916009)(8936002)(86362001)(2900100001)(53936002)(9686003)(106356001)(76176999)(105586002)(99286004)(6246003)(55016002)(50986999)(54356999)(101416001)(25786009)(2351001)(229853002)(5660300001)(2906002)(53546010)(1730700003)(81156014)(68736007)(4001150100001)(2501003)(33656002)(6506006);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0502MB3885;H:VI1PR0502MB3885.eurprd05.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: realvnc.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM X-MS-Exchange-CrossTenant-Network-Message-Id: 5085ab53-2d98-4c46-fd67-08d53688ee04 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Nov 2017 17:53:27.8456 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9ad766d3-c6a5-4458-8c58-244e7c118728 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0502MB3885 X-OriginatorOrg: realvnc.com Xref: news.gmane.org gmane.linux.lib.musl.general:12172 Archived-At: Thanks John! In fact we'd have to cast them through an int, since Musl some= times stores syscall numbers in an int, but that cast is safe on Wasm since= function pointers are just an index into a global array of functions, so a= re guaranteed to be "small". It's cunning, and I like it! OK, so this patch can also be scrapped, I think it's not necessary with Joh= n's idea. Nick ________________________________________ From: John Starks Sent: 28 November 2017 16:51:19 To: musl@lists.openwall.com Subject: RE: [musl] [PATCH] Wasm support patch 2 (static syscalls) 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] 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.