This is the current build for XOmB Bare Bones.

Since GDC is for all reasonable purposes dead in development, LDC is the current way to go. In this build, LDC is used to compile any D language code. You will not need a naked-compile of GDC to compile anymore.

We will no longer maintain GDC as a first priority.

Please check the wiki first for build instructions, check the README for a link.

Signed-off-by: The XOmB Overlord <overlord@xomb.org>
This commit is contained in:
wilkie
2009-02-24 08:55:10 +08:00
committed by The XOmB Overlord
parent 6d924a9fd7
commit dd1faf4d30
8 changed files with 229 additions and 54 deletions

1
build/.gitignore vendored
View File

@@ -2,3 +2,4 @@ dsss_objs/*
dsss.last
xomb.dump
xomb.iso
iso/boot/xomb

View File

@@ -4,11 +4,11 @@ CC = x86_64-pc-elf-gcc
CFLAGS = -nostdlib -nodefaultlibs -g -DUSE_ASSERT -mcmodel=kernel
[*]
buildflags=-dc=gdc-xomb
buildflags=-dc=ldc-xomb
[../kernel/core/kmain.d]
buildflags=-dc=gdc-xomb -I..
buildflags=-dc=ldc-xomb -I..
# compile the assembly for the target
@@ -18,9 +18,9 @@ prebuild= \
echo ; \
echo Compiling Assembly for target: x86_64 ;\
echo '--> boot.S';\
x86_64-pc-elf-gcc -nostdlib -nodefaultlibs -g -DUSE_ASSERT -mcmodel=kernel -c ../kernel/arch/x86_64/boot/boot.S -o dsss_objs/G/kernel.arch.x86_64.boot.boot.o ; \
gcc -nostdlib -nodefaultlibs -g -DUSE_ASSERT -mcmodel=kernel -c ../kernel/arch/x86_64/boot/boot.S -o dsss_objs/G/kernel.arch.x86_64.boot.boot.o ; \
echo '--> load.S';\
x86_64-pc-elf-gcc -nostdlib -nodefaultlibs -g -DUSE_ASSERT -mcmodel=kernel -c ../kernel/arch/x86_64/boot/load.S -o dsss_objs/G/kernel.arch.x86_64.boot.load.o ; \
gcc -nostdlib -nodefaultlibs -g -DUSE_ASSERT -mcmodel=kernel -c ../kernel/arch/x86_64/boot/load.S -o dsss_objs/G/kernel.arch.x86_64.boot.load.o ; \
#echo '--> trampoline.S';\
#x86_64-pc-elf-gcc -nostdlib -nodefaultlibs -g -DUSE_ASSERT -mcmodel=kernel -c ../kernel/arch/x86_64/boot/trampoline.S -o dsss_objs/G/kernel.arch.x86_64.boot.trampoline.o ;\
\
@@ -28,15 +28,17 @@ x86_64-pc-elf-gcc -nostdlib -nodefaultlibs -g -DUSE_ASSERT -mcmodel=kernel -c ..
echo ; \
echo Compiling Kernel Runtime ; \
echo '--> kernel/runtime/object.d';\
x86_64-pc-elf-gdc -nostdlib -nodefaultlibs -g -DUSE_ASSERT -mcmodel=kernel -I .. -I ../kernel/runtime/. -c ../kernel/runtime/object.d -o dsss_objs/G/kernel.runtime.object.o ;\
ldc -nodefaultlib -I.. -I../kernel/runtime/. -c ../kernel/runtime/object.d -ofdsss_objs/G/kernel.runtime.object.o; \
echo '--> kernel/runtime/invariant.d';\
x86_64-pc-elf-gdc -nostdlib -nodefaultlibs -g -DUSE_ASSERT -mcmodel=kernel -I .. -I ../kernel/runtime/. -c ../kernel/runtime/invariant.d -o dsss_objs/G/kernel.runtime.invariant.o ;\
ldc -nodefaultlib -g -I.. -I../kernel/runtime/. -c ../kernel/runtime/invariant.d -ofdsss_objs/G/kernel.runtime.invariant.o; \
echo '--> kernel/runtime/std/typeinfo/*';\
x86_64-pc-elf-gdmd -q,-nostdlib,-nodefaultlibs,-g,-DUSE_ASSERT,-mcmodel=kernel -I.. -I../kernel/runtime/. -c `ls ../kernel/runtime/std/typeinfo/*.d` -oddsss_objs/G/. ;\
ldc -nodefaultlib -g -I.. -I../kernel/runtime/. -c `ls ../kernel/runtime/std/typeinfo/*.d` -oddsss_objs/G/. ;\
echo '--> kernel/runtime/dstubs.d';\
x86_64-pc-elf-gdc -nostdlib -nodefaultlibs -g -DUSE_ASSERT -mcmodel=kernel -I .. -I ../kernel/runtime/. -c ../kernel/runtime/dstubs.d -o dsss_objs/G/kernel.runtime.dstubs.o ;\
ldc -nodefaultlib -g -I.. -I../kernel/runtime/. -c ../kernel/runtime/dstubs.d -ofdsss_objs/G/kernel.runtime.dstubs.o ;\
echo '--> kernel/runtime/util.d';\
x86_64-pc-elf-gdc -nostdlib -nodefaultlibs -g -DUSE_ASSERT -mcmodel=kernel -I .. -I ../kernel/runtime/. -c ../kernel/runtime/util.d -o dsss_objs/G/kernel.runtime.util.o ;\
ldc -nodefaultlib -g -I.. -I../kernel/runtime/. -c ../kernel/runtime/util.d -ofdsss_objs/G/kernel.runtime.util.o ;\
echo '--> kernel/runtime/std/moduleinit.d';\
ldc -nodefaultlib -g -I.. -I../kernel/runtime/. -c ../kernel/runtime/std/moduleinit.d -ofdsss_objs/G/kernel.runtime.std.moduleinit.o ;\
\
echo ; \
echo Compiling Kernel Proper ;
@@ -52,7 +54,9 @@ postbuild = \
echo ; \
echo Creating Kernel Executable; \
echo '--> xomb';\
x86_64-pc-elf-ld -nostdlib -nodefaultlibs -b elf64-x86-64 -T linker.ld -o iso/boot/xomb `ls dsss_objs/G/*.o`;\
#llvm-ld -native -Xlinker=-nostdlib -Xlinker=-Tlinker.ld -Xlinker="-b elf64-x86-64" `ls dsss_objs/G/*.o` -o iso/boot/xomb ; \
#llvm-ld -nodefaultlib -g -I.. -I../kernel/runtime/. `ls dsss_objs/G/*.o` ;\
ld -nostdlib -nodefaultlibs -b elf64-x86-64 -T linker.ld -o iso/boot/xomb `ls dsss_objs/G/*.o`;\
\
echo ;\
echo Creating Kernel Dump; \

View File

@@ -1,35 +0,0 @@
profile=phobos
compiler=x86_64-pc-elf-gdc
exeext=
objext=o
noversion=DigitalMars
version=GNU
testversion=linux
testversion=darwin
version=Unix
version=Posix
noversion=Windows
noversion=Win32
noversion=Win64
testversion=X86
testversion=PPC
testversion=X86_64
testversion=D_InlineAsm
testversion=D_InlineAsm_X86
testversion=D_InlineAsm_PPC
testversion=D_InlineAsm_X86_64
testversion=LittleEndian
testversion=BigEndian
[compile]
cmd=x86_64-pc-elf-gdmd -q,-nostdlib,-nodefaultlibs,-g,-DUSE_ASSERT,-mcmodel=kernel -I../kernel/runtime/ -c $i
[link]
cmd=#
[postlink]
cmd=echo "lol fuckers"

20
build/ldc-xomb Normal file
View File

@@ -0,0 +1,20 @@
profile=phobos
compiler=ldc
exeext=
objext=o
version=LDC
[compile]
cmd=ldc -nodefaultlib -g -I../kernel/runtime/ -c $i
[link]
cmd=#
[postlink]
cmd=echo "lol fuckers"

View File

@@ -11,12 +11,18 @@ import kernel.runtime.util;
import kernel.core.kprintf;
// magical gcc business (BEWARE THE MAGICAL EMPTY FILE!!!)
static import gcc.builtins;
version(GNU)
{
static import gcc.builtins;
}
extern(C)
{
alias gcc.builtins.__builtin_alloca alloca;
version(GNU)
{
alias gcc.builtins.__builtin_alloca alloca;
}
private
{
@@ -377,6 +383,7 @@ mixin(Stub!("void _d_delinterface(void** p)"));
mixin(Stub!("void _d_delclass(Object* p)"));
mixin(Stub!("Array _d_newarrayT(TypeInfo ti, size_t length)"));
mixin(Stub!("Array _d_newarrayiT(TypeInfo ti, size_t length)"));
mixin(Stub!("Array _d_newarrayvT(TypeInfo ti, size_t length)"));
mixin(Stub!("void[] _d_newarraymTp(TypeInfo ti, int ndims, size_t* pdim)"));
mixin(Stub!("void[] _d_newarraymiTp(TypeInfo ti, int ndims, size_t* pdim)"));
mixin(Stub!("void _d_delarray(Array *p)"));
@@ -391,6 +398,77 @@ mixin(Stub!("byte[] _d_arraycatT(TypeInfo ti, byte[] x, byte[] y)"));
mixin(Stub!("byte[] _d_arraycatnT(TypeInfo ti, uint n, ...)"));
mixin(Stub!("Array _adDupT(TypeInfo ti, Array a)"));
void[] _d_arraycase(uint tsize, uint fsize, void[] a)
{
uint length = a.length;
uint nbytes;
nbytes = length * fsize;
if (nbytes % tsize != 0)
{
// throw new Error ("array case misalignment");
}
length = nbytes / tsize;
*cast(uint *)&a = length;
return a;
}
template ArrayInit(char[] name, char[] type)
{
const char[] ArrayInit = `
void _d_array_init_` ~ name ~ `(` ~ type ~ `* a, size_t n, ` ~ type ~ ` v)
{
auto p = a;
auto end = a + n;
while (p !is end)
{
*p++ = v;
}
}
`;
}
mixin(ArrayInit!("i1", "bool"));
mixin(ArrayInit!("i8", "ubyte"));
mixin(ArrayInit!("i16", "ushort"));
mixin(ArrayInit!("i32", "uint"));
mixin(ArrayInit!("i64", "ulong"));
mixin(ArrayInit!("float", "float"));
mixin(ArrayInit!("double", "double"));
mixin(ArrayInit!("pointer", "void*"));
void _d_array_init_mem(void* a, size_t na, void* v, size_t nv)
{
auto p = a;
auto end = a + na * nv;
while (p !is end) {
memcpy(p,v,nv);
p+=nv;
}
}
// for array cast
size_t _d_array_cast_len(size_t len, size_t elemsz, size_t newelemsz)
{
if (newelemsz == 1)
{
return len*elemsz;
}
else if (len % newelemsz)
{
// throw new Exception("Bad array case");
}
return (len*elemsz)/newelemsz;
}
/**************************************************
GC stubs
**************************************************/
@@ -441,25 +519,25 @@ void _d_switch_error( char[] file, uint line )
private void onAssertError(char[] file, size_t line)
{
kprintfln!("Error in {}, line {}: assertion failed.")(file, line);
kprintfln!("Error in {}, line {}: assertion failed.")(file, "line");
asm { l: hlt; jmp l; }
}
private void onAssertErrorMsg(char[] file, size_t line, char[] msg)
{
kprintfln!("Error in {}, line {}: assertion failed: \"{}\"")(file, line, msg);
kprintfln!("Error in {}, line {}: assertion failed: \"{}\"")(file, "line", msg);
asm { l: hlt; jmp l; }
}
private void onArrayBoundsError(char[] file, size_t line)
{
kprintfln!("Error in {}, line {}: array index out of bounds.")(file, line);
kprintfln!("Error in {}, line {}: array index out of bounds.")(file, "line");
asm { l: hlt; jmp l; }
}
private void onSwitchError(char[] file, size_t line)
{
kprintfln!("Error in {}, line {}: switch has no case or default to handle the switched-upon value.")(file, line);
kprintfln!("Error in {}, line {}: switch has no case or default to handle the switched-upon value.")(file, "line");
asm { l: hlt; jmp l; }
}
@@ -828,7 +906,12 @@ Array _adReverse(Array a, size_t szelem)
tmp = buffer.ptr;
if (szelem > 16)
tmp = cast(byte*)alloca(szelem);
{
version(GNU)
{
tmp = cast(byte*)alloca(szelem);
}
}
for (; lo < hi; lo += szelem, hi -= szelem)
{
@@ -1011,4 +1094,7 @@ byte[] _d_arraycopy(size_t size, byte[] from, byte[] to)
return to;
}
mixin(Stub!("Object _d_allocclass(ClassInfo ci)"));
mixin(Stub!("void _d_throw_exception(Object e)"));
}

