1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

freestanding: add array support (stack only for now)

This commit is contained in:
bogen85
2019-12-01 02:27:36 -06:00
committed by Alexander Medvednikov
parent 3fea8f3de5
commit 854309a7d8
9 changed files with 235 additions and 49 deletions

View File

@ -126,7 +126,7 @@ fn (v mut V) cc() {
v.out_name = v.out_name + '.so'
}
if v.pref.is_bare {
a << '-static -ffreestanding -nostdlib $vdir/vlib/os/bare/bare.S'
a << '-fno-stack-protector -static -ffreestanding -nostdlib $vdir/vlib/os/bare/bare.S'
}
if v.pref.build_mode == .build_module {
// Create the modules & out directory if it's not there.
@ -263,7 +263,7 @@ fn (v mut V) cc() {
a << libs
// Without these libs compilation will fail on Linux
// || os.user_os() == 'linux'
if v.pref.build_mode != .build_module && (v.os == .linux || v.os == .freebsd || v.os == .openbsd ||
if !v.pref.is_bare && v.pref.build_mode != .build_module && (v.os == .linux || v.os == .freebsd || v.os == .openbsd ||
v.os == .netbsd || v.os == .dragonfly || v.os == .solaris) {
a << '-lm -lpthread '
// -ldl is a Linux only thing. BSDs have it in libc.
@ -272,7 +272,7 @@ fn (v mut V) cc() {
}
}
if v.os == .js && os.user_os() == 'linux' {
if !v.pref.is_bare && v.os == .js && os.user_os() == 'linux' {
a << '-lm'
}

View File

@ -206,4 +206,17 @@ typedef map map_string;
#define false 0
#endif
'
bare_c_headers = '
#define EMPTY_ARRAY_OF_ELEMS(x,n) (x[])
#define TCCSKIP(x) x
#ifdef __TINYC__
#undef EMPTY_ARRAY_OF_ELEMS
#define EMPTY_ARRAY_OF_ELEMS(x,n) (x[n])
#undef TCCSKIP
#define TCCSKIP(x)
#endif
'
)

View File

@ -254,6 +254,8 @@ pub fn (v mut V) compile() {
if !v.pref.is_bare {
cgen.genln(c_headers)
} else {
cgen.genln(bare_c_headers)
}
}
v.generate_hotcode_reloading_declarations()