[Picolibc] meson and ninja

Keith Packard keithp at keithp.com
Tue Apr 28 13:57:10 PDT 2020


Larry Doolittle <ldoolitt at recycle.lbl.gov> writes:

> Despite decades of *nix experience, picolibc represents the first time I've
> had to deal with meson+ninja.  This may therefore count as a noob question.

I switched to meson mostly so that the build system changes necessary
for picolibc didn't conflict with newlib build system bits. Once I
discovered how much faster it was to build with meson, I was willing to
suffer a bit of pain learning a new system. The Meson developers have
been helpful, although there's still some work left undone that you've
discovered.

> My target is riscv32-unknown-elf.  I've built toolchains for it many times.
> Right now I have both gcc-8.3.0 and gcc-9.3.0 running nicely with newlib
> (3.1.0 and 3.3.0, respectively), running the resulting code on picorv32.
> Picolibc sounds pretty cool, and I thought I should give it a spin.

Awesome! I work on picolibc for SiFive, so RISC-V is a key
architecture.

> I don't see any hints in README.md about what versions of meson are
> valid.

The meson.build file says >= 0.50. Meson *should* complain about having
the wrong version when you try to run it, but ...

> Switching to 0.54.1 from PIP, I get a boatload
> of warnings like
>   Target "rv64imafdc_lp64d/posix-io" has a path separator in its name.
> but can at least progress to the ninja step.

Yeah, I'm working with upstream meson to sort out how to get meson to
build picolibc in a way that makes them happy. For now, you get a lot of
warnings, but it does work.

> Is there a supported way to force meson to use a non-automatic 
> architecture list?  All I'm really intersted in is
> rv32im/ilp32;@march=rv32im at mabi=ilp32
> rv32imc/ilp32;@march=rv32imc at mabi=ilp32

You can build for a single architecture, but there's no current way to
specify a shorter list of architectures. So, if you only need these two,
you could just build both of them separately. I've included a shell
script and cross compile configuration file that builds for rv32imac;
feel free to edit this as you like.

If you think it would be useful, I could add a way to specify a subset
of the desired architectures.

-------------- next part --------------
#!/bin/sh
#
# SPDX-License-Identifier: BSD-3-Clause
#
# Copyright ? 2019 Keith Packard
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above
#    copyright notice, this list of conditions and the following
#    disclaimer in the documentation and/or other materials provided
#    with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
#    contributors may be used to endorse or promote products derived
#    from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
# OF THE POSSIBILITY OF SUCH DAMAGE.
#
ARCH=riscv64-unknown-elf
DIR=`dirname $0`
meson "$DIR" \
	-Dtests=true \
	-Dmultilib=false \
	-Dincludedir=picolibc/$ARCH/include \
	-Dlibdir=picolibc/$ARCH/lib \
	--cross-file "$DIR"/cross-rv32imac.txt \
	"$@"
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cross-rv32imac.txt
URL: <http://keithp.com/pipermail/picolibc/attachments/20200428/100daa5b/attachment.txt>
-------------- next part --------------

-- 
-keith
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://keithp.com/pipermail/picolibc/attachments/20200428/100daa5b/attachment.sig>


More information about the Picolibc mailing list