From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/13429 Path: news.gmane.org!.POSTED!not-for-mail From: Michael Forney Newsgroups: gmane.linux.lib.musl.general Subject: Re: riscv port for review Date: Sat, 10 Nov 2018 22:34:04 -0800 Message-ID: References: <20180928022404.GQ17995@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1541917937 27496 195.159.176.226 (11 Nov 2018 06:32:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 11 Nov 2018 06:32:17 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-13445-gllmg-musl=m.gmane.org@lists.openwall.com Sun Nov 11 07:32:12 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 1gLjI2-00070A-Lw for gllmg-musl@m.gmane.org; Sun, 11 Nov 2018 07:32:10 +0100 Original-Received: (qmail 11806 invoked by uid 550); 11 Nov 2018 06:34:19 -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 11785 invoked from network); 11 Nov 2018 06:34:18 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mforney-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=NDNAZYDS3duZAOwCFn1Hu1W8aI6NFzZXL2Vg0HUz9Os=; b=HBFpQz3JEYvgacVPw7HiM8/rjDoApdXoqzFohd8+myA1fAbE2bDkI88qvxop2FuWh2 QJ6qTn+aEsmzvHfnBOTzLt0xx18OR8+cJ8pqxMzrYJUOnWuBpDmCiwLYziIvqU4JLxbT 3RSWtweGmycaKeDBDChHGmg8blTW0ifPyj+VWGmwCO/HmFxC1fsp9ckxBVU8Hlv8ONjs zhX2FNWrk875+qCc67nE+I6/xwMGmLWV5kqnRbVFvYNi1JAoDcTGNZDkIZtLnTrmhO0n uAN5gh/UGeq09cd0a7XA9D71jqlRaQQ0oZU4VbQzTxw5LJSIYGlyF9utDNRpFbT5R4GC HrWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=NDNAZYDS3duZAOwCFn1Hu1W8aI6NFzZXL2Vg0HUz9Os=; b=i2jFbUhkTEQkKJh+NpXeKKKEqSnG9PTNneOYvs/hBDfdjm45MnBQeWxCJZ73nJyy/J 2FmnWccnqpl48oyjhHkVOSe3n/DJ5q4nwuwDiNGJKLpgrOpj8AmgGQ1sO69ng3MuVFmV uulCKQ9+TvzdDe3lDLfbbD5XwfbpDVXKcg9InIKHH56qS3a9hT6oFEvmJ2XfXSPWN3c9 srlPV2S/WDDJ7INzkYgmv0pJyHohm67567cif8jIHH+dr4sBMMG13poRWyZS6MvDngBh RHxR72tu0I80QAqIBs+5RwXnRm6IvLSKTmUqrYr/kwSRbSufzTSWC67PEhqGFP2mnh8N 8ffw== X-Gm-Message-State: AGRZ1gJCb8VVu5Q14RDxuT+Th4PMOSJFVBMUz+fhFI6RkCjDlMFuFZwv DtUg27QlIjOm1ZidBRiTfT1qTDSHEffvAvNvMVXp9ATWP0o= X-Google-Smtp-Source: AJdET5eLvaifPdUiWiXFgWH2GuXMv1TeFt7juZlXwWxGwJdSAi1Fjx/2JdzxpjIc8EhpTiZfYKI7kyBgeIKzdgGgib0= X-Received: by 2002:a9d:927:: with SMTP id 36mr9677600otp.263.1541918046067; Sat, 10 Nov 2018 22:34:06 -0800 (PST) X-Originating-IP: [2601:647:5180:35d7::a50] In-Reply-To: Xref: news.gmane.org gmane.linux.lib.musl.general:13429 Archived-At: On 2018-10-18, Michael Forney wrote: > On 2018-10-11, Michael Forney wrote: >> On 2018-09-27, Rich Felker 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.