From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12438 Path: news.gmane.org!.POSTED!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: Views on bare metal port Date: Wed, 31 Jan 2018 19:25:47 +0100 Message-ID: <20180131182546.GL4418@port70.net> References: <20180131152507.GO1627@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1517423070 9844 195.159.176.226 (31 Jan 2018 18:24:30 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 31 Jan 2018 18:24:30 +0000 (UTC) User-Agent: Mutt/1.9.1 (2017-09-22) To: musl@lists.openwall.com Original-X-From: musl-return-12454-gllmg-musl=m.gmane.org@lists.openwall.com Wed Jan 31 19:24:26 2018 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 1egx38-00016I-KI for gllmg-musl@m.gmane.org; Wed, 31 Jan 2018 19:23:58 +0100 Original-Received: (qmail 30692 invoked by uid 550); 31 Jan 2018 18:26:00 -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 30659 invoked from network); 31 Jan 2018 18:25:59 -0000 Mail-Followup-To: musl@lists.openwall.com Content-Disposition: inline In-Reply-To: Xref: news.gmane.org gmane.linux.lib.musl.general:12438 Archived-At: * Jon Chesterfield [2018-01-31 17:51:33 +0000]: > Implementing the syscalls probably wouldn't be too much trouble, thanks for > the advice. > > I've been able to build 95% of math on our toolchain in the last hour. > Impressed by how straightforward that was. Nice codebase. > note that in particular for math code llvm is problematic. i'm not aware of any issues in musl libm currently, but rounding mode changes can break in unexpected ways because there is no support for -frounding-math (last time i checked the few cases where it matters clang did not miscompile those, but this is not actively tested) an illustration of the kind of things that can go wrong: https://github.com/freebsd/freebsd/commit/e7b0a63c190c7ecb475b09f41387a75952540f49 we don't have equivalent hacks in musl. > On 31 Jan 2018 15:25, "Rich Felker" wrote: > > On Wed, Jan 31, 2018 at 01:38:44PM +0000, Jon Chesterfield wrote: > > Hello musl, > > > > I'm writing an llvm back end for a custom asic. There's no kernel, limited > > syscall support. As far as I can tell from the source tree, musl expects a > > host OS. I'm aware of a couple of projects running musl by emulating the > > Linux syscall interface. > > > > I would like to derive libc from a subset of musl. Math.h included, > > filesystem excluded. Malloc and threads tdb. > > > > Are there any bare metal projects that use musl without syscall emulation? > > If not, would one be of interest to this mailing list? > > I'm not aware of any specific ones to recommend (maybe others can > suggest) but here are a couple general guidelines: > > 1. The easiest and probably-recommended way to do this is just writing > a trap handler to implement the syscalls you need and using musl > unmodified. You've said you don't want to do that, though, so > moving on... > > 2. The other intended/recommended way is making new arch dirs with a > syscall_impl.h that implements the syscall.h backend stuff as calls > to your own functions. The SYS_* macros can actually be defined as > function pointers if you like, or you can still use numbers and a > switch-based dispatch table. Either way the vast majority of > syscall points have constant expressions for the syscall number so > it should all collapse/inline fine to a single direct call. > > 3. While you can trim down parts of the tree you don't need, there's > usually no compelling reason to do so. Static linking (only option > for bare metal anyway) will not link things you don't use. > > Hope this helps a bit. > > Rich