From b40cacaf469728fe59b161b1caa5eb078091a756 Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 18 Mar 2016 23:37:09 +0100 Subject: [PATCH] Get the pcc ARM backend building. --HG-- branch : default-branch --- Makefile | 6 +- first/core.mk | 2 +- lang/pcc/build.mk | 96 +++++++++++++++++++++ lang/pcc/config.h | 188 +++++++++++++++++++++++++++++++++++++++++ man/powerpc_as.6 | 25 ++++++ plat/build.mk | 9 ++ plat/linuxarm/build.mk | 9 ++ 7 files changed, 332 insertions(+), 3 deletions(-) create mode 100644 lang/pcc/build.mk create mode 100644 lang/pcc/config.h create mode 100644 man/powerpc_as.6 create mode 100644 plat/linuxarm/build.mk diff --git a/Makefile b/Makefile index dbac9cabd..98922cd25 100644 --- a/Makefile +++ b/Makefile @@ -91,6 +91,7 @@ include lang/cem/build.mk include lang/basic/build.mk include lang/pc/build.mk include lang/m2/build.mk +include lang/pcc/build.mk include mach/proto/as/build.mk include mach/proto/ncg/build.mk @@ -102,7 +103,7 @@ include mach/i80/build.mk include mach/i386/build.mk include mach/i86/build.mk include mach/m68020/build.mk -# include mach/powerpc/build.mk +include mach/powerpc/build.mk include mach/vc4/build.mk include plat/build.mk @@ -110,7 +111,8 @@ include plat/pc86/build.mk include plat/cpm/build.mk include plat/linux386/build.mk include plat/linux68k/build.mk -# include plat/linuxppc/build.mk +#include plat/linuxppc/build.mk +include plat/linuxarm/build.mk include plat/rpi/build.mk .PHONY: installables diff --git a/first/core.mk b/first/core.mk index 6c386d0f5..b9d943414 100644 --- a/first/core.mk +++ b/first/core.mk @@ -14,8 +14,8 @@ define cfile-rule $o: $s @echo CC $o @mkdir -p $(dir $o) - @$(CC) $(CFLAGS) $(cflags) -MM -MQ $o -o $d $s $(hide) $(CC) $(CFLAGS) $(cflags) -c -o $o $s + @$(CC) $(CFLAGS) $(cflags) -MM -MQ $o -o $d $s endef define cfile diff --git a/lang/pcc/build.mk b/lang/pcc/build.mk new file mode 100644 index 000000000..cc932addf --- /dev/null +++ b/lang/pcc/build.mk @@ -0,0 +1,96 @@ +D := lang/pcc + +define pcc-cfile-impl + $(call cfile, $1) + $(call dependson, $(OBJDIR)/$D/external.h) +endef +pcc-cfile = $(eval $(pcc-cfile-impl)) + +define build-pcc-impl + +$(eval pcc-cflags = \ + -Ilang/pcc \ + -I$(OBJDIR)/$D \ + -Ilang/pcc/pcc/common \ + -Ilang/pcc/pcc/mip \ + -Ilang/pcc/pcc/cc/ccom \ + -Ilang/pcc/pcc/arch/$(PCCARCH) \ + -D_DEFAULT_SOURCE \ + -DGCC_COMPAT \ + -DPCC_DEBUG \ + -DNATIVE_FLOATING_POINT \ + -D_ISOC99_SOURCE \ + -Dos_ack \ + -Dmach_$(PCCMACH) \ +) + +$(call reset) +$(eval cflags += $(pcc-cflags)) + +$(call pcc-cfile, $(OBJDIR)/$D/external.c) +$(call pcc-cfile, lang/pcc/pcc/arch/$(PCCARCH)/code.c) +$(call pcc-cfile, lang/pcc/pcc/arch/$(PCCARCH)/local.c) +$(call pcc-cfile, lang/pcc/pcc/arch/$(PCCARCH)/local2.c) +$(call pcc-cfile, lang/pcc/pcc/arch/$(PCCARCH)/order.c) +$(call pcc-cfile, lang/pcc/pcc/arch/$(PCCARCH)/table.c) +$(call pcc-cfile, lang/pcc/pcc/cc/ccom/builtins.c) +$(call pcc-cfile, lang/pcc/pcc/cc/ccom/dwarf.c) +$(call pcc-cfile, lang/pcc/pcc/cc/ccom/init.c) +$(call pcc-cfile, lang/pcc/pcc/cc/ccom/inline.c) +$(call pcc-cfile, lang/pcc/pcc/cc/ccom/main.c) +$(call pcc-cfile, lang/pcc/pcc/cc/ccom/optim.c) +$(call pcc-cfile, lang/pcc/pcc/cc/ccom/stabs.c) +$(call pcc-cfile, lang/pcc/pcc/cc/ccom/symtabs.c) +$(call pcc-cfile, lang/pcc/pcc/cc/ccom/trees.c) +$(call pcc-cfile, lang/pcc/pcc/common/compat.c) +$(call pcc-cfile, lang/pcc/pcc/common/unicode.c) +$(call pcc-cfile, lang/pcc/pcc/mip/common.c) +$(call pcc-cfile, lang/pcc/pcc/mip/match.c) +$(call pcc-cfile, lang/pcc/pcc/mip/optim2.c) +$(call pcc-cfile, lang/pcc/pcc/mip/reader.c) +$(call pcc-cfile, lang/pcc/pcc/mip/regs.c) + +$(call pcc-cfile, lang/pcc/pcc/cc/ccom/gcc_compat.c) +$(call dependson, $(OBJDIR)/$D/cgram.h) + +$(call pcc-cfile, lang/pcc/pcc/cc/ccom/pftn.c) +$(call dependson, $(OBJDIR)/$D/cgram.h) + +$(call yacc, $(OBJDIR)/$D, lang/pcc/pcc/cc/ccom/cgram.y) + +$(call flex, $(OBJDIR)/$D, lang/pcc/pcc/cc/ccom/scan.l) +$(call dependson, $(OBJDIR)/$D/cgram.h) + +$(call cprogram, $(BINDIR)/$(PLATFORM)/pcc_ccom) +$(call installto, $(PLATDEP)/$(PLATFORM)/pcc_ccom) + + +$(call reset) +$(call rawfile, $(OBJDIR)/$D/y.tab.h) +$(call installto, $(OBJDIR)/$D/cgram.h) + + +$(call reset) +$(eval cflags += $(pcc-cflags)) + + +$(call reset) +$(eval objdir := mkext) +$(eval cflags += $(pcc-cflags) -DMKEXT) +$(call cfile, lang/pcc/pcc/mip/mkext.c) +$(call cfile, lang/pcc/pcc/mip/common.c) +$(call cfile, lang/pcc/pcc/arch/$(PCCARCH)/table.c) +$(call cprogram, $(OBJDIR)/$D/mkext) +$(eval pcc_mkext := $o) + +$(OBJDIR)/$D/external.h: $(OBJDIR)/$D/external.c +$(OBJDIR)/$D/external.c: $(pcc_mkext) + @echo MKEXT + @mkdir -p $$(dir $$@) + $(hide) (cd $$(dir $$@) && $(pcc_mkext)) + +endef + + +build-pcc = $(eval $(build-pcc-impl)) + diff --git a/lang/pcc/config.h b/lang/pcc/config.h new file mode 100644 index 000000000..72b011c00 --- /dev/null +++ b/lang/pcc/config.h @@ -0,0 +1,188 @@ +/* config.h. Generated MANUALLY (but based on Debian's autoconf result). */ + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* Using a.out ABI */ +/* #undef AOUTABI */ + +/* Define path to alternate assembler */ +/* #undef ASSEMBLER */ + +/* Using Classic 68k ABI */ +/* #undef CLASSIC68K */ + +/* Using COFF ABI */ +/* #undef COFFABI */ + +/* Define path to alternate compiler */ +/* #undef COMPILER */ + +/* Using ECOFF ABI */ +/* #undef ECOFFABI */ + +/* Using ELF ABI */ +#define ELFABI 1 + +/* Define to 1 if printf supports C99 size specifiers */ +#define HAVE_C99_FORMAT 1 + +/* Define to 1 if you have the `ffs' function. */ +#define HAVE_FFS 1 + +/* Define to 1 if you have the `getopt' function. */ +#define HAVE_GETOPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LIBGEN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MALLOC_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mkstemp' function. */ +#define HAVE_MKSTEMP 1 + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strlcat' function. */ +/* #undef HAVE_STRLCAT */ + +/* Define to 1 if you have the `strlcpy' function. */ +/* #undef HAVE_STRLCPY */ + +/* Define to 1 if you have the `strtold' function. */ +#define HAVE_STRTOLD 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have that is POSIX.1 compatible. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `vfork' function. */ +#define HAVE_VFORK 1 + +/* Define to 1 if you have the `vsnprintf' function. */ +#define HAVE_VSNPRINTF 1 + +/* Define if host is BIG endian */ +/* #undef HOST_BIG_ENDIAN */ + +/* Define if host is LITTLE endian */ +#define HOST_LITTLE_ENDIAN 1 + +/* Define alternate standard lib directory */ +/* #undef LIBDIR */ + +/* Define path to alternate linker */ +/* #undef LINKER */ + +/* Using Mach-O ABI */ +/* #undef MACHOABI */ + +/* Define target Multi-Arch path */ +#define MULTIARCH_PATH "x86_64-linux-gnu" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "pcc@lists.ludd.ltu.se" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "Portable C Compiler" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "Portable C Compiler 1.2.0.DEVEL" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "pcc" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "http://pcc.ludd.ltu.se/" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "1.2.0.DEVEL" + +/* Major version no */ +#define PCC_MAJOR 1 + +/* Minor version no */ +#define PCC_MINOR 2 + +/* Minor minor version no */ +#define PCC_MINORMINOR 0 + +/* Using PE/COFF ABI */ +/* #undef PECOFFABI */ + +/* Define path to alternate preprocessor */ +/* #undef PREPROCESSOR */ + +/* Enable STABS debugging output */ +#define STABS 1 + +/* Enable DWARF debugging output */ +/* #undef DWARF */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define alternate standard include directory */ +/* #undef STDINC */ + +/* Define if target defaults to BIG endian */ +/* #undef TARGET_BIG_ENDIAN */ + +/* Define if target defaults to LITTLE endian */ +#define TARGET_LITTLE_ENDIAN 1 + +/* Enable thread-local storage (TLS). */ +/* #undef TLS */ + +/* Version string */ +#define VERSSTR "Portable C Compiler 1.2.0.DEVEL 20160315 for x86_64-unknown-linux-gnu" + +/* Size of wide-character type in chars */ +#define WCHAR_SIZE 4 + +/* Type to use for wide characters */ +#define WCHAR_TYPE INT + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a + `char[]'. */ +#define YYTEXT_POINTER 1 diff --git a/man/powerpc_as.6 b/man/powerpc_as.6 new file mode 100644 index 000000000..d85167c69 --- /dev/null +++ b/man/powerpc_as.6 @@ -0,0 +1,25 @@ +.\" $Header$ +.TH POWERPC_AS 1 +.ad +.SH NAME +powerpc_as \- assembler for Motorola PowerPC + +.SH SYNOPSIS +/usr/em/lib/powerpc_as [options] argument ... + +.SH DESCRIPTION +This assembler is made with the general framework +described in \fIuni_ass\fP(6). + +.SH SYNTAX +TODO. Sorry. + +.SH "SEE ALSO" +uni_ass(6), +ack(1), + +.SH EXAMPLE +.nf +.ta 8n 16n 24n 32n 40n 48n +TODO. +.fi diff --git a/plat/build.mk b/plat/build.mk index 623658b07..f7102032c 100644 --- a/plat/build.mk +++ b/plat/build.mk @@ -65,4 +65,13 @@ endef build-platform = $(eval $(call build-platform-impl, $1)) +define build-pcc-platform-impl + $(eval PLATFORM_$(PLATFORM) := \ + $(PLATDEP)/$(PLATFORM)/pcc_ccom \ + ) + + $(call build-pcc) +endef + +build-pcc-platform = $(eval $(call build-pcc-platform-impl, $1)) diff --git a/plat/linuxarm/build.mk b/plat/linuxarm/build.mk new file mode 100644 index 000000000..bb93e2a92 --- /dev/null +++ b/plat/linuxarm/build.mk @@ -0,0 +1,9 @@ +ARCH := arm +PCCARCH := arm +PLATFORM := linuxarm +OPTIMISATION := -O6 + +D := plat/linuxarm/ + +$(eval $(call build-pcc-platform)) + -- 2.34.1