[Picolibc] Integrating Picolibc into a GCC toolchain

Keith Packard keithp at keithp.com
Mon Mar 7 20:08:06 PST 2022


"R. Diez" <rdiezmail-newlib at yahoo.de> writes:

>> Right, I'm hoping to replace *all* of the cross-compilation control
>> [...]
>
> Take a look at the newest version:
>
> https://github.com/rdiez/JtagDue/blob/master/Toolchain/Tools/GeneratePicolibcCrossFile.sh
>
> I hope the script has now everything you need.

That's looking great! I've built picolibc using your script on several
targets and it worked perfectly. I had a couple of minor suggestions
which make the command line a bit shorter by filling in some common
defaults.

This uses the first element of the target architecture for the cpu
family name by default, then can use the cpu family name for the cpu
name.

I also stuck in a few common cpu families to set the endianness value,
but that probably should just be required to be more consistent.

In any case, I'll be adding this to the picolibc scripts directory. I'll
see if I can't install it somewhere that a user could find it without
sticking it in /bin, although /bin may be the best we can manage :-)

Thanks again; this should make using picolibc take a bit less meson-fu,
and (we hope) less change as meson changes.

@@ -454,6 +454,7 @@
 
 TARGET_ARCH=""
 CPU_FAMILY_NAME=""
+CPU_NAME=""
 ENDIANNESS=""
 MESON_COMPATIBILITY=""
 
@@ -462,7 +463,6 @@
 
 # The CPU name is not really used by Meson, see:
 #   https://github.com/mesonbuild/meson/issues/7037
-CPU_NAME="unknown-cpu"
 
 parse_command_line_arguments "$@"
 
@@ -475,17 +475,30 @@
 fi
 
 if [[ $CPU_FAMILY_NAME = "" ]]; then
-  abort "Option --cpu-family is required."
+  CPU_FAMILY_NAME=`expr "$TARGET_ARCH" : '\([^-]*\)-.*'`
 fi
 
 if [[ $ENDIANNESS = "" ]]; then
-  abort "Option --endianness is required."
+  case "$CPU_FAMILY_NAME" in
+    arm*|aarch*|x86*|riscv*)
+      ENDIANNESS=little
+      ;;
+    68*|sparc*)
+      ENDIANNESS=big
+      ;;
+    *)
+      abort "Option --endianness is required."
+      ;;
+  esac
 fi
 
 if (( ${#C_COMPILER[@]} == 0)); then
   C_COMPILER+=("$TARGET_ARCH-gcc")
 fi
 
+if [[ "$CPU_NAME" = "" ]]; then
+  CPU_NAME="$CPU_FAMILY_NAME"
+fi
 
 escape_for_meson_string "$TARGET_ARCH"     "ESCAPED_TARGET_ARCH"
 escape_for_meson_string "$SYSTEM_NAME"     "ESCAPED_SYSTEM_NAME"

-- 
-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/20220308/a5da68f1/attachment.sig>


More information about the Picolibc mailing list