Merge pull request #94 from gartnerd/master

These changes allow to compile RetroBSD on a Linux Mint host with 32bit libraries installed.
The simulator in "tools/virtualmips/pic32" seems to work fine.

* removed the -Wall compiler flag (hopefully this will be temporary) from makefile recipes to prevent errors from stopping compilation. It mostly fails on printf type functions because of string size conflicts.
* added the "-m32" flag so that compilation and linking produced 32bit executables. I'm not sure is if this is strictly necessary.
* copied Makefile.kconfig to Makefile.kconfigpic32. The files in the pic32 directory compile after making this change
* modified the code in config.h to explicitly tag those function that are externally defined. This is required by newer versions of gcc
* hacked config.y so that the lexer/compiler stopped complaining.
* commented out the "compp" variable in main.c because of size mismatch errors. It doesn't seem to be used for anything.
* added a system header file to tools/kconfig/mkswapconf.c so that the compiler could find included functions
This commit is contained in:
Serge Vakulenko
2023-07-07 11:41:40 -07:00
committed by GitHub
18 changed files with 167 additions and 42 deletions

5
.gitignore vendored
View File

@@ -26,3 +26,8 @@
*.img
Makefile.user
#misc
*.log
*.txt

View File

@@ -2,7 +2,7 @@ TOPSRC = $(shell cd ..; pwd)
SUBDIR = startup libc libm libcurses libtermlib libwiznet libreadline libgpanel
PROG = ar as aout ld nm ranlib size strip
CFLAGS = -Os -std=gnu89 -fno-builtin -g -Werror -Wall -DCROSS -I. \
CFLAGS = -m32 -Os -std=gnu89 -fno-builtin -g -Wall -DCROSS -I. \
-idirafter $(TOPSRC)/include \
-idirafter $(TOPSRC)/src/cmd/ar \
-idirafter $(TOPSRC)/src/cmd/as
@@ -26,28 +26,28 @@ clean:
for i in $(SUBDIR); do $(MAKE) -C $$i $(MFLAGS) clean; done
ar: $(AR_OBJS)
$(CC) $(LDFLAGS) -o $@ $(AR_OBJS) $(LIBS)
$(CC) -m32 $(LDFLAGS) -o $@ $(AR_OBJS) $(LIBS)
as: as.o
$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
$(CC) -m32 $(LDFLAGS) -o $@ $< $(LIBS)
aout: $(AOUT_OBJS)
$(CC) $(LDFLAGS) -o $@ $(AOUT_OBJS) $(LIBS)
$(CC) -m32 $(LDFLAGS) -o $@ $(AOUT_OBJS) $(LIBS)
ld: ld.o
$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
$(CC) -m32 $(LDFLAGS) -o $@ $< $(LIBS)
nm: nm.o
$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
$(CC) -m32 $(LDFLAGS) -o $@ $< $(LIBS)
ranlib: $(RANLIB_OBJS)
$(CC) $(LDFLAGS) -o $@ $(RANLIB_OBJS) $(LIBS)
$(CC) -m32 $(LDFLAGS) -o $@ $(RANLIB_OBJS) $(LIBS)
size: size.o
$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
$(CC) -m32 $(LDFLAGS) -o $@ $< $(LIBS)
strip: strip.o
$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
$(CC) -m32 $(LDFLAGS) -o $@ $< $(LIBS)
$(HEADERS):
-ln -s -f ../include/a.out.h .

View File

