mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Tom Storey <tom@snnap.net>
To: Rich Felker <dalias@libc.org>
Cc: musl@lists.openwall.com
Subject: Re: [musl] Building for m68k
Date: Fri, 24 Apr 2020 10:36:23 +1000	[thread overview]
Message-ID: <CAFDgZgWe2Sc83DEWjDLUQd=wW5AAzJ7eUp-C4YDm4Hq9g8YPbQ@mail.gmail.com> (raw)
In-Reply-To: <20200423163016.GW11469@brightrain.aerifal.cx>

[-- Attachment #1: Type: text/plain, Size: 4395 bytes --]

Thanks Rich.

Just for gits and shiggles I tried #ifdef'ing out the cas.l instruction in
the atomic_arch.h file for 68020+ processors, and compilation then
proceeded along very smoothly for a while, but then hit another roadblock
in src/setjmp/m68k/longjmp.s where it tries to execute a floating point
instruction, and then subsequently fails with a "needs M68K fpu" error
message. So maybe there was a way to work around that, but FPU adds another
dimension to this problem.

Trying to make this work is probably more than I'm really willing to take
on for this project, so I may put it on the back burner and perhaps look at
it another time. In the meantime I will look at copying in the source I
require into my own "kind of mini-libc". I can't imagine I'm going to use a
large percentage of what's there anyway, so maybe just cherry picking the
bits I want is a better way forward for now.

If I get really adventurous maybe I'll look into using a 68020 or above
processor, but for now I would like to stick with the simpler 68000. At
that point I could probably look at running more of a full blown Linux. :-)

Cheers.

On Fri, 24 Apr 2020 at 02:30, Rich Felker <dalias@libc.org> wrote:

> On Thu, Apr 23, 2020 at 03:04:15PM +1000, Tom Storey wrote:
> > Hi Rich,
> >
> > Sorry, I should perhaps mention that I am looking to "build for bare
> > metal", if that matters? Im not a particular expert in all of this. :-)
> >
> > Basically, my situation is that Im a hobbyist, and have plans to build a
> > computer around the m68k. Not looking to run Linux or anything on it, but
> > dont want to be stuck with writing assembly. I was hoping to have libc
> > available just to have access to some standard functions if needed.
> >
> > Or, perhaps Im complicating things for my intended use? The older CPUs
> > might not be supported due to lack of MMU, and libc is really only meant
> > for use within an OS environment? Could I perhaps be better off writing
> my
> > own implementations of libc things if/when I need them?
>
> It's possible to do a bare-metal port of musl, or to use unmodified or
> minimally-modified musl with bare-metal by implementing the syscall
> ABI for at least a minimal set of syscalls for things you need. In the
> m68k case the latter would also involve the trap handler emulating the
> cas instruction. If doing your own more extensive port, you could do
> something more elaborate but less costly, or on nommu something simple
> like cli;nonatomic_op;sti.
>
> Any of these options is going to be a lot less work than writing a
> significantly functional libc from scratch.
>
> Rich
>
>
> > On Thu, 23 Apr 2020 at 12:32, Rich Felker <dalias@libc.org> wrote:
> >
> > > On Thu, Apr 23, 2020 at 12:05:27PM +1000, Tom Storey wrote:
> > > > Hi all.
> > > >
> > > > Is anyone out there particularly familiar with building musl for the
> > > m68k?
> > > >
> > > > I was able to successfully build it, but then later discovered that
> it
> > > > would appear to be targeting 68020+ processors more specifically. I
> would
> > > > like to build for the earlier 680[01]0's.
> > > >
> > > > Specific examples are to do with (at least) aio where some atomic
> > > > instructions are used (e.g. cas - compare and swap) which only exist
> for
> > > > the 68020 and later, but not for earlier processors.
> > > >
> > > > https://git.musl-libc.org/cgit/musl/tree/src/aio/aio.c#n375
> > > > https://git.musl-libc.org/cgit/musl/tree/arch/m68k/atomic_arch.h
> > > >
> > > > Thus, adding -m68000 to the CFLAGS env variable when trying to do a
> > > rebuild
> > > > results in a failure complaining that the 68020+ is required. I dont
> know
> > > > what else is hiding away in the rest of it that will also be
> > > > incompatible... :-)
> > > >
> > > > Any suggestions, pointers, tips would be greatly appreciated.
> > >
> > > To answer this I think we need to know how Linux support for these
> > > models is meant to work (if it even is meant to). If Linux does
> > > trap-and-emulate (I'm not aware of any other mechanism it has by which
> > > it could make this work) then it might just amount to passing the
> > > right -Wa,... to make the assembler accept instructions not supported
> > > in the target ISA level. But it could mean there are missing
> > > prerequisites that have to be fixed on the kernel side before anything
> > > can actually work.
> > >
> > > Rich
> > >
>

[-- Attachment #2: Type: text/html, Size: 5642 bytes --]

  reply	other threads:[~2020-04-24  0:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-23  2:05 Tom Storey
2020-04-23  2:32 ` Rich Felker
2020-04-23  5:04   ` Tom Storey
2020-04-23 16:30     ` Rich Felker
2020-04-24  0:36       ` Tom Storey [this message]
2020-04-24  0:51         ` Rich Felker
2020-04-24  1:14           ` Tom Storey
2020-04-24  1:20             ` Rich Felker
2020-04-24  2:29               ` Tom Storey
2020-04-24  2:37                 ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFDgZgWe2Sc83DEWjDLUQd=wW5AAzJ7eUp-C4YDm4Hq9g8YPbQ@mail.gmail.com' \
    --to=tom@snnap.net \
    --cc=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).