@@ -5,6 +5,7 @@ INSTALL_DIR := @prefix@
55GCC_SRCDIR := @with_gcc_src@
66BINUTILS_SRCDIR := @with_binutils_src@
77NEWLIB_SRCDIR := @with_newlib_src@
8+ PICOLIBC_SRCDIR := @with_picolibc_src@
89GLIBC_SRCDIR := @with_glibc_src@
910MUSL_SRCDIR := @with_musl_src@
1011LINUX_HEADERS_SRCDIR := @with_linux_headers_src@
@@ -59,9 +60,11 @@ MULTILIB_FLAGS := @multilib_flags@
5960MULTILIB_GEN := @multilib_gen@
6061ifeq ($(MULTILIB_GEN ) ,)
6162NEWLIB_MULTILIB_NAMES := @newlib_multilib_names@
63+ PICOLIBC_MULTILIB_NAMES := @picolibc_multilib_names@
6264GCC_MULTILIB_FLAGS := $(MULTILIB_FLAGS )
6365else
6466NEWLIB_MULTILIB_NAMES := $(shell echo "$(MULTILIB_GEN ) " | $(SED ) 's/;/\n/g'| $(AWK ) '{split($$0,a,"-") ; printf "%s-%s ", a[1],a[2]}')
67+ PICOLIBC_MULTILIB_NAMES := $(shell echo "$(MULTILIB_GEN ) " | $(SED ) 's/;/\n/g'| $(AWK ) '{split($$0,a,"-") ; printf "%s-%s ", a[1],a[2]}')
6568GCC_MULTILIB_FLAGS := $(MULTILIB_FLAGS ) --with-multilib-generator="$(MULTILIB_GEN ) "
6669endif
6770GLIBC_MULTILIB_NAMES := @glibc_multilib_names@
7578make_tuple = riscv$(1 ) -unknown-$(2 )
7679LINUX_TUPLE ?= $(call make_tuple,$(XLEN ) ,linux-gnu)
7780NEWLIB_TUPLE ?= $(call make_tuple,$(XLEN ) ,elf)
81+ PICOLIBC_TUPLE ?= $(call make_tuple,$(XLEN ) ,elf)
7882MUSL_TUPLE ?= $(call make_tuple,$(XLEN ) ,linux-musl)
7983
8084CFLAGS_FOR_TARGET := $(CFLAGS_FOR_TARGET_EXTRA ) @target_cflags@ @cmodel@
@@ -96,6 +100,10 @@ NEWLIB_CXX_FOR_TARGET ?= $(NEWLIB_TUPLE)-g++
96100NEWLIB_TARGET_BOARDS ?= $(shell echo "$(NEWLIB_MULTILIB_NAMES ) " | sed 's!\([_a-z0-9]* \) -\([_a-z0-9]*\)!riscv-sim/-march=\1/-mabi=\2/@cmodel@!g')
97101NEWLIB_NANO_TARGET_BOARDS ?= $(shell echo "$(NEWLIB_MULTILIB_NAMES ) " | sed 's!\([_a-z0-9]* \) -\([_a-z0-9]*\)!riscv-sim-nano/-march=\1/-mabi=\2/@cmodel@!g')
98102
103+ PICOLIBC_CC_FOR_TARGET ?= $(PICOLIBC_TUPLE ) -gcc
104+ PICOLIBC_CXX_FOR_TARGET ?= $(PICOLIBC_TUPLE ) -g++
105+ PICOLIBC_TARGET_BOARDS ?= $(shell echo "$(PICOLIBC_MULTILIB_NAMES ) " | sed 's!\([_a-z0-9]* \) -\([_a-z0-9]*\)!riscv-sim/-march=\1/-mabi=\2/@cmodel@!g')
106+
99107MUSL_TARGET_FLAGS := $(MUSL_TARGET_FLAGS_EXTRA )
100108MUSL_CC_FOR_TARGET ?= $(MUSL_TUPLE ) -gcc
101109MUSL_CXX_FOR_TARGET ?= $(MUSL_TUPLE ) -g++
@@ -104,6 +112,7 @@ CONFIGURE_HOST = @configure_host@
104112
105113all : @default_target@
106114newlib : stamps/build-gcc-newlib-stage2
115+ picolibc : stamps/build-gcc-picolibc-stage2
107116linux : stamps/build-gcc-linux-stage2
108117ifneq (,$(findstring riscv32,$(MUSL_TUPLE ) ) )
109118.PHONY : musl
@@ -114,6 +123,7 @@ musl: stamps/build-gcc-musl-stage2
114123endif
115124ifeq (@enable_gdb@,--enable-gdb)
116125newlib : stamps/build-gdb-newlib
126+ picolibc : stamps/build-gdb-picolibc
117127linux : stamps/build-gdb-linux
118128endif
119129linux-native : stamps/build-gcc-linux-native
@@ -125,33 +135,40 @@ build-gcc%: stamps/build-gcc-@default_target@-stage%
125135ifeq (@default_target@,linux)
126136build-libc : $(addprefix stamps/build-glibc-linux-,$(GLIBC_MULTILIB_NAMES ) )
127137else
138+ ifeq (@default_target@,picolibc)
139+ build-libc : stamps/build-picolibc
140+ else
128141build-libc : stamps/build-newlib stamps/build-newlib-nano \
129142 stamps/merge-newlib-nano
130143endif
144+ endif
131145build-qemu : stamps/build-qemu
132146
133147REGRESSION_TEST_LIST = gcc
134148
135149.PHONY : check
136150check : check-@default_target@
137- .PHONY : check-linux check-newlib
151+ .PHONY : check-linux check-newlib check-picolibc
138152check-linux : $(patsubst % ,check-% -linux,$(REGRESSION_TEST_LIST ) )
139153check-newlib : $(patsubst % ,check-% -newlib,$(REGRESSION_TEST_LIST ) )
140154check-newlib-nano : $(patsubst % ,check-% -newlib-nano,$(REGRESSION_TEST_LIST ) )
141- .PHONY : check-gcc check-gcc-linux check-gcc-newlib check-gcc-newlib-nano
155+ check-picolibc : $(patsubst % ,check-% -picolibc,$(REGRESSION_TEST_LIST ) )
156+ .PHONY : check-gcc check-gcc-linux check-gcc-newlib check-gcc-newlib-nano check-gcc-picolibc
142157check-gcc : check-gcc-@default_target@
143158check-gcc-linux : stamps/check-gcc-linux
144159check-gcc-newlib : stamps/check-gcc-newlib
145160check-gcc-newlib-nano : stamps/check-gcc-newlib-nano
161+ check-gcc-picolibc : stamps/check-gcc-picolibc
146162.PHONY : check-glibc-linux
147163check-glibc-linux : $(addprefix stamps/check-glibc-linux-,$(GLIBC_MULTILIB_NAMES ) )
148164.PHONY : check-dhrystone check-dhrystone-linux check-dhrystone-newlib
149165check-dhrystone : check-dhrystone-@default_target@
150- .PHONY : check-binutils check-binutils-linux check-binutils-newlib
166+ .PHONY : check-binutils check-binutils-linux check-binutils-newlib check-binutils-picolibc
151167check-binutils : check-binutils-@default_target@
152168check-binutils-linux : stamps/check-binutils-linux
153169check-binutils-newlib : stamps/check-binutils-newlib
154170check-binutils-newlib-nano : stamps/check-binutils-newlib-nano
171+ check-binutils-picolibc : stamps/check-binutils-picolibc
155172.PHONY : check-gdb check-gdb-linux check-gdb-newlib
156173check-gdb : check-gdb-@default_target@
157174check-gdb-linux : stamps/check-gdb-linux
@@ -688,6 +705,119 @@ stamps/build-gcc-newlib-stage2: $(GCC_SRCDIR) $(GCC_SRC_GIT) stamps/build-newlib
688705 $(MAKE ) -C $(notdir $@ ) install
689706 mkdir -p $(dir $@ ) && touch $@
690707
708+ #
709+ # PICOLIBC
710+ #
711+
712+ stamps/build-binutils-picolibc : $(BINUTILS_SRCDIR ) $(BINUTILS_SRC_GIT ) stamps/check-write-permission
713+ rm -rf $@ $(notdir $@ )
714+ mkdir $(notdir $@ )
715+ # CC_FOR_TARGET is required for the ld testsuite.
716+ cd $(notdir $@) && CC_FOR_TARGET=$(PICOLIBC_CC_FOR_TARGET) $</configure \
717+ --target=$(PICOLIBC_TUPLE) \
718+ $(CONFIGURE_HOST) \
719+ --prefix=$(INSTALL_DIR) \
720+ @with_guile@ \
721+ --disable-werror \
722+ $(BINUTILS_TARGET_FLAGS) \
723+ --disable-gdb \
724+ --disable-sim \
725+ --disable-libdecnumber \
726+ --disable-readline \
727+ $(WITH_ISA_SPEC)
728+ $(MAKE) -C $(notdir $@)
729+ $(MAKE) -C $(notdir $@) install
730+ mkdir -p $(dir $@) && touch $@
731+
732+ stamps/build-gdb-picolibc : $(GDB_SRCDIR ) $(GDB_SRC_GIT )
733+ rm -rf $@ $(notdir $@ )
734+ mkdir $(notdir $@ )
735+ # CC_FOR_TARGET is required for the ld testsuite.
736+ cd $(notdir $@) && CC_FOR_TARGET=$(PICOLIBC_CC_FOR_TARGET) $</configure \
737+ --target=$(PICOLIBC_TUPLE) \
738+ $(CONFIGURE_HOST) \
739+ --prefix=$(INSTALL_DIR) \
740+ @with_guile@ \
741+ --disable-werror \
742+ $(GDB_TARGET_FLAGS) \
743+ --enable-gdb \
744+ --disable-gas \
745+ --disable-binutils \
746+ --disable-ld \
747+ --disable-gold \
748+ --disable-gprof
749+ $(MAKE) -C $(notdir $@)
750+ $(MAKE) -C $(notdir $@) install
751+ mkdir -p $(dir $@) && touch $@
752+
753+ GCC_PICOLIBC_ARGS = \
754+ --target=$(PICOLIBC_TUPLE ) \
755+ $(CONFIGURE_HOST ) \
756+ --disable-wchar_t \
757+ --prefix=$(INSTALL_DIR ) \
758+ --disable-shared \
759+ --disable-threads \
760+ --enable-languages=c,c++ \
761+ --with-pkgversion="$(GCCPKGVER ) " \
762+ @with_system_zlib@ \
763+ --enable-tls \
764+ --with-newlib \
765+ --with-sysroot=$(INSTALL_DIR ) /$(PICOLIBC_TUPLE ) \
766+ --disable-libmudflap \
767+ --disable-libssp \
768+ --disable-libquadmath \
769+ --disable-libgomp \
770+ --disable-nls \
771+ --disable-tm-clone-registry \
772+ --src=$(gccsrcdir ) \
773+ $(GCC_CHECKING_FLAGS ) \
774+ $(GCC_MULTILIB_FLAGS ) \
775+ $(WITH_ABI ) \
776+ $(WITH_ARCH ) \
777+ $(WITH_TUNE ) \
778+ $(WITH_ISA_SPEC ) \
779+ CFLAGS_FOR_TARGET="-Os $(CFLAGS_FOR_TARGET ) " \
780+ CXXFLAGS_FOR_TARGET="-Os $(CXXFLAGS_FOR_TARGET ) "
781+
782+ stamps/build-gcc-picolibc-stage1 : $(GCC_SRCDIR ) $(GCC_SRC_GIT ) stamps/build-binutils-picolibc
783+ if test -f $< /contrib/download_prerequisites && test " @NEED_GCC_EXTERNAL_LIBRARIES@" = " true" ; then cd $< && ./contrib/download_prerequisites; fi
784+ rm -rf $@ $(notdir $@ )
785+ mkdir $(notdir $@ )
786+ cd $(notdir $@ ) && $< /configure $(GCC_PICOLIBC_ARGS )
787+ $(MAKE ) -C $(notdir $@ ) all-gcc
788+ $(MAKE ) -C $(notdir $@ ) install-gcc
789+ mkdir -p $(dir $@ ) && touch $@
790+
791+ stamps/build-picolibc : $(PICOLIBC_SRCDIR ) $(PICOLIBC_SRC_GIT ) stamps/build-gcc-picolibc-stage1 picolibc-cross.txt
792+ rm -rf $@ $(notdir $@ )
793+ mkdir $(notdir $@ )
794+ meson setup --cross-file picolibc-cross.txt \
795+ --prefix=$(INSTALL_DIR ) /$(PICOLIBC_TUPLE ) \
796+ -Dincludedir=include \
797+ -Dlibdir=lib \
798+ -Dsysroot-install=true \
799+ -Dsystem-libc=true \
800+ $(PICOLIBC_SRCDIR ) \
801+ $(notdir $@ )
802+ ninja -C $(notdir $@ ) install
803+ mkdir -p $(dir $@ ) && touch $@
804+
805+ picolibc-cross.txt : make-picolibc-cross Makefile
806+ sh ./make-picolibc-cross $(INSTALL_DIR ) /bin/$(PICOLIBC_TUPLE ) -Os $(CFLAGS_FOR_TARGET ) > $@
807+
808+ stamps/build-gcc-picolibc-stage2 : $(GCC_SRCDIR ) $(GCC_SRC_GIT ) stamps/build-picolibc
809+ rm -rf $@ $(notdir $@ )
810+ mkdir $(notdir $@ )
811+ cd $(notdir $@ ) && $< /configure \
812+ $(GCC_PICOLIBC_ARGS ) \
813+ --enable-stdio=stdio_pure \
814+ --with-default-libc=picolibc \
815+ --with-native-system-header-dir=/include
816+ $(MAKE ) -C $(notdir $@ )
817+ $(MAKE ) -C $(notdir $@ ) install
818+ mkdir -p $(dir $@ ) && touch $@
819+
820+
691821#
692822# MUSL
693823#
@@ -888,6 +1018,12 @@ stamps/check-gcc-newlib-nano: stamps/build-gcc-newlib-stage2 $(SIM_STAMP) stamps
8881018 mkdir -p $(dir $@ )
8891019 date > $@
8901020
1021+ stamps/check-gcc-picolibc : stamps/build-gcc-picolibc-stage2 stamps/build-qemu
1022+ cd build-picolibc && meson configure -Dtests=true
1023+ ninja -C build-picolibc test
1024+ mkdir -p $(dir $@ )
1025+ date > $@
1026+
8911027stamps/check-gcc-linux : stamps/build-gcc-linux-stage2 $(SIM_STAMP ) stamps/build-dejagnu
8921028 $(SIM_PREPARE ) $(MAKE ) -C build-gcc-linux-stage2 check-gcc " RUNTESTFLAGS=$( RUNTESTFLAGS) --target_board='$( GLIBC_TARGET_BOARDS) '"
8931029 mkdir -p $(dir $@ )
@@ -942,6 +1078,10 @@ stamps/check-binutils-newlib-nano: stamps/build-gcc-newlib-stage2 $(SIM_STAMP) s
9421078 $(SIM_PREPARE ) $(MAKE ) -C build-binutils-newlib check-binutils check-gas check-ld -k " RUNTESTFLAGS=--target_board='$( NEWLIB_NANO_TARGET_BOARDS) '" || true
9431079 date > $@
9441080
1081+ stamps/check-binutils-picolibc : stamps/build-gcc-picolibc-stage2 $(SIM_STAMP ) stamps/build-dejagnu
1082+ $(SIM_PREPARE ) $(MAKE ) -C build-binutils-picolibc check-binutils check-gas check-ld -k " RUNTESTFLAGS=--target_board='$( PICOLIBC_TARGET_BOARDS) '" || true
1083+ date > $@
1084+
9451085stamps/check-binutils-linux : stamps/build-gcc-linux-stage2 $(SIM_STAMP ) stamps/build-dejagnu
9461086 $(SIM_PREPARE ) $(MAKE ) -C build-binutils-linux check-binutils check-gas check-ld -k " RUNTESTFLAGS=--target_board='$( GLIBC_TARGET_BOARDS) '" || true
9471087 date > $@
@@ -990,14 +1130,20 @@ report-binutils-newlib-nano: stamps/check-binutils-newlib-nano
9901130 $(srcdir ) /test/allowlist \
9911131 ` find build-binutils-newlib/ -name * .sum | paste -sd " ," -`
9921132
1133+ .PHONY : report-binutils-picolibc
1134+ report-binutils-picolibc : stamps/check-binutils-picolibc
1135+ $(srcdir ) /scripts/testsuite-filter binutils picolibc \
1136+ $(srcdir ) /test/allowlist \
1137+ ` find build-binutils-picolibc/ -name * .sum | paste -sd " ," -`
1138+
9931139.PHONY : report-binutils-linux
9941140report-binutils-linux : stamps/check-binutils-linux
9951141 $(srcdir ) /scripts/testsuite-filter binutils glibc \
9961142 $(srcdir ) /test/allowlist \
9971143 ` find build-binutils-linux/ -name * .sum | paste -sd " ," -`
9981144
9991145clean :
1000- rm -rf build-* stamps install-newlib-nano
1146+ rm -rf build-* stamps install-newlib-nano picolibc-cross.txt
10011147
10021148.PHONY : report-gdb-newlib report-gdb-newlib-nano
10031149report-gdb-newlib : stamps/check-gdb-newlib
0 commit comments