@@ -0,0 +1,91 @@
#
# Makefile for RetroBSD, pic32 target
#
# DEBUG is set to -g by kconfig if debugging is requested (kconfig -g).
#
include ../gcc-config.mk
AS = ${MIPS_GCC_PREFIX}as ${DEBUG} -mips32r2 -EL
CC = ${MIPS_GCC_PREFIX}gcc ${DEBUG} -mips32r2 -EL -nostdinc -fno-builtin -Werror -Wall
CPP = ${MIPS_GCC_PREFIX}cpp
LD = ${MIPS_GCC_PREFIX}gcc -mips32r2 -EL
LDFLAGS = -nostdlib -T ../${LDSCRIPT} -Wl,-Map=$(basename $@).map
SIZE = ${MIPS_GCC_PREFIX}size
OBJCOPY = ${MIPS_GCC_PREFIX}objcopy
OBJDUMP = ${MIPS_GCC_PREFIX}objdump
ifneq (${MIPS_GCC_FORMAT},)
LDFLAGS += -Wl,--oformat=${MIPS_GCC_FORMAT}
endif
# sources are located via $S relative to the compilation directory
S = ../..
DEPFLAGS = -MT $@ -MP -MD -MF .deps/$*.dep
DEFS = -I. ${PARAM} -DKERNEL $(DEPFLAGS)
CFLAGS = -O ${DEFS}
# compile rules: rules are named COMPILE_${SUFFIX}
# SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
COMPILE_C = ${CC} -c ${CFLAGS} $<
COMPILE_S = ${CC} -c ${DEFS} $<
%OBJS
%CFILES
# load lines for config "xxx" will be emitted as:
# xxx: ${SYSTEM_DEP} swapxxx.o
# ${SYSTEM_LD_HEAD}
# ${SYSTEM_LD} swapxxx.o
# ${SYSTEM_LD_TAIL}
SYSTEM_OBJ = startup.o ${OBJS} ioconf.o
ifeq (devcfg.c,$(wildcard devcfg.c))
SYSTEM_OBJ += devcfg.o
endif
SYSTEM_DEP = Makefile ioconf.c machine sys .deps ${SYSTEM_OBJ}
SYSTEM_LD_HEAD = sh ../newvers.sh > vers.c; ${CC} $(CFLAGS) -c vers.c; rm -f $@
SYSTEM_LD = -@echo ${LD} ${LDFLAGS} '$${SYSTEM_OBJ}' vers.o -o $@; \
${LD} ${LDFLAGS} ${SYSTEM_OBJ} vers.o -o $@
SYSTEM_LD_TAIL = ${SIZE} $@; \
$(OBJCOPY) -O ihex --change-addresses=0x80000000 $@ $(basename $@).hex; \
$(OBJCOPY) -O binary -R .boot -R .config $@ $(basename $@).bin; \
$(OBJDUMP) -d -S $@ > $(basename $@).dis
%LOAD
clean:
rm -rf .deps *.elf *.o *.map *.dis *.bin machine sys
clean-all: clean
rm -f *.h *.hex ioconf.c swap*.c vers.c
reconfig ioconf.c: Config ../../../tools/kconfig/kconfig
../../../tools/kconfig/kconfig Config
$(MAKE) clean
rm -f *.hex
load: unix.elf
pic32prog unix.hex
machine:
ln -s .. $@
sys:
ln -s ../../include $@
.deps:
mkdir .deps
startup.o: ../startup.S
${COMPILE_S}
ioconf.o: ioconf.c
${COMPILE_C}
%RULES
ifeq (.deps, $(wildcard .deps))
-include .deps/*.dep
endif

View File

@@ -56,7 +56,7 @@ ifeq (/usr/local/mips-elf/bin/mips-elf-gcc,$(wildcard /usr/local/mips-elf/bin/mi
endif
endif
# Mentor Sourcery CodeBench Lite toolchain
# Mentor Sourcery CodeBench Lite toolchain -- DG Downloaded this compiler suite from given link
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# You can download a Linux or Windows binary package from
# https://sourcery.mentor.com/GNUToolchain/release2641

View File

@@ -3,7 +3,7 @@ BIN = config
SRCS = main.cpp config.cpp mapping.cpp device.cpp cluster.cpp util.cpp core.cpp gstore.cpp
OBJS = main.o config.o mapping.o device.o cluster.o util.o core.o gstore.o
CXX = g++
CXXFLAGS = -Wall -O
CXXFLAGS = -Wall -O -m32
all: .depend $(BIN)

View File

@@ -55,7 +55,7 @@ DEFS += -DLED_KERNEL_PORT=TRISE -DLED_KERNEL_PIN=2 -DLED_KERNEL_INVER
DEFS += -DLED_TTY_PORT=TRISE -DLED_TTY_PIN=3 -DLED_TTY_INVERT
DEPFLAGS = -MT $@ -MD -MP -MF .deps/$*.dep
CFLAGS = -O $(DEFS) $(DEPFLAGS)
CFLAGS = -O $(DEFS) $(DEPFLAGS) -m32
ASFLAGS = $(DEFS) $(DEPFLAGS)
CC = $(GCCPREFIX)gcc -EL -g -mips32r2

View File

@@ -1,5 +1,5 @@
CC = ${HOSTCC}gcc -g
CFLAGS = -O -Wall
CFLAGS = -O -Wall -m32
DESTDIR = /usr/local
OBJS = elf2aout.o
PROG = elf2aout
@@ -15,7 +15,7 @@ clean:
rm -f *~ *.o *.lst *.dis $(PROG)
$(PROG): $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
$(CC) -m32 $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
$(PROG).exe: $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)

View File

@@ -1,5 +1,5 @@
CC = gcc -g
CFLAGS = -O -Wall
CFLAGS = -O -Wall -m32
DESTDIR = /usr/local
OBJS = fsutil.o superblock.o block.c inode.o create.o check.o \
file.o mount.o manifest.o
@@ -29,7 +29,7 @@ clean:
rm -rf *~ *.o *.lst *.dis $(PROG) $(PROG).dSYM
$(PROG): $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
$(CC) -m32 $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
root.bin: $(PROG)
./$(PROG) -n16384 -s2048 $@

View File

@@ -1,4 +1,4 @@
CC = gcc -g
CC = gcc -g -m32
CFLAGS = -O -Wall
DESTDIR = /usr/local
OBJS = ice2aout.o

View File

@@ -1,5 +1,5 @@
CC = gcc -g
CFLAGS = -O -Wall -Werror
CC = gcc -g -m32
CFLAGS = -O -Wall -Werror
YACC = byacc -d
DESTDIR = /usr/local
OBJS = config.o main.o lang.o mkioconf.o mkmakefile.o mkswapconf.o

View File

@@ -125,15 +125,15 @@ struct config {
/*
* Config has a global notion of which architecture is being used.
*/
int arch;
char *archname;
extern int arch;
extern char *archname;
#define ARCH_PIC32 1
/*
* For each architecture, a set of CPU's may be specified as supported.
* These and the options (below) are put in the C flags in the makefile.
*/
struct cputype {
extern struct cputype {
char *cpu_name;
struct cputype *cpu_next;
} *cputype;
@@ -143,7 +143,7 @@ struct cputype {
* but which may also specify values for the options.
* A separate set of options may be defined for make-style options.
*/
struct opt {
extern struct opt {
char *op_name;
char *op_value;
struct opt *op_next;
@@ -152,30 +152,30 @@ struct opt {
/*
* Mapping of signal names to pins.
*/
struct signal {
extern struct signal {
char *sig_name;
int sig_pin;
int sig_invert;
struct signal *sig_next;
} *siglist;
char *board;
char *ldscript;
extern char *board;
extern char *ldscript;
int do_trace;
extern int do_trace;
struct device *dtab;
extern struct device *dtab;
char errbuf[80];
int yyline;
extern char errbuf[];
extern int yyline;
struct file_list *ftab, *conf_list, **confp, *comp_list, **compp;
extern struct file_list *ftab, *conf_list, **confp, *comp_list, **compp;
int zone, hadtz;
int dst;
int debugging;
extern int zone, hadtz;
extern int dst;
extern int debugging;
int maxusers;
extern int maxusers;
#define eq(a,b) (!strcmp(a,b))

View File

@@ -99,14 +99,35 @@
* @(#)config.y 8.1 (Berkeley) 6/6/93
*/
#include <sys/sysmacros.h> //definition for major(), minor() and makedev()
#include "config.h"
#include <ctype.h>
#include <stdio.h>
#include <sys/stat.h>
struct device cur;
struct device *curp = 0;
struct device *dtab;
struct file_list **confp;
struct opt *opt, *mkopt;
struct signal *siglist;
struct cputype *cputype;
char *temp_id;
char *val_id;
char *archname;
char errbuf[80];
char *board;
char *ldscript;
int arch;
int do_trace;
int maxusers;
int yyline;
int dst;
int hadtz;
int zone;
int yylex(void);
int finddev(dev_t dev);

View File

@@ -38,6 +38,9 @@
#include "y.tab.h"
#include "config.h"
struct file_list *conf_list;
int debugging;
/*
* Config builds a set of files for building a UNIX
* system given a description of the desired system.
@@ -72,7 +75,7 @@ usage: fputs("usage: kconfig [-gp] sysname\n", stderr);
dtab = NULL;
confp = &conf_list;
compp = &comp_list;
//compp = &comp_list;
if (yyparse())
exit(3);

View File

@@ -40,6 +40,8 @@
#include "y.tab.h"
#include "config.h"
struct file_list *ftab;
#define next_word(fp, wd) \
{ register char *word = get_word(fp); \
if (word == (char *)EOF) \
@@ -425,7 +427,7 @@ void makefile()
read_files();
strcpy(line, "../Makefile.kconf");
//strcat(line, archname);
strcat(line, archname);
ifp = fopen(line, "r");
if (ifp == 0) {
perror(line);

View File

@@ -34,6 +34,9 @@
/*
* Build a swap configuration file.
*/
#include <sys/sysmacros.h> //definitions for makedev(), major(), minor()
#include "config.h"
#include <unistd.h>

View File

@@ -1,5 +1,5 @@
LOBJS=fs.o util.o fops.o set.o
CFLAGS=-Wall -Werror -ggdb3
CFLAGS=-Wall -Werror -ggdb3 -m32
PROGS=umkfs umkdir uls uchmod uchown uchgrp ulogin ucd ucat
POBJS=umkfs.o umkdir.o uls.o uchmod.o uchown.o uchgrp.o ulogin.o ucd.o ucat.o
LDFLAGS=-L. -lufs -ggdb3

View File

@@ -1,11 +1,11 @@
OBJS = mkrd.o
BIN = mkrd
CFLAGS = -Wall -Werror -O
CFLAGS = -m32 -Wall -Werror -O
all: $(BIN)
$(BIN): $(OBJS)
$(CC) -o $@ $< $(LIBS) $(LDFLAGS)
$(CC) -m32 -o $@ $< $(LIBS) $(LDFLAGS)
clean:
@rm -f $(BIN) $(OBJS)

View File

@@ -15,8 +15,8 @@ CFLAGS = -DSIM_PIC32 -DPIC32MX7 -DMAX32
# UBW32 with UART console
#CFLAGS = -DSIM_PIC32 -DPIC32MX7 -DUBW32
CC = gcc -g
CFLAGS += -Wall -Werror -MT $@ -MD -MP -MF .deps/$*.dep
CC = gcc -g -m32
CFLAGS += -Wall -MT $@ -MD -MP -MF .deps/$*.dep
LIBS = -lpthread
CFLAGS += $(shell pkg-config libelf --cflags)