From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12806 Path: news.gmane.org!.POSTED!not-for-mail From: Palmer Dabbelt Newsgroups: gmane.linux.lib.musl.general Subject: Re: Porting to RISC-V Date: Wed, 02 May 2018 13:45:49 -0700 (PDT) Message-ID: References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1525294140 11054 195.159.176.226 (2 May 2018 20:49:00 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 2 May 2018 20:49:00 +0000 (UTC) Cc: musl@lists.openwall.com, dbancajas@gmail.com, dalias@libc.org To: michaeljclark@mac.com Original-X-From: musl-return-12822-gllmg-musl=m.gmane.org@lists.openwall.com Wed May 02 22:48:56 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 1fDygH-0002iA-6n for gllmg-musl@m.gmane.org; Wed, 02 May 2018 22:48:53 +0200 Original-Received: (qmail 7792 invoked by uid 550); 2 May 2018 20:51:01 -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 32111 invoked from network); 2 May 2018 20:46:03 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20150623.gappssmtp.com; s=20150623; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=ePf0s544oJILQRjvDXMagszbLWtN8QkQyIEz1ozpgBY=; b=F3++dkVFdPB6shvp+06ZDUemds38tDHmnx6MFotf+jiZYll9PkNecJ34HRR5ubvV2u fpyjBbg6eCHE9jwE99XrXWVfj3JSCvv5tQr8RozxepBVLOhQ5PNgVF/OditV5gBCJWHH wp+VqmeTMDsUhQ0ui0Wa974apRsRUfMGTaK45NnrZT9QepTBRLGgdpnL0dyg2GBLVq+W qG+wAqEtX/9z2P40no5I0Tf+Alwcko6/I7cMTX3t2H9ff604+yvESV7h/aJUrJCi8dVi qX58TTtTM8EmZ07FmOUxHn0ypHBfOc3hWDmxFTW8N0cpSE0ZmE/HPI6JbCwoYmE2Sh2j ZMZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=ePf0s544oJILQRjvDXMagszbLWtN8QkQyIEz1ozpgBY=; b=OntlUVfOLB0G2tlw/nNhIHIiG9481zrxRzb8DOpCkrjOLB2upCSLDp4fvowL2oN6CD fCZ3VhTR4h0cH1iytVVKLjPntt8VgiHE+mCS2HnUALobKT7uEhK9JURkXioDrqTmb/qM JyyRtTj+f794xw7qAopg8hGB+CgMTPgusHxJENv/F46wP2+SjVAk8lCBFX66tUzHsFob TVPI3EjDEobTwOIaBbVStcEvULPljPdOEhLlY4ogxqEcIiC4RX28YOFUjr58kVDE9EM5 yVMWt1Ws6BZziYWaNvaSIbM3cMHy25xHsAK73ZaQHIC4x6QxJTFvj+al4pTdc04jiKWI h1sw== X-Gm-Message-State: ALQs6tBrLI/sBNFXwsOdCDgjFbKqpJHph8rNX2a1l5tU09DznSOF9NaJ fMqpCIwIN4zXawxXez5tWRKco9pAYaM= X-Google-Smtp-Source: AB8JxZpPEeqtsoGkYRiu0iYgo7waZq4N5VAeY0n0XekxySCmhT0Edqeq54imYDrwILi/+x4yYJnV8A== X-Received: by 2002:a17:902:a512:: with SMTP id s18-v6mr21424218plq.223.1525293950356; Wed, 02 May 2018 13:45:50 -0700 (PDT) X-Google-Original-Date: Wed, 02 May 2018 13:45:47 PDT (-0700) In-Reply-To: Xref: news.gmane.org gmane.linux.lib.musl.general:12806 Archived-At: 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’s a pointer to my fork of Aric Belsito’s tree, including 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’ve talked to Palmer Dabbelt about moving the port to the riscv github organisation retaining all of the contributor history. Typically riscv repos are prefixed with riscv- versus suffixed however that is a minor detail. We’ll need to squash the port into some more logical commits as there is quite a bit of churn in the history, however we’ll tag 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 run 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 results compared to QEMU’s linux-user emulation which may not be 100% accurate. This is easier to do now as there are several glibc based full Linux distros that can be run in QEMU RISC-V and on real hardware with networking 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-risc-v-qemu-port-is-upstream/ > > Here is the last update I sent regarding the RISC-V musl port… > > Issues fixed since picking up GSoC musl-riscv branch: > > • gcc patch to set the musl dynamic linker name (ELF interp) is upstream > • /lib/ld-musl-riscv32.so.1 (-mabi=ilp32d, default, hard float) > • /lib/ld-musl-riscv64.so.1 (-mabi=lp64d, default, hard float) > • /lib/ld-musl-riscv32-sf.so.1 (-mabi=ilp32, soft float) > • /lib/ld-musl-riscv64-sf.so.1 (-mabi=lp64, soft float) > • /lib/ld-musl-riscv32-sp.so.1 (-mabi=ilp32f, single precision) > • /lib/ld-musl-riscv64-sp.so.1 (-mabi=lp64f, single precision) > • fixed failing pthread tests. > • a_cas was deadlocking (updated a_cas in atomic_a.h, fixed missing inline asm constraint) > • defined the minimal set of atomics required by the musl library > • fixed failing sigaltstack tests (update sigaltstack and ucontext in signal.h) > • fixed failing ipc_sem tests (added struct semid_ds in sem.h) > • fixed failing stat tests (defined blksize_t and nlink_t in alltypes.h.in) > • rename sigcontext __regs to gregs so that gcc would compile > • rename _gp to __global_pointer$ in the crt to work with current binutils > • change definition of long double to quadruple precision > • update syscalls.h.in to use asm-generic syscall definitions > • update stat.h to use asm-generic stat definition > > Remaining issues: > > • rebase to current musl-libc > • audit arch/riscv32 and arch/riscv64 headers to make sure they match linux-4.16 > • check results of tests that are expected to fail (compare with other architectures) > • ELF thread local variables are not being initialised > • tls_init test is failing > > Note: riscv32 glibc is not yet upstream so the 32-bit ABI is not yet frozen. > > Rich, BTW It seems the TLS offset is directly above the thread pointer (tp). > > $ cat foo.c > __thread int i = 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.