From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12435 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Views on bare metal port Date: Wed, 31 Jan 2018 10:25:07 -0500 Message-ID: <20180131152507.GO1627@brightrain.aerifal.cx> References: 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 1517412210 10447 195.159.176.226 (31 Jan 2018 15:23:30 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 31 Jan 2018 15:23:30 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-12451-gllmg-musl=m.gmane.org@lists.openwall.com Wed Jan 31 16:23:21 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 1eguEI-00022E-L3 for gllmg-musl@m.gmane.org; Wed, 31 Jan 2018 16:23:18 +0100 Original-Received: (qmail 15621 invoked by uid 550); 31 Jan 2018 15:25:20 -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 15596 invoked from network); 31 Jan 2018 15:25:19 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:12435 Archived-At: 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