View File

@@ -5,7 +5,7 @@
* www.digitalmars.com
*/
void _d_invariant(Object o)
extern(C) void _d_invariant(Object o)
{
ClassInfo c;
@@ -15,7 +15,7 @@ void _d_invariant(Object o)
assert(o !is null); // just do null check, not invariant check
c = o.classinfo;
do
{
if(c.classInvariant)

View File

@@ -38,6 +38,11 @@ module object;
// Imports necessary routines used by the runtime
import kernel.runtime.util;
//version(LDC)
//{
import std.moduleinit;
//}
extern(C) Object _d_newclass(ClassInfo ci);
/// Standard boolean type.
@@ -309,6 +314,30 @@ class ClassInfo : Object
}
}
//version(LDC){
class ModuleInfo : Object
{
char[] name;
ModuleInfo[] importedModules;
ClassInfo[] localClasses;
uint flags; // initialization state
void function() ctor;
void function() dtor;
void function() unitTest;
void* xgetMembers;
void function() ictor;
// Return collection of all modules in the program.
static int opApply(int delegate(ref ModuleInfo));
}
//}
//private import std.string;
/**

View File

@@ -0,0 +1,70 @@
// Written in the D programming language
module std.moduleinit;
//debug = 1;
//private
//{
// import object;
//}
/*
enum
{
MIctorstart = 1, // we've started constructing it
MIctordone = 2, // finished construction
MIstandalone = 4, // module ctor does not depend on other module
// ctors being done first
MIhasictor = 8, // has ictor member
}
*/
// Start of the module linked list
struct ModuleReference
{
ModuleReference* next;
ModuleInfo mod;
}
extern(C) ModuleReference* _Dmodule_ref;
//ModuleInfo[] _moduleinfo_dtors;
uint _moduleinfo_dtors_i;
// Register termination function pointers
//extern (C) int _fatexit(void *);
/*************************************
* Initialize the modules.
*/
extern (C) void _moduleCtor()
{
}
/**********************************
* Destruct the modules.
*/
// Starting the name with "_STD" means under linux a pointer to the
// function gets put in the .dtors segment.
extern (C) void _moduleDtor()
{
}
/**********************************
* Run unit tests.
*/
extern (C) void _moduleUnitTests()
{
}
/**********************************
* Run unit tests.
*/
extern (C) void _moduleIndependentCtors()
{
}