[Picolibc] Integrating Picolibc into a GCC toolchain

R. Diez rdiezmail-newlib at yahoo.de
Mon Jan 31 11:45:45 PST 2022


> Hrm. Maybe what picolibc should be doing is providing a script that uses
> a template to create the cross compilation file based off values
> provided by the user. We need some compilation flags, and the triplet
> describing the target machine. Maybe that's all we'd need? Once the
> script creates that file, it would run meson with the remaining flags.
> [...]

I think that is the way to go. Users should not have to know very much about Meson variables or configuration file syntax.


>> crosstool-ng-1.24.0.tar.bz2
>
> It's in scripts/build/companion_libs/340-picolibc.sh

Thanks. Apparently, that script did not make it to the latest crosstool-ng release 1.24.0, but it is in Git Master:

https://github.com/crosstool-ng/crosstool-ng/blob/master/scripts/build/companion_libs/340-picolibc.sh

Interestingly enough, that script is already outdated, for it is missing the new setting nm = 'arm-none-eabi-nm' that you mentioned. So that's why I think that such a script should be part of Picolibc.

Your script does not handle escaping/quoting correctly. I could write a Bash script with such logic.

I am wondering how to define the interface right. How about something like this?

GeneratePicolibcCrossFile.sh my-cross-arm-none-eabi.txt none arm cortex-m3 little arm-none-eabi -g -O2 ...

Or perhaps it would be easier to maintain compatibility in the face of future enhancements if we had argument names:

GeneratePicolibcCrossFile.sh \
   --output-file="my-cross-arm-none-eabi.txt" \
   --system="none" \
   --cpu-family="arm" \
   --cpu="cortex-m3" \
   --endian="little" \
   --arch="arm-none-eabi" \
   --target-cflag="-g" \
   --target-cflag="-O2" \
   --target-ldflag="-lsomelib" \
   ...

The standard CPU families are defined here and may be used:

https://mesonbuild.com/Reference-tables.html

But are the operating system name and the CPU name important as far as Meson or Picolibc are concerned?

File scripts/cross-clang-riscv64-unknown-elf.txt has one extra setting:

c_ld = '/usr/bin/riscv64-unknown-elf-ld'

Is that really needed?

Is it OK to set "needs_exe_wrapper = true" and then not set "exe_wrapper"? Your script 340-picolibc.sh does that. Can you leave both out if you just want to build Picolibc to be GCC's libc?

GNU Make makefiles have problems with spaces, and you may want to pass flags like [ -Wl,blah -g -O2 -DNAME="Computer's name" ], where some flags have quotes and spaces inside.

Perhaps it would be easier to pass CFLAGS_FOR_TARGET as an environment variable. Otherwise, specifying all settings in one or in several command-line arguments may be cumbersome or difficult inside a makefile.

What do you think?

Regards,
   rdiez


More information about the Picolibc mailing list