Merge branch 'newlib'

This commit is contained in:
Giacomo Tesio 2017-04-19 23:14:02 +02:00
commit eb37bc6013
7 changed files with 74 additions and 28 deletions

3
.gitmodules vendored
View File

@ -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

View File

@ -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 }, \

6
cross/pkgs/README.txt Normal file
View File

@ -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.

35
cross/pkgs/newlib.sh Normal file
View File

@ -0,0 +1,35 @@
#!/bin/bash
# This file is part of Jehanne.
#
# Copyright (C) 2017 Giacomo Tesio <giacomo@tesio.it>
#
# 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 <http://www.gnu.org/licenses/>.
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
}

1
cross/pkgs/newlib/src Submodule

@ -0,0 +1 @@
Subproject commit 0f0315dbffeb30149c5746dedd307dc1f12eb317

View File

@ -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-

View File

@ -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)
}
}