mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Michael Forney <mforney@mforney.org>
To: musl@lists.openwall.com
Subject: Re: riscv port for review
Date: Sat, 10 Nov 2018 22:34:04 -0800	[thread overview]
Message-ID: <CAGw6cBt97QUoMwwp5SUizG2MabtLxHK3fChG0P9=O4S+zmNE9w@mail.gmail.com> (raw)
In-Reply-To: <CAGw6cBtO2HDrxj-yarC5BfCOBsVLzaUFP0sjAXh9UbRqJKdn5g@mail.gmail.com>

On 2018-10-18, Michael Forney <mforney@mforney.org> wrote:
> On 2018-10-11, Michael Forney <mforney@mforney.org> wrote:
>> On 2018-09-27, Rich Felker <dalias@libc.org> wrote:
>>> Pulled from here:
>>> https://github.com/riscv/riscv-musl/commit/6a4f4a9c774608add4b02f95322518bd2f5f51ee
>>>
>>> Attached for review.
>>
>> I noticed that some fcntl.h constants are incorrect (O_DIRECTORY,
>> O_NOFOLLOW, O_DIRECT, O_LARGEFILE, and O_TMPFILE). Linux doesn't seem
>> to have a riscv-specific fcntl.h, so I think they just come from
>> asm-generic.
>
> While playing around with a riscv32-linux-musl toolchain and tinyemu,
> I found a few more issues:
>
> - riscv linux has no renameat syscall. I think __NR_renameat needs to
> be removed from arch/riscv*/bits/syscall.h.in, and musl's rename and
> renameat need to fallback to SYS_renameat2 if SYS_renameat is not
> defined.
>
> - arch/riscv32/bits/syscall.h.in defines syscall names as if it were
> 64-bit. I think the following changes are necessary
>     __NR_fcntl -> __NR_fcntl64
>     __NR_statfs -> __NR_statfs64
>     __NR_fstatfs -> __NR_fstatfs64
>     __NR_truncate -> __NR_truncate64
>     __NR_ftruncate -> __NR_ftruncate64
>     __NR_lseek -> __NR__llseek (and __NR_llseek?)
>     __NR_fstatat -> __NR_fstatat64
>     __NR_fstat -> __NR_fstat64
>     __NR_mmap -> __NR_mmap2
>     __NR_fadvise64 -> __NR_fadvise64_64
>
> - Since riscv32 uses fcntl64, and musl's struct flock corresponds to
> struct flock64 on 32-bit, F_GETLK, F_SETLK, and F_SETLKW should be
> defined to the corresponding *64 values (12, 13, 14). This matches
> arch/generic/bits/fcntl.h, so I think arch/riscv32/bits/fcntl.h should
> just be completely removed as Rich suggested.
> arch/riscv64/bits/fcntl.h needs to stay to define the non *64 values
> (5, 6, 7).
>
> - For detecting soft float, configure compares $ARCH to riscv and
> riscv64, but ARCH is set to riscv32 or riscv64 above. Also ARCH is set
> to riscv32 when $target is riscv* but not riscv64*. Should this be
> riscv32*?
>
> - There are several instances of preprocessor checks
> __riscv_soft_float, but this does not seem to be defined by gcc.
> Perhaps this is superseded by __riscv_flen or __riscv_float_abi_soft?
>
> - The functions in src/math/riscv* don't fall back to the C
> implementation for soft float.

Forgot to mention one other thing I found: __SYSCALL_LL_O on riscv32
is defined as if registers pairs need to be aligned for syscalls, but
that does not appear to be the case.

My proposed fixes are available here:
https://github.com/michaelforney/musl/compare/6a4f4a9...riscv

Zach van Rijn has applied those patches in his toolchains at
https://musl.cc, and Fabrice Bellard is using them in his buildroot
port at https://bellard.org/tinyemu/buildroot.html. It'd be nice to
get them applied/squashed into https://github.com/riscv/riscv-musl.

I haven't done any actual review of the port (and I don't actually
know much about riscv). I just ran into these issues while trying to
get some programs to run under linux in tinyemu.


      reply	other threads:[~2018-11-11  6:34 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-28  2:24 Rich Felker
2018-09-28  2:46 ` Rich Felker
2018-10-09 18:05   ` Rich Felker
2018-10-09 21:36     ` Michael Clark
2018-10-10  1:14       ` Khem Raj
2018-10-10  3:41         ` Michael Clark
2018-09-28  2:47 ` Rich Felker
2018-09-28  6:33   ` Michael Clark
2018-09-28  6:49     ` Michael Clark
2018-09-28 10:33     ` Szabolcs Nagy
2018-09-28 14:26       ` Rich Felker
2018-09-28 11:43 ` Szabolcs Nagy
2018-09-28 14:28   ` Rich Felker
2018-10-11  7:34 ` Michael Forney
2018-10-11 15:49   ` Rich Felker
2018-10-18 21:52   ` Michael Forney
2018-11-11  6:34     ` Michael Forney [this message]

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='CAGw6cBt97QUoMwwp5SUizG2MabtLxHK3fChG0P9=O4S+zmNE9w@mail.gmail.com' \
    --to=mforney@mforney.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).