From 13e1540deb201a6d139ba6b90ad24bc801b91320 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Thu, 30 Mar 2017 16:05:53 +0200 Subject: [PATCH 1/4] devshell.sh: set CPATH for cross compiling --- devshell.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/devshell.sh b/devshell.sh index 4a64154..703f04d 100755 --- a/devshell.sh +++ b/devshell.sh @@ -7,6 +7,7 @@ export JEHANNE=`git rev-parse --show-toplevel` export PATH="$JEHANNE/hacking/bin:$PATH" export PATH="$JEHANNE/hacking/cross/toolchain/bin:$PATH" +export CPATH="$JEHANNE/hacking/cross/toolchain/lib/gcc/x86_64-jehanne/4.9.4/include:$JEHANNE/hacking/cross/toolchain/lib/gcc/x86_64-jehanne/4.9.4/include-fixed" export ARCH=amd64 export TOOLPREFIX=x86_64-jehanne- From b60ed180666e3247d36bd793edea229a2676e147 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Tue, 11 Apr 2017 18:21:56 +0200 Subject: [PATCH 2/4] ksyscalls use libc ns --- src/jehanne/cmd/ksyscalls/ksyscalls.go | 46 +++++++++++++------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/jehanne/cmd/ksyscalls/ksyscalls.go b/src/jehanne/cmd/ksyscalls/ksyscalls.go index c50d0e6..4125e71 100644 --- a/src/jehanne/cmd/ksyscalls/ksyscalls.go +++ b/src/jehanne/cmd/ksyscalls/ksyscalls.go @@ -97,18 +97,18 @@ func sysret(t string) string { func formatArg(i int, t string) string{ switch(t){ case "int", "int32_t": - return fmt.Sprintf("\tfmtprint(fmt, \" %%d\", a%d);\n", i) + return fmt.Sprintf("\tjehanne_fmtprint(fmt, \" %%d\", a%d);\n", i) case "unsigned int", "uint32_t": /* unsigned int is reserved for flags */ - return fmt.Sprintf("\tfmtprint(fmt, \" %%#ux\", a%d);\n", i) + return fmt.Sprintf("\tjehanne_fmtprint(fmt, \" %%#ux\", a%d);\n", i) case "long", "int64_t": - return fmt.Sprintf("\tfmtprint(fmt, \" %%lld\", a%d);\n", i) + return fmt.Sprintf("\tjehanne_fmtprint(fmt, \" %%lld\", a%d);\n", i) case "unsigned long", "uint64_t": - return fmt.Sprintf("\tfmtprint(fmt, \" %%#lud\", a%d);\n", i) + return fmt.Sprintf("\tjehanne_fmtprint(fmt, \" %%#lud\", a%d);\n", i) case "void*", "uint8_t*", "const void*", "const uint8_t*": - return fmt.Sprintf("\tfmtprint(fmt, \" %%#p\", a%d);\n", i) + return fmt.Sprintf("\tjehanne_fmtprint(fmt, \" %%#p\", a%d);\n", i) case "int32_t*", "int*", "const int32_t*", "const int*": - return fmt.Sprintf("\tfmtprint(fmt, \" %%#p(%%d)\", a%d, a%d);\n", i, i) + return fmt.Sprintf("\tjehanne_fmtprint(fmt, \" %%#p(%%d)\", a%d, a%d);\n", i, i) case "const char*", "char*": return fmt.Sprintf("\tfmtuserstring(fmt, a%d);\n", i) case "const char**", "char**": @@ -120,18 +120,18 @@ func formatArg(i int, t string) string{ func formatRet(t string) string{ switch(t){ case "int", "int32_t": - return fmt.Sprintf("\tfmtprint(fmt, \" %%d\", ret->%s);\n", sysret(t)) + return fmt.Sprintf("\tjehanne_fmtprint(fmt, \" %%d\", ret->%s);\n", sysret(t)) case "unsigned int", "uint32_t": /* unsigned int is reserved for flags */ - return fmt.Sprintf("\tfmtprint(fmt, \" %%#ux\", ret->%s);\n", sysret(t)) + return fmt.Sprintf("\tjehanne_fmtprint(fmt, \" %%#ux\", ret->%s);\n", sysret(t)) case "long", "int64_t": - return fmt.Sprintf("\tfmtprint(fmt, \" %%lld\", ret->%s);\n", sysret(t)) + return fmt.Sprintf("\tjehanne_fmtprint(fmt, \" %%lld\", ret->%s);\n", sysret(t)) case "unsigned long", "uint64_t", "void": - return fmt.Sprintf("\tfmtprint(fmt, \" %%#llud\", ret->%s);\n", sysret(t)) + return fmt.Sprintf("\tjehanne_fmtprint(fmt, \" %%#llud\", ret->%s);\n", sysret(t)) case "void*", "uintptr_t", "const void*", "const uintptr_t": - return fmt.Sprintf("\tfmtprint(fmt, \" %%#p\", ret->%s);\n", sysret(t)) + return fmt.Sprintf("\tjehanne_fmtprint(fmt, \" %%#p\", ret->%s);\n", sysret(t)) case "int32_t*", "int*", "const int32_t*", "const int*": - return fmt.Sprintf("\tfmtprint(fmt, \" %%#p(%%d)\", ret->%s, *ret->%s);\n", sysret(t), sysret(t)) + return fmt.Sprintf("\tjehanne_fmtprint(fmt, \" %%#p(%%d)\", ret->%s, *ret->%s);\n", sysret(t), sysret(t)) } return " [?? " + t + "]" } @@ -285,7 +285,7 @@ enter_{{ .Name }}(Fmt* fmt, Ureg* ureg) {{ range .Vars }}{{.}} {{ end }} {{ .CommonCode }} - fmtprint(fmt, "{{ .Name }} %#p > ", ureg->ip); + jehanne_fmtprint(fmt, "{{ .Name }} %#p > ", ureg->ip); {{ .EntryPrint }} } {{ end }} @@ -294,8 +294,8 @@ char* syscallfmt(int syscall, Ureg* ureg) { Fmt fmt; - fmtstrinit(&fmt); - fmtprint(&fmt, "%d %s ", up->pid, up->text); + jehanne_fmtstrinit(&fmt); + jehanne_fmtprint(&fmt, "%d %s ", up->pid, up->text); switch(syscall){ {{ range .Wrappers }}case {{ .Id }}: @@ -306,14 +306,14 @@ syscallfmt(int syscall, Ureg* ureg) panic("syscallfmt: bad sys call number %d pc %#p\n", syscall, ureg->ip); } - return fmtstrflush(&fmt); + return jehanne_fmtstrflush(&fmt); } {{ range .Wrappers }} static void exit_{{ .Name }}(Fmt* fmt, Ureg* ureg, ScRet* ret) { - fmtprint(fmt, "{{ .Name }} %#p < ", ureg->ip); + jehanne_fmtprint(fmt, "{{ .Name }} %#p < ", ureg->ip); {{ .ExitPrint }} } {{ end }} @@ -322,8 +322,8 @@ char* sysretfmt(int syscall, Ureg* ureg, ScRet* ret, uint64_t start, uint64_t stop) { Fmt fmt; - fmtstrinit(&fmt); - fmtprint(&fmt, "%d %s ", up->pid, up->text); + jehanne_fmtstrinit(&fmt); + jehanne_fmtprint(&fmt, "%d %s ", up->pid, up->text); switch(syscall){ {{ range .Wrappers }}case {{ .Id }}: @@ -335,12 +335,12 @@ sysretfmt(int syscall, Ureg* ureg, ScRet* ret, uint64_t start, uint64_t stop) } if(0 > ret->vl){ - fmtprint(&fmt, " %s %#llud %#llud\n", up->syserrstr, start, stop-start); + jehanne_fmtprint(&fmt, " %s %#llud %#llud\n", up->syserrstr, start, stop-start); } else { - fmtprint(&fmt, " \"\" %#llud %#llud\n", start, stop-start); + jehanne_fmtprint(&fmt, " \"\" %#llud %#llud\n", start, stop-start); } - return fmtstrflush(&fmt); + return jehanne_fmtstrflush(&fmt); } `) @@ -371,4 +371,4 @@ func main() { generateKernelCode(sysconf.Syscalls) -} \ No newline at end of file +} From 372896ff415056ea9a610259a610d342efb9a104 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Wed, 19 Apr 2017 17:03:53 +0200 Subject: [PATCH 3/4] gcc: posix include directories under /sys/posix/ --- cross/patch/gcc/gcc/config/jehanne.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cross/patch/gcc/gcc/config/jehanne.h b/cross/patch/gcc/gcc/config/jehanne.h index 9dc2aac..71f48d7 100644 --- a/cross/patch/gcc/gcc/config/jehanne.h +++ b/cross/patch/gcc/gcc/config/jehanne.h @@ -30,10 +30,10 @@ #define MD_STARTFILE_PREFIX "/arch/amd64/lib/" #undef GPLUSPLUS_INCLUDE_DIR -#define GPLUSPLUS_INCLUDE_DIR "/posix/include/g++" +#define GPLUSPLUS_INCLUDE_DIR "/sys/posix/g++" #undef GCC_INCLUDE_DIR -#define GCC_INCLUDE_DIR "/posix/include/gcc" +#define GCC_INCLUDE_DIR "/sys/posix/gcc" /* Architecture specific header (u.h) goes here (from config.gcc) */ #define ARCH_INCLUDE_DIR NATIVE_SYSTEM_HEADER_DIR @@ -41,15 +41,15 @@ /* The default include dir is /sys/include but... */ #define PORTABLE_INCLUDE_DIR "/sys/include" -/* ...we have to wrap libc.h and stdio.h with POSIX headers */ -#define POSIX_INCLUDE_DIR "/sys/include/apw" +/* ...we have to wrap libc.h and stdio.h with basic POSIX headers */ +#define BASIC_POSIX_INCLUDE_DIR "/sys/include/apw" #undef INCLUDE_DEFAULTS #define INCLUDE_DEFAULTS \ { \ { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, 1, 0 }, \ { GCC_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ - { POSIX_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ + { BASIC_POSIX_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ { ARCH_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ { PORTABLE_INCLUDE_DIR, 0, 0, 0, 1, 0 }, \ { ".", 0, 0, 0, 1, 0 }, \ From b07c09e087d148771141a6294f33913a5920e04f Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Wed, 19 Apr 2017 23:08:16 +0200 Subject: [PATCH 4/4] newlib: setup newlib sources --- .gitmodules | 3 +++ cross/pkgs/README.txt | 6 ++++++ cross/pkgs/newlib.sh | 35 +++++++++++++++++++++++++++++++++++ cross/pkgs/newlib/src | 1 + 4 files changed, 45 insertions(+) create mode 100644 cross/pkgs/README.txt create mode 100644 cross/pkgs/newlib.sh create mode 160000 cross/pkgs/newlib/src diff --git a/.gitmodules b/.gitmodules index 79df54f..177274c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,3 +5,6 @@ [submodule "third_party/src/github.com/0intro/drawterm"] path = third_party/src/github.com/0intro/drawterm url = https://github.com/JehanneOS/devtools-drawterm.git +[submodule "cross/pkgs/newlib/src"] + path = cross/pkgs/newlib/src + url = https://github.com/JehanneOS/newlib.git diff --git a/cross/pkgs/README.txt b/cross/pkgs/README.txt new file mode 100644 index 0000000..a461ba8 --- /dev/null +++ b/cross/pkgs/README.txt @@ -0,0 +1,6 @@ +# Jehanne cross-compiled packages + +This folder contains those development tools that need to be +cross-compiled to bootstrap a selfhosted system. + +Mainly this means a native compiler and its dependencies. diff --git a/cross/pkgs/newlib.sh b/cross/pkgs/newlib.sh new file mode 100644 index 0000000..1f106f3 --- /dev/null +++ b/cross/pkgs/newlib.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# This file is part of Jehanne. +# +# Copyright (C) 2017 Giacomo Tesio +# +# Jehanne is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 2 of the License. +# +# Jehanne is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Jehanne. If not, see . + +if [ "$JEHANNE" = "" ]; then + echo $0 requires the shell started by ./hacking/devshell.sh + exit 1 +fi + +# To create a Jehanne version of GCC, we need specific OUTDATED versions +# of Autotools that won't compile easily in a modern Linux distro. + +function failOnError { + # $1 -> exit status on a previous command + # $2 -> task description + if [ $1 -ne 0 ]; then + echo "ERROR $2" + exit $1 + fi +} + diff --git a/cross/pkgs/newlib/src b/cross/pkgs/newlib/src new file mode 160000 index 0000000..0f0315d --- /dev/null +++ b/cross/pkgs/newlib/src @@ -0,0 +1 @@ +Subproject commit 0f0315dbffeb30149c5746dedd307dc1f12eb317