From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/13298 Path: news.gmane.org!.POSTED!not-for-mail From: Khem Raj Newsgroups: gmane.linux.lib.musl.general Subject: Re: Porting to RISC-V Date: Sat, 22 Sep 2018 17:55:00 -0700 Message-ID: References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1537664016 17275 195.159.176.226 (23 Sep 2018 00:53:36 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 23 Sep 2018 00:53:36 +0000 (UTC) Cc: Michael Clark , dbancajas@gmail.com, Rich Felker To: musl@lists.openwall.com Original-X-From: musl-return-13314-gllmg-musl=m.gmane.org@lists.openwall.com Sun Sep 23 02:53:31 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 1g3seQ-0004Pt-OF for gllmg-musl@m.gmane.org; Sun, 23 Sep 2018 02:53:30 +0200 Original-Received: (qmail 11835 invoked by uid 550); 23 Sep 2018 00:55:39 -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 11811 invoked from network); 23 Sep 2018 00:55:38 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=hXhJ4mpc33NfZqyeQuiOoYjIniygVuZ4Ui4B/lxC6pU=; b=ZtZklLJfbGufvErHhyzijgs01EVM5dtKmjffdeazaZMc1cC3TPWbzg83IKSYLUVKCW z2/1CB8wsHX5/8tBgza5BSSmxReNkkuRD7rC3p7Li5oUwy7sng9Er1GAyh2v/ljnQmG4 E88V7JbPu5ajy3fk+eaIyP5C4eMRTgzhnctreS/auMu/lBbMbXkRj4xT6ZPTUd9hqy0U DnO+S8AQFSmkJ4uyajSBra2BZcbH3Md/MmltiJm5Wm49GmdFsG+3scWbdwe50lI7VsVz t1oMWMDx8Rwzl4u31doxgtsVdl3XK67DKHEBWI+W7MwhwFETzF6rozDOu163A+U5gCin iVVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=hXhJ4mpc33NfZqyeQuiOoYjIniygVuZ4Ui4B/lxC6pU=; b=WG+5goGc3kX9cQtfvzZZZCj/L6TuQNE1n0m73ahhNvpSFz/Rq9Kr3hcrd8sfkerfmJ bPEqHdgL6GZjOvzCHzRm28IP+IU2Y378w3SUXu2pOOmge5AyxsuLEq2rir3GFC58V3kb sjc8JsGd2hx+IH2VtfY2xOJwBUaqR3lj1t41g7EwqrY9iMyaTah4YnDZAeT/CiQRm0x+ Nuvd6nlkksN1VyiBqGwXg56KtjzOLHp3GUoOiRMFm4ZCsk+Eh6B3RYOUEdPm2VP9Pjwg W86oor9ftT6Zis0wr3vat1AOxAElyYOYmIVp9NrPzSjUgWW9s/VUUgixhgUBAAOEp5cF PGrw== X-Gm-Message-State: ABuFfogxak+kl0OUJolcyDffC32AlCCi+Ga9MS/t8fEBm8kvztBwDFmB pHNSgbgMjQtLgzw0D8b7XJ0ujAUX6RnQYiH83zlycw== X-Google-Smtp-Source: ACcGV61ijD8pMGiQI9ESZRMdyyFcBN1uAt/7x9vVIcV39oWc1fmnXHPTYpDkvjl9+EwTvt3mR82AL1ZFxOp1Kw4lnps= X-Received: by 2002:a0c:ef0a:: with SMTP id t10-v6mr2691703qvr.194.1537664126711; Sat, 22 Sep 2018 17:55:26 -0700 (PDT) In-Reply-To: Xref: news.gmane.org gmane.linux.lib.musl.general:13298 Archived-At: Hi Palmer I think move it to riscv github handle and then I can help with upstreaming in 1.21 timeframe. Thanks -Khem On Wed, May 2, 2018 at 1:51 PM Palmer Dabbelt wrote: > > On Wed, 02 May 2018 13:37:13 PDT (-0700), michaeljclark@mac.com wrote: > > > > > >> On 3/05/2018, at 7:45 AM, Rich Felker wrote: > >> > >> On Wed, May 02, 2018 at 03:40:04PM -0400, Dean Michael Ancajas wrote: > >>> Can you send a link of the wiki? > >> > >> https://wiki.musl-libc.org/ > >> https://wiki.musl-libc.org/porting.html > > > > Here=E2=80=99s a pointer to my fork of Aric Belsito=E2=80=99s tree, inc= luding several fixes to get threads and atomics passing libc-tests. > > > > - https://github.com/michaeljclark/musl-riscv > > > > This is the list of contributors as far as I know, but I might have to = do a deeper inspection of the git history: > > > > Aric Belsito > > Alex Suykov > > Michael Clark > > > > I=E2=80=99ve talked to Palmer Dabbelt about moving the port to the risc= v github organisation retaining all of the contributor history. Typically r= iscv repos are prefixed with riscv- versus suffixed however that is a minor= detail. We=E2=80=99ll need to squash the port into some more logical commi= ts as there is quite a bit of churn in the history, however we=E2=80=99ll t= ag the repo in its current state to keep the contributor history. > > I can move it whenever you want. > > > Threads and mutexes are working. I need to sync with latest musl and ru= n libc-tests again and we need to run the tests in RISC-V Linux versus RISC= -V QEMU linux-user. Running against linux-kernel will give more accurate re= sults compared to QEMU=E2=80=99s linux-user emulation which may not be 100%= accurate. This is easier to do now as there are several glibc based full L= inux distros that can be run in QEMU RISC-V and on real hardware with netwo= rking and block storage. i.e. we can rsync binaries in over ssh in the QEMU= virt machine. Indeed folk have been running self-hosted GCC bootstraps in = the Fedora RISC-V port which has toolchain packages. Now there is a Debian = port, and iirc there may even be a SUSE port (Palmer?) > > > > Here is some recent info on QEMU for RISC-V, which might help with the = porting effort: > > > > - https://github.com/riscv/riscv-qemu/wiki > > - https://www.sifive.com/blog/2018/04/25/risc-v-qemu-part-2-the-r= isc-v-qemu-port-is-upstream/ > > > > Here is the last update I sent regarding the RISC-V musl port=E2=80=A6 > > > > Issues fixed since picking up GSoC musl-riscv branch: > > > > =E2=80=A2 gcc patch to set the musl dynamic linker name (ELF inte= rp) is upstream > > =E2=80=A2 /lib/ld-musl-riscv32.so.1 (-mabi=3Dilp32d, defa= ult, hard float) > > =E2=80=A2 /lib/ld-musl-riscv64.so.1 (-mabi=3Dlp64d, defau= lt, hard float) > > =E2=80=A2 /lib/ld-musl-riscv32-sf.so.1 (-mabi=3Dilp32, so= ft float) > > =E2=80=A2 /lib/ld-musl-riscv64-sf.so.1 (-mabi=3Dlp64, sof= t float) > > =E2=80=A2 /lib/ld-musl-riscv32-sp.so.1 (-mabi=3Dilp32f, s= ingle precision) > > =E2=80=A2 /lib/ld-musl-riscv64-sp.so.1 (-mabi=3Dlp64f, si= ngle precision) > > =E2=80=A2 fixed failing pthread tests. > > =E2=80=A2 a_cas was deadlocking (updated a_cas in atomic_= a.h, fixed missing inline asm constraint) > > =E2=80=A2 defined the minimal set of atomics required by = the musl library > > =E2=80=A2 fixed failing sigaltstack tests (update sigaltstack and= ucontext in signal.h) > > =E2=80=A2 fixed failing ipc_sem tests (added struct semid_ds in s= em.h) > > =E2=80=A2 fixed failing stat tests (defined blksize_t and nlink_t= in alltypes.h.in) > > =E2=80=A2 rename sigcontext __regs to gregs so that gcc would com= pile > > =E2=80=A2 rename _gp to __global_pointer$ in the crt to work with= current binutils > > =E2=80=A2 change definition of long double to quadruple precision > > =E2=80=A2 update syscalls.h.in to use asm-generic syscall definit= ions > > =E2=80=A2 update stat.h to use asm-generic stat definition > > > > Remaining issues: > > > > =E2=80=A2 rebase to current musl-libc > > =E2=80=A2 audit arch/riscv32 and arch/riscv64 headers to make sur= e they match linux-4.16 > > =E2=80=A2 check results of tests that are expected to fail (compa= re with other architectures) > > =E2=80=A2 ELF thread local variables are not being initialised > > =E2=80=A2 tls_init test is failing > > > > Note: riscv32 glibc is not yet upstream so the 32-bit ABI is not yet fr= ozen. > > > > Rich, BTW It seems the TLS offset is directly above the thread pointer = (tp). > > > > $ cat foo.c > > __thread int i =3D 42; > > > > void foo() > > { > > i++; > > } > > > > 0000000000010226 : > > 10226: 00022703 lw a4,0(tp) # 0 > > 1022a: 2705 addiw a4,a4,1 > > 1022c: 00e22023 sw a4,0(tp) # 0 > > 10230: 8082 ret > > > > 0000000000010a7a <__set_thread_area>: > > 10a7a: 822a mv tp,a0 > > 10a7c: 4501 li a0,0 > > 10a7e: 8082 ret > > > > Michael.