GCC and Binutils upgrade attempt

This commit is contained in:
Kevin Lange 2016-12-25 21:47:01 +09:00
parent fae3c8171c
commit 1e5b785b0d
11 changed files with 301 additions and 272 deletions

View File

@ -14,6 +14,13 @@ AR = i686-pc-toaru-ar
AS = i686-pc-toaru-as
STRIP = i686-pc-toaru-strip
KCC = i686-elf-gcc
KNM = i686-elf-nm
KCXX= i686-elf-g++
KAR = i686-elf-ar
KAS = i686-elf-as
KSTRIP = i686-elf-strip
# Build flags
CFLAGS = -O2 -std=c99
CFLAGS += -finline-functions -ffreestanding
@ -195,18 +202,18 @@ KERNEL_ASMOBJS = $(filter-out kernel/symbols.o,$(patsubst %.S,%.o,$(wildcard ker
################
toaruos-kernel: ${KERNEL_ASMOBJS} ${KERNEL_OBJS} kernel/symbols.o
@${BEG} "CC" "$@"
@${CC} -T kernel/link.ld ${CFLAGS} -nostdlib -o toaruos-kernel ${KERNEL_ASMOBJS} ${KERNEL_OBJS} kernel/symbols.o -lgcc ${ERRORS}
@${KCC} -T kernel/link.ld ${CFLAGS} -nostdlib -o toaruos-kernel ${KERNEL_ASMOBJS} ${KERNEL_OBJS} kernel/symbols.o -lgcc ${ERRORS}
@${END} "CC" "$@"
@${INFO} "--" "Kernel is ready!"
kernel/symbols.o: ${KERNEL_ASMOBJS} ${KERNEL_OBJS} util/generate_symbols.py
@-rm -f kernel/symbols.o
@${BEG} "NM" "Generating symbol list..."
@${CC} -T kernel/link.ld ${CFLAGS} -nostdlib -o toaruos-kernel ${KERNEL_ASMOBJS} ${KERNEL_OBJS} -lgcc ${ERRORS}
@${NM} toaruos-kernel -g | python2 util/generate_symbols.py > kernel/symbols.S
@${KCC} -T kernel/link.ld ${CFLAGS} -nostdlib -o toaruos-kernel ${KERNEL_ASMOBJS} ${KERNEL_OBJS} -lgcc ${ERRORS}
@${KNM} toaruos-kernel -g | python2 util/generate_symbols.py > kernel/symbols.S
@${END} "NM" "Generated symbol list."
@${BEG} "AS" "kernel/symbols.S"
@${AS} ${ASFLAGS} kernel/symbols.S -o $@ ${ERRORS}
@${KAS} ${ASFLAGS} kernel/symbols.S -o $@ ${ERRORS}
@${END} "AS" "kernel/symbols.S"
kernel/sys/version.o: kernel/*/*.c kernel/*.c
@ -216,17 +223,17 @@ hdd/mod:
hdd/mod/%.ko: modules/%.c ${HEADERS} | hdd/mod
@${BEG} "CC" "$< [module]"
@${CC} -T modules/link.ld -I./kernel/include -nostdlib ${CFLAGS} -c -o $@ $< ${ERRORS}
@${KCC} -T modules/link.ld -I./kernel/include -nostdlib ${CFLAGS} -c -o $@ $< ${ERRORS}
@${END} "CC" "$< [module]"
kernel/%.o: kernel/%.S
@${BEG} "AS" "$<"
@${AS} ${ASFLAGS} $< -o $@ ${ERRORS}
@${KAS} ${ASFLAGS} $< -o $@ ${ERRORS}
@${END} "AS" "$<"
kernel/%.o: kernel/%.c ${HEADERS}
@${BEG} "CC" "$<"
@${CC} ${CFLAGS} -nostdlib -g -I./kernel/include -c -o $@ $< ${ERRORS}
@${KCC} ${CFLAGS} -nostdlib -g -I./kernel/include -c -o $@ $< ${ERRORS}
@${END} "CC" "$<"
#############
@ -287,24 +294,26 @@ hdd/usr/lib/libc.so: ${TOOLCHAIN}/lib/libc.a | hdd/usr/lib
@${BEG} "SO" "$@"
@cp ${TOARU_SYSROOT}/usr/lib/libc.a libc.a
@# init and fini don't belong in our shared object
@${AR} d libc.a lib_a-init.o
@${AR} d libc.a lib_a-fini.o
@ar d libc.a lib_a-init.o
@ar d libc.a lib_a-fini.o
@# Remove references to newlib's reentrant malloc
@${AR} d libc.a lib_a-calloc.o
@${AR} d libc.a lib_a-callocr.o
@${AR} d libc.a lib_a-cfreer.o
@${AR} d libc.a lib_a-freer.o
@${AR} d libc.a lib_a-malignr.o
@${AR} d libc.a lib_a-mallinfor.o
@${AR} d libc.a lib_a-mallocr.o
@${AR} d libc.a lib_a-malloptr.o
@${AR} d libc.a lib_a-mallstatsr.o
@${AR} d libc.a lib_a-msizer.o
@${AR} d libc.a lib_a-pvallocr.o
@${AR} d libc.a lib_a-realloc.o
@${AR} d libc.a lib_a-reallocr.o
@${AR} d libc.a lib_a-vallocr.o
@${CC} -shared -o $@ -Wl,--whole-archive libc.a -Wl,--no-whole-archive ${ERRORS}
@ar d libc.a lib_a-callocr.o
@ar d libc.a lib_a-cfreer.o
@ar d libc.a lib_a-freer.o
@ar d libc.a lib_a-malignr.o
@ar d libc.a lib_a-mallinfor.o
@ar d libc.a lib_a-mallocr.o
@ar d libc.a lib_a-malloptr.o
@ar d libc.a lib_a-msizer.o
@ar d libc.a lib_a-mallstatsr.o
@ar d libc.a lib_a-pvallocr.o
@ar d libc.a lib_a-vallocr.o
@ar d libc.a lib_a-reallocr.o
@ar d libc.a lib_a-realloc.o
@ar d libc.a lib_a-calloc.o
@ar d libc.a lib_a-reallo.o
@${CC} -shared -o libc.so -Wl,--whole-archive libc.a -Wl,--no-whole-archive ${ERRORS}
@mv libc.so hdd/usr/lib/libc.so
@if [ "x$(STRIP_LIBS)" = "x1" ]; then ${STRIP} $@; fi
@rm libc.a
@${END} "SO" "$@"
@ -321,11 +330,13 @@ hdd/lib/ld.so: linker/linker.c | hdd/lib
define basic-so-wrapper
hdd/usr/lib/lib$(1).so: ${TOOLCHAIN}/lib/lib$(1).a
@${BEG} "SO" "$$@"
@${CC} -shared -Wl,-soname,lib$(1).so -o hdd/usr/lib/lib$(1).so -Lhdd/usr/lib -Wl,--whole-archive ${TOOLCHAIN}/lib/lib$(1).a -Wl,--no-whole-archive $2
@${CC} -shared -Wl,-soname,lib$(1).so -o lib$(1).so -Lhdd/usr/lib -Wl,--whole-archive ${TOOLCHAIN}/lib/lib$(1).a -Wl,--no-whole-archive $2 -lgcc
@mv lib$(1).so hdd/usr/lib/lib$(1).so
@if [ "x$(STRIP_LIBS)" = "x1" ]; then ${STRIP} $$@; fi
@${END} "SO" "$$@"
endef
$(eval $(call basic-so-wrapper,gcc,))
$(eval $(call basic-so-wrapper,m,))
$(eval $(call basic-so-wrapper,z,))
$(eval $(call basic-so-wrapper,ncurses,))

View File

@ -177,7 +177,7 @@ void free(void * ptr) {
/*
* Adjust bin size in bin_size call to proper bounds.
*/
static uintptr_t __attribute__ ((always_inline, pure)) klmalloc_adjust_bin(uintptr_t bin)
inline static uintptr_t __attribute__ ((always_inline, pure)) klmalloc_adjust_bin(uintptr_t bin)
{
if (bin <= (uintptr_t)SMALLEST_BIN_LOG)
{
@ -194,7 +194,7 @@ static uintptr_t __attribute__ ((always_inline, pure)) klmalloc_adjust_bin(uint
* Given a size value, find the correct bin
* to place the requested allocation in.
*/
static uintptr_t __attribute__ ((always_inline, pure)) klmalloc_bin_size(uintptr_t size) {
inline static uintptr_t __attribute__ ((always_inline, pure)) klmalloc_bin_size(uintptr_t size) {
uintptr_t bin = sizeof(size) * CHAR_BIT - __builtin_clzl(size);
bin += !!(size & (size - 1));
return klmalloc_adjust_bin(bin);
@ -255,7 +255,7 @@ static klmalloc_big_bin_header * klmalloc_newest_big = NULL; /* Newest big bin
* position in the list by linking
* its neighbors to eachother.
*/
static void __attribute__ ((always_inline)) klmalloc_list_decouple(klmalloc_bin_header_head *head, klmalloc_bin_header *node) {
inline static void __attribute__ ((always_inline)) klmalloc_list_decouple(klmalloc_bin_header_head *head, klmalloc_bin_header *node) {
klmalloc_bin_header *next = node->next;
head->first = next;
node->next = NULL;
@ -268,7 +268,7 @@ static void __attribute__ ((always_inline)) klmalloc_list_decouple(klmalloc_bin_
* elements are updated to point back
* to it (our list is doubly linked).
*/
static void __attribute__ ((always_inline)) klmalloc_list_insert(klmalloc_bin_header_head *head, klmalloc_bin_header *node) {
inline static void __attribute__ ((always_inline)) klmalloc_list_insert(klmalloc_bin_header_head *head, klmalloc_bin_header *node) {
node->next = head->first;
head->first = node;
}
@ -279,7 +279,7 @@ static void __attribute__ ((always_inline)) klmalloc_list_insert(klmalloc_bin_he
* are really great, and just in case
* we change the list implementation.
*/
static klmalloc_bin_header * __attribute__ ((always_inline)) klmalloc_list_head(klmalloc_bin_header_head *head) {
inline static klmalloc_bin_header * __attribute__ ((always_inline)) klmalloc_list_head(klmalloc_bin_header_head *head) {
return head->first;
}
@ -315,7 +315,7 @@ static uint32_t __attribute__ ((pure)) klmalloc_skip_rand(void) {
/*
* Generate a random level for a skip node
*/
static int __attribute__ ((pure, always_inline)) klmalloc_random_level(void) {
inline static int __attribute__ ((pure, always_inline)) klmalloc_random_level(void) {
int level = 0;
/*
* Keep trying to check rand() against 50% of its maximum.
@ -557,7 +557,7 @@ static void klmalloc_stack_push(klmalloc_bin_header *header, void *ptr) {
* stack, so there is no more free
* space available in the block.
*/
static int __attribute__ ((always_inline)) klmalloc_stack_empty(klmalloc_bin_header *header) {
inline static int __attribute__ ((always_inline)) klmalloc_stack_empty(klmalloc_bin_header *header) {
return header->head == NULL;
}

View File

@ -48,6 +48,8 @@ typedef struct elf_object {
void (*init)(void);
void (**ctors)(void);
size_t ctors_size;
void (**init_array)(void);
size_t init_array_size;
uintptr_t base;
@ -290,6 +292,11 @@ static int object_postload(elf_t * object) {
object->ctors = (void *)(shdr.sh_addr + object->base);
object->ctors_size = shdr.sh_size;
}
if (!strcmp((char *)((uintptr_t)object->string_table + shdr.sh_name), ".init_array")) {
object->init_array = (void *)(shdr.sh_addr + object->base);
object->init_array_size = shdr.sh_size;
}
}
return 0;
@ -489,6 +496,13 @@ static void * do_actual_load(const char * filename, elf_t * lib, int flags) {
}
}
if (lib->init_array) {
for (size_t i = 0; i < lib->init_array_size; i += sizeof(uintptr_t)) {
TRACE_LD(" 0x%x()", lib->init_array[i]);
lib->init_array[i]();
}
}
if (lib->init) {
lib->init();
}
@ -577,6 +591,10 @@ int main(int argc, char * argv[]) {
hashmap_t * libs = hashmap_create(10);
while (end_addr & 0xFFF) {
end_addr++;
}
list_t * ctor_libs = list_create();
list_t * init_libs = list_create();
@ -605,7 +623,7 @@ int main(int argc, char * argv[]) {
fclose(lib->file);
/* Execute constructors */
if (lib->ctors) {
if (lib->ctors || lib->init_array) {
list_insert(ctor_libs, lib);
}
if (lib->init) {
@ -636,6 +654,13 @@ nope:
lib->ctors[i]();
}
}
if (lib->init_array) {
TRACE_LD("Executing init_array...");
for (size_t i = 0; i < lib->init_array_size; i += sizeof(uintptr_t)) {
TRACE_LD(" 0x%x()", lib->init_array[i]);
lib->init_array[i]();
}
}
}
}

View File

@ -11,6 +11,7 @@ if [ ! -d toaru-python ]; then
fi
echo "Installing dlfcn.h..."
mkdir -p hdd/usr/include
cp userspace/lib/dlfcn.h hdd/usr/include/
pushd toaru-python || exit 1

View File

@ -46,8 +46,18 @@ pushd build
unset PKG_CONFIG_LIBDIR
pushd binutils
$DIR/tarballs/binutils-2.22/configure --target=$TARGET --prefix=$PREFIX --with-sysroot=$TOARU_SYSROOT --disable-werror || bail
make || bail
$DIR/tarballs/binutils-2.27/configure --target=$TARGET --prefix=$PREFIX --with-sysroot=$TOARU_SYSROOT --disable-werror || bail
make -j || bail
make install || bail
popd
if [ ! -d binutils-elf ]; then
mkdir binutils-elf
fi
pushd binutils-elf
$DIR/tarballs/binutils-2.27/configure --target=i686-elf --prefix=$PREFIX --disable-werror || bail
make -j || bail
make install || bail
popd
fi
@ -61,11 +71,20 @@ pushd build
unset PKG_CONFIG_LIBDIR
pushd gcc
$DIR/tarballs/gcc-4.6.4/configure --target=$TARGET --prefix=$PREFIX --with-sysroot=$TOARU_SYSROOT --with-build-sysroot=$TOARU_SYSROOT --with-native-system-header-dir=$TOARU_SYSROOT --disable-nls --enable-languages=c,c++ --disable-libssp --with-newlib || bail
make all-gcc || bail
make install-gcc || bail
make all-target-libgcc || bail
make install-target-libgcc || bail
$DIR/tarballs/gcc-6.3.0/configure --target=i686-pc-toaru --prefix=$PREFIX --with-sysroot=$TOARU_SYSROOT --disable-nls --enable-languages=c,c++,go --disable-libssp --with-newlib || baiol
make -j all-gcc all-target-libgcc || bail
make install-gcc install-target-libgcc || bail
popd
if [ -d gcc-elf ]; then
rm -rf gcc-elf
fi
mkdir gcc-elf
pushd gcc-elf
$DIR/tarballs/gcc-6.3.0/configure --target=i686-elf --prefix=$PREFIX --disable-nls --enable-languages=c --disable-libssp --without-headers || baiol
make -j all-gcc all-target-libgcc || bail
make install-gcc install-target-libgcc || bail
popd
fi
@ -111,7 +130,7 @@ pushd build
# Fix the damned tooldir
sed -s 's/prefix}\/i686-pc-toaru/prefix}/' Makefile > Makefile.tmp
mv Makefile.tmp Makefile
make || bail
make -j || bail
make DESTDIR=$TOARU_SYSROOT install || bail
cp -r $DIR/patches/newlib/include/* $TOARU_SYSROOT/$VIRTPREFIX/include/
cp $TARGET/newlib/libc/sys/crt0.o $TOARU_SYSROOT/$VIRTPREFIX/lib/
@ -123,7 +142,7 @@ pushd build
if $BUILD_LIBSTDCPP; then
pushd gcc
# build libstdc++
make all-target-libstdc++-v3 || bail
make -j all-target-libstdc++-v3 || bail
make install-target-libstdc++-v3 || bail
popd
fi
@ -198,7 +217,7 @@ pushd build
mkdir ncurses
fi
pushd ncurses
$DIR/tarballs/ncurses-5.9/configure --prefix=$VIRTPREFIX --host=$TARGET --with-terminfo-dirs=/usr/share/terminfo --with-default-terminfo-dir=/usr/share/terminfo --without-tests || bail
CPPFLAGS="-P" $DIR/tarballs/ncurses-5.9/configure --prefix=$VIRTPREFIX --host=$TARGET --with-terminfo-dirs=/usr/share/terminfo --with-default-terminfo-dir=/usr/share/terminfo --without-tests || bail
make || bail
make DESTDIR=$TOARU_SYSROOT install || bail
cp $DIR/../util/toaru.tic $TOARU_SYSROOT/$VIRTPREFIX/share/terminfo/t/toaru

View File

@ -1,80 +0,0 @@
diff -rupN original/bfd/config.bfd new/bfd/config.bfd
--- original/bfd/config.bfd 2011-07-28 17:35:13.000000000 -0500
+++ new/bfd/config.bfd 2012-05-16 20:51:26.000000000 -0500
@@ -674,6 +674,10 @@ case "${targ}" in
targ_defvec=bfd_elf32_i386_vec
targ_selfvecs=i386chaos_vec
;;
+ i[3-7]86-*-toaru*)
+ targ_defvec=bfd_elf32_i386_vec
+ ;;
+
i860-*-mach3* | i860-*-osf1* | i860-*-coff*)
targ_defvec=i860coff_vec
diff -rupN original/config.sub new/config.sub
--- original/config.sub 2011-06-06 05:36:06.000000000 -0500
+++ new/config.sub 2012-05-16 20:49:18.000000000 -0500
@@ -1323,6 +1323,7 @@ case $os in
| -sym* | -kopensolaris* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
| -aos* | -aros* \
+ | -toaru* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
diff -rupN original/gas/configure.tgt new/gas/configure.tgt
--- original/gas/configure.tgt 2011-06-20 08:23:21.000000000 -0500
+++ new/gas/configure.tgt 2012-05-16 20:51:49.000000000 -0500
@@ -228,6 +228,7 @@ case ${generic_target} in
i386-*-chaos) fmt=elf ;;
i386-*-rdos*) fmt=elf ;;
i386-*-darwin*) fmt=macho ;;
+ i386-*-toaru*) fmt=elf ;;
i860-*-*) fmt=elf endian=little ;;
diff -rupN original/ld/configure.tgt new/ld/configure.tgt
--- original/ld/configure.tgt 2011-11-21 03:29:37.000000000 -0600
+++ new/ld/configure.tgt 2012-05-16 20:49:58.000000000 -0500
@@ -195,6 +195,7 @@ x86_64-*-linux-*) targ_emul=elf_x86_64
targ_extra_libpath="elf_i386 elf32_x86_64 elf_l1om elf_k1om"
tdir_i386linux=`echo ${targ_alias}aout | sed -e 's/x86_64/i386/'`
tdir_elf_i386=`echo ${targ_alias} | sed -e 's/x86_64/i386/'` ;;
+i[3-7]86-*-toaru*) targ_emul=toaru_i386 ;;
i[3-7]86-*-sysv[45]*) targ_emul=elf_i386 ;;
i[3-7]86-*-solaris2*) targ_emul=elf_i386_sol2
targ_extra_emuls="elf_i386_ldso elf_i386 elf_x86_64_sol2 elf_x86_64 elf_l1om elf_k1om"
diff -rupN original/ld/emulparams/toaru_i386.sh new/ld/emulparams/toaru_i386.sh
--- original/ld/emulparams/toaru_i386.sh 1969-12-31 18:00:00.000000000 -0600
+++ new/ld/emulparams/toaru_i386.sh 2012-05-16 20:48:40.000000000 -0500
@@ -0,0 +1,16 @@
+SCRIPT_NAME=elf
+ELFSIZE=32
+OUTPUT_FORMAT=elf32-i386
+NO_RELA_RELOCS=yes
+TEXT_START_ADDR=0x40000000
+MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
+COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)"
+ARCH=i386
+MACHINE=
+NOP=0x90909090
+TEMPLATE_NAME=elf32
+GENERATE_SHLIB_SCRIPT=yes
+GENERATE_PIE_SCRIPT=yes
+NO_SMALL_DATA=yes
+SEPARATE_GOTPLT=12
+IREL_IN_PLT=
diff -rupN original/ld/Makefile.in new/ld/Makefile.in
--- original/ld/Makefile.in 2011-07-22 15:22:37.000000000 -0500
+++ new/ld/Makefile.in 2012-05-16 20:50:54.000000000 -0500
@@ -2627,6 +2627,9 @@ eelf32xtensa.c: $(srcdir)/emulparams/elf
eelf_i386.c: $(srcdir)/emulparams/elf_i386.sh \
$(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
${GENSCRIPTS} elf_i386 "$(tdir_elf_i386)"
+etoaru_i386.c: $(srcdir)/emulparams/toaru_i386.sh \
+ $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
+ ${GENSCRIPTS} toaru_i386 "$(tdir_toaru_i386)"
eelf_i386_be.c: $(srcdir)/emulparams/elf_i386_be.sh \
$(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
${GENSCRIPTS} elf_i386_be "$(tdir_elf_i386_be)"

View File

@ -0,0 +1,64 @@
diff --git a/bfd/config.bfd b/bfd/config.bfd
index b998830..3d6bdc4 100644
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -661,6 +661,10 @@ case "${targ}" in
targ_defvec=i386_elf32_vec
targ_selvecs="iamcu_elf32_vec i386_nlm32_vec i386_coff_vec i386_aout_vec"
;;
+ i[3-7]86-*-toaru*)
+ targ_defvec=i386_elf32_vec
+ targ_selvecs=
+ ;;
i[3-7]86-*-linux*aout*)
targ_defvec=i386_aout_linux_vec
targ_selvecs="i386_elf32_vec iamcu_elf32_vec"
diff --git a/config.sub b/config.sub
index 2377e13..19fa153 100755
--- a/config.sub
+++ b/config.sub
@@ -1375,6 +1375,7 @@ case $os in
# -sysv* is not here because it comes later, after sysvr4.
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
+ | -toaru* \
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
| -sym* | -kopensolaris* | -plan9* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
diff --git a/gas/configure.tgt b/gas/configure.tgt
index e2df659..72a6bbf 100644
--- a/gas/configure.tgt
+++ b/gas/configure.tgt
@@ -283,6 +283,7 @@ case ${generic_target} in
i386-*-chaos) fmt=elf ;;
i386-*-rdos*) fmt=elf ;;
i386-*-darwin*) fmt=macho ;;
+ i386-*-toaru*) fmt=elf ;;
i860-*-*) fmt=elf endian=little ;;
diff --git a/ld/configure.tgt b/ld/configure.tgt
index a3db909..13c4387 100644
--- a/ld/configure.tgt
+++ b/ld/configure.tgt
@@ -269,6 +269,7 @@ x86_64-*-linux-*) targ_emul=elf_x86_64
targ_extra_libpath="elf_i386 elf32_x86_64 elf_l1om elf_k1om"
tdir_i386linux=`echo ${targ_alias}aout | sed -e 's/x86_64/i386/'`
tdir_elf_i386=`echo ${targ_alias} | sed -e 's/x86_64/i386/'` ;;
+i[3-7]86-*-toaru*) targ_emul=elf_i386 ;;
i[3-7]86-*-sysv[45]*) targ_emul=elf_i386
targ_extra_emuls=elf_iamcu ;;
i[3-7]86-*-solaris2*) targ_emul=elf_i386_sol2
diff --git a/ld/emulparams/elf_i386.sh b/ld/emulparams/elf_i386.sh
index b08e661..7bd4bd5 100644
--- a/ld/emulparams/elf_i386.sh
+++ b/ld/emulparams/elf_i386.sh
@@ -33,4 +33,8 @@ case "$target" in
;;
esac
;;
+ i[3-7]86*-toaru*)
+ TEXT_START_ADDR=0x40000000
+ ;;
esac
+

View File

@ -1,135 +0,0 @@
diff -rupN original/config.sub new/config.sub
--- original/config.sub 2010-05-25 08:22:07.000000000 -0500
+++ new/config.sub 2011-04-24 19:55:22.000000000 -0500
@@ -1298,6 +1298,7 @@ case $os in
| -sym* | -kopensolaris* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
| -aos* | -aros* \
+ | -toaru* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
diff -rupN original/gcc/config/toaru.h new/gcc/config/toaru.h
--- original/gcc/config/toaru.h 1969-12-31 18:00:00.000000000 -0600
+++ new/gcc/config/toaru.h 2011-04-24 19:51:58.000000000 -0500
@@ -0,0 +1,20 @@
+#undef TARGET_OS_CPP_BUILTINS
+#define TARGET_OS_CPP_BUILTINS() \
+ do { \
+ builtin_define_std ("toaru"); \
+ builtin_define_std ("unix"); \
+ builtin_assert ("system=toaru"); \
+ builtin_assert ("system=unix"); \
+ } while (0);
+
+#undef STARTFILE_SPEC
+#define STARTFILE_SPEC "%{!shared: %{!pg:crt0.o%s}} crti.o%s %{!shared:crtbegin.o%s}"
+
+#undef ENDFILE_SPEC
+#define ENDFILE_SPEC "%{!shared:crtend.o%s} crtn.o%s"
+
+#undef LINK_SPEC
+#define LINK_SPEC "%{shared:-shared} %{!shared: %{!static: %{rdynamic:-export-dynamic} %{!dynamic-linker:-dynamic-linker /lib/ld.so}}}"
+
+#undef TARGET_VERSION
+#define TARGET_VERSION fprintf(stderr, " (i386 toaru)");
diff -rupN original/gcc/config.gcc new/gcc/config.gcc
--- original/gcc/config.gcc 2011-03-14 01:05:29.000000000 -0500
+++ new/gcc/config.gcc 2011-04-24 20:04:11.000000000 -0500
@@ -694,6 +694,12 @@ case ${target} in
*) echo 'Unknown thread configuration for VxWorks'; exit 1 ;;
esac
;;
+*-*-toaru*)
+ extra_parts="crtbegin.o crtend.o"
+ gas=yes
+ gnu_ld=yes
+ default_use_cxa_atexit=yes
+ ;;
*-*-elf)
# Assume that newlib is being used and so __cxa_atexit is provided.
default_use_cxa_atexit=yes
@@ -1190,6 +1196,11 @@ hppa[12]*-*-hpux11*)
dwarf2=no
fi
;;
+i[34567]86-*-toaru*)
+ tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h i386/i386elf.h toaru.h"
+ tmake_file="${tmake_file} i386/t-i386elf t-svr4 i386/t-crtstuff"
+ use_fixproto=yes
+ ;;
i[34567]86-*-darwin*)
need_64bit_hwint=yes
need_64bit_isa=yes
diff -rupN original/libgcc/config.host new/libgcc/config.host
--- original/libgcc/config.host 2011-03-14 01:06:23.000000000 -0500
+++ new/libgcc/config.host 2011-04-24 20:00:50.000000000 -0500
@@ -345,6 +345,8 @@ x86_64-*-mingw*)
;;
i[34567]86-*-interix3*)
;;
+i[34567]86-*-toaru*)
+ ;;
ia64*-*-elf*)
extra_parts="crtbegin.o crtend.o crtbeginS.o crtendS.o crtfastmath.o"
tmake_file="ia64/t-ia64"
diff -rupN original/libstdc++-v3/crossconfig.m4 new/libstdc++-v3/crossconfig.m4
--- original/libstdc++-v3/crossconfig.m4 2011-02-04 01:26:57.000000000 -0600
+++ new/libstdc++-v3/crossconfig.m4 2011-04-24 19:56:16.000000000 -0500
@@ -249,6 +249,12 @@ case "${host}" in
AC_DEFINE(HAVE_ISNANL)
fi
;;
+ *-toaru*)
+ AC_CHECK_HEADERS([sys/types.h local.h float.h])
+ GLIBCXX_CHECK_BUILTIN_MATH_SUPPORT
+ GLIBCXX_CHECK_COMPLEX_MATH_SUPPORT
+ GLIBCXX_CHECK_STDLIB_SUPPORT
+ ;;
*-vxworks)
AC_DEFINE(HAVE_ACOSF)
AC_DEFINE(HAVE_ASINF)
diff -rupN original/gcc/gengtype.c new/gcc/gengtype.c
--- original/gcc/gengtype.c
+++ new/gcc/gengtype.c
@@ -3594,13 +3594,13 @@ write_field_root (outf_p f, pair_p v, type_p type,
int has_length, struct fileloc *line, const char *if_marked,
bool emit_pch, type_p field_type, const char *field_name)
{
+ struct pair newv;
/* If the field reference is relative to V, rather than to some
subcomponent of V, we can mark any subarrays with a single stride.
We're effectively treating the field as a global variable in its
own right. */
if (v && type == v->type)
{
- struct pair newv;
newv = *v;
newv.type = field_type;
diff -rupN original/gcc/cp/cfns.h new/gcc/cp/cfns.h
--- original/gcc/cp/cfns.h
+++ new/gcc/cp/cfns.h
@@ -53,6 +53,9 @@ __inline
static unsigned int hash (const char *, unsigned int);
#ifdef __GNUC__
__inline
+#ifdef __GNUC_STDC_INLINE__
+__attribute__ ((__gnu_inline__))
+#endif
#endif
const char * libc_name_p (const char *, unsigned int);
/* maximum key range = 391, duplicates = 0 */
diff -rupN original/gcc/cp/cfns.gperf new/gcc/cp/cfns.gperf
--- original/gcc/cp/cfns.gperf
+++ new/gcc/cp/cfns.gperf
@@ -22,6 +22,9 @@ __inline
static unsigned int hash (const char *, unsigned int);
#ifdef __GNUC__
__inline
+#ifdef __GNUC_STDC_INLINE__
+__attribute__ ((__gnu_inline__))
+#endif
#endif
const char * libc_name_p (const char *, unsigned int);
%}

View File

@ -0,0 +1,127 @@
diff --git a/config.sub b/config.sub
index 41146e1..8438e24 100755
--- a/config.sub
+++ b/config.sub
@@ -1375,6 +1375,7 @@ case $os in
# -sysv* is not here because it comes later, after sysvr4.
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
+ | -toaru* \
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
| -sym* | -kopensolaris* | -plan9* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
diff --git a/fixincludes/mkfixinc.sh b/fixincludes/mkfixinc.sh
index 0d96c8c..1ae6bdc 100755
--- a/fixincludes/mkfixinc.sh
+++ b/fixincludes/mkfixinc.sh
@@ -13,6 +13,7 @@ target=fixinc.sh
case $machine in
i?86-*-cygwin* | \
i?86-*-mingw32* | \
+ i?86-*-toaru* | \
x86_64-*-mingw32* | \
i?86-*-interix* | \
powerpc-*-eabisim* | \
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 1d5b23f..603a22b 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -820,6 +820,11 @@ case ${target} in
gnu_ld=yes
default_use_cxa_atexit=yes
;;
+*-*-toaru*)
+ gas=yes
+ gnu_ld=yes
+ default_use_cxa_atexit=yes
+ ;;
*-*-rtems*)
case ${enable_threads} in
"" | yes | rtems) thread_file='rtems' ;;
@@ -1441,6 +1446,9 @@ x86_64-*-rdos*)
tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h i386/x86-64.h i386/rdos.h i386/rdos64.h"
tmake_file="i386/t-i386elf t-svr4"
;;
+*-*-toaru*)
+ tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h glibc-stdint.h i386/i386elf.h toaru.h"
+ ;;
i[34567]86-*-dragonfly*)
tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h dragonfly.h dragonfly-stdint.h i386/dragonfly.h"
tmake_file="${tmake_file} i386/t-crtstuff"
diff --git a/gcc/config/toaru.h b/gcc/config/toaru.h
new file mode 100644
index 0000000..9157525
--- /dev/null
+++ b/gcc/config/toaru.h
@@ -0,0 +1,26 @@
+#undef TARGET_OS_CPP_BUILTINS
+#define TARGET_OS_CPP_BUILTINS() \
+ do { \
+ builtin_define_std ("toaru"); \
+ builtin_define_std ("unix"); \
+ builtin_assert ("system=toaru"); \
+ builtin_assert ("system=unix"); \
+ } while (0);
+
+#undef STARTFILE_SPEC
+#define STARTFILE_SPEC "%{!shared: %{!pg:crt0.o%s}} crti.o%s %{!shared:crtbegin.o%s}"
+
+#undef ENDFILE_SPEC
+#define ENDFILE_SPEC "%{!shared:crtend.o%s} crtn.o%s"
+
+#undef LINK_SPEC
+#define LINK_SPEC "%{shared:-shared} %{static:-static} %{!shared: %{!static: %{rdynamic:-export-dynamic} %{!dynamic-linker:-dynamic-linker /lib/ld.so}}}"
+
+#undef LIB_SPEC
+#define LIB_SPEC "%{pthread:-lpthread} -lc"
+
+#undef OBJECT_FORMAT_ELF
+#define OBJECT_FORMAT_ELF
+
+#undef NO_IMPLICIT_EXTERN_C
+#define NO_IMPLICIT_EXTERN_C 1
diff --git a/libgcc/config.host b/libgcc/config.host
index 124f2ce..c865054 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -656,6 +656,10 @@ i[34567]86-*-solaris2* | x86_64-*-solaris2.1[0-9]*)
;;
i[4567]86-wrs-vxworks|i[4567]86-wrs-vxworksae)
;;
+i[34567]86-*-toaru*)
+ extra_parts="$extra_parts crtbegin.o crtend.o"
+ tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
+ ;;
i[34567]86-*-cygwin*)
extra_parts="crtbegin.o crtbeginS.o crtend.o crtfastmath.o"
if test x$enable_vtable_verify = xyes; then
diff --git a/libstdc++-v3/crossconfig.m4 b/libstdc++-v3/crossconfig.m4
index ece1256..97566e6 100644
--- a/libstdc++-v3/crossconfig.m4
+++ b/libstdc++-v3/crossconfig.m4
@@ -248,6 +248,12 @@ case "${host}" in
GLIBCXX_CHECK_MATH_SUPPORT
GLIBCXX_CHECK_STDLIB_SUPPORT
;;
+ *-toaru*)
+ GLIBCXX_CHECK_COMPILER_FEATURES
+ GLIBCXX_CHECK_LINKER_FEATURES
+ GLIBCXX_CHECK_MATH_SUPPORT
+ GLIBCXX_CHECK_STDLIB_SUPPORT
+ ;;
*-vxworks)
AC_DEFINE(HAVE_ACOSF)
AC_DEFINE(HAVE_ASINF)
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 03e198a..e0eb9d6 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -38,7 +38,7 @@
#include <bits/c++config.h>
#ifdef _GLIBCXX_USE_C99_STDINT_TR1
-# if defined (__UINT_LEAST16_TYPE__) && defined(__UINT_LEAST32_TYPE__)
+# if defined (__UINT_LEAST16_TYPE__) && defined(__UINT_LEAST32_TYPE__) && 0
namespace std
{
typedef __UINT_LEAST16_TYPE__ uint_least16_t;

View File

@ -7,11 +7,6 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. $DIR/util.sh
function deleteUnusedGCC () {
# If you are running from the non-core GCC, run this function delete the stuff we don't care about
rm -r $1/boehm-gc $1/gcc/ada $1/gcc/go $1/gcc/java $1/gcc/objc $1/gcc/objcp $1/gcc/testsuite $1/gnattools $1/libada $1/libffi $1/libgo $1/libjava $1/libobjc
}
pushd "$DIR" > /dev/null
if [ ! -d tarballs ]; then
@ -19,12 +14,11 @@ pushd "$DIR" > /dev/null
fi
pushd tarballs > /dev/null
$INFO "wget" "Pulling source packages..."
grab "gcc" "http://www.netgull.com/gcc/releases/gcc-4.6.4" "gcc-core-4.6.4.tar.gz" || bail
grab "g++" "http://www.netgull.com/gcc/releases/gcc-4.6.4" "gcc-g++-4.6.4.tar.gz" || bail
grab "gcc" "http://www.netgull.com/gcc/releases/gcc-6.3.0" "gcc-6.3.0.tar.gz" || bail
#grab "mpc" "http://www.multiprecision.org/mpc/download" "mpc-0.9.tar.gz"
#grab "mpfr" "http://www.mpfr.org/mpfr-3.0.1" "mpfr-3.0.1.tar.gz"
#grab "gmp" "ftp://ftp.gmplib.org/pub/gmp-5.0.1" "gmp-5.0.1.tar.gz"
grab "binutils" "http://ftp.gnu.org/gnu/binutils" "binutils-2.22.tar.gz" || bail
grab "binutils" "http://ftp.gnu.org/gnu/binutils" "binutils-2.27.tar.gz" || bail
grab "newlib" "http://b.dakko.us/~klange/mirrors" "newlib-1.19.0.tar.gz" || bail
grab "freetype" "http://download.savannah.gnu.org/releases/freetype" "freetype-2.4.9.tar.gz" || bail
grab "zlib" "http://zlib.net" "zlib-1.2.8.tar.gz" || bail
@ -35,14 +29,13 @@ pushd "$DIR" > /dev/null
grab "ncurses" "http://b.dakko.us/~klange/mirrors" "ncurses-5.9.tar.gz" || bail
grab "vim" "ftp://ftp.vim.org/pub/vim/unix" "vim-7.3.tar.bz2" || bail
$INFO "wget" "Pulled source packages."
rm -rf "binutils-2.22" "freetype-2.4.9" "gcc-4.6.4" "gmp-5.0.1" "libpng-1.5.13" "mpc-0.9" "mpfr-3.0.1" "newlib-1.19.0" "zlib-1.2.7" "pixman-0.28.2" "Mesa-7.5.2" "ncurses-5.9" "vim73"
rm -rf "binutils-2.27" "freetype-2.4.9" "gcc-6.3.0" "gmp-5.0.1" "libpng-1.5.13" "mpc-0.9" "mpfr-3.0.1" "newlib-1.19.0" "zlib-1.2.7" "pixman-0.28.2" "Mesa-7.5.2" "ncurses-5.9" "vim73"
$INFO "tar" "Decompressing..."
deco "gcc" "gcc-core-4.6.4.tar.gz" || bail
deco "g++" "gcc-g++-4.6.4.tar.gz" || bail
deco "gcc" "gcc-6.3.0.tar.gz" || bail
#deco "mpc" "mpc-0.9.tar.gz"
#deco "mpfr" "mpfr-3.0.1.tar.gz"
#deco "gmp" "gmp-5.0.1.tar.gz"
deco "binutils" "binutils-2.22.tar.gz" || bail
deco "binutils" "binutils-2.27.tar.gz" || bail
deco "newlib" "newlib-1.19.0.tar.gz" || bail
deco "freetype" "freetype-2.4.9.tar.gz" || bail
deco "zlib" "zlib-1.2.8.tar.gz" || bail
@ -54,11 +47,11 @@ pushd "$DIR" > /dev/null
deco "vim" "vim-7.3.tar.bz2" || bail
$INFO "tar" "Decompressed source packages."
$INFO "patch" "Patching..."
patc "gcc" "gcc-4.6.4" || bail
patc "gcc" "gcc-6.3.0" || bail
#patc "mpc" "mpc-0.9"
#patc "mpfr" "mpfr-3.0.1"
#patc "gmp" "gmp-5.0.1"
patc "binutils" "binutils-2.22" || bail
patc "binutils" "binutils-2.27" || bail
patc "newlib" "newlib-1.19.0" || bail
patc "freetype" "freetype-2.4.9" || bail
patc "libpng" "libpng-1.5.13" || bail

View File

@ -14,6 +14,10 @@
#include <pwd.h>
#include "lib/sha2.h"
#ifndef fgetpwent
extern struct passwd *fgetpwent(FILE *stream);
#endif
#define MASTER_PASSWD "/etc/master.passwd"
int toaru_auth_check_pass(char * user, char * pass) {