x64: use correct exe name and set +x

pull/2854/head
Alexander Medvednikov 2019-11-22 18:33:02 +03:00
parent c11025f01f
commit 94318b1287
5 changed files with 24 additions and 22 deletions

View File

@ -46,7 +46,7 @@ jobs:
- name: Bare metal
run: ./v -freestanding -o bare vlib/os/bare/bare_example_linux.v
- name: x64 machine code generation
run: ./v -x64 examples/x64/hello_world.v
run: cd examples/x64 && ./v -x64 hello_world.v && ./hello_world
build-ubuntu-tcc:
runs-on: ubuntu-18.04

View File

@ -1,25 +1,6 @@
module compiler
import filepath
//import filepath
//import compiler.x64
pub fn (v mut V) compile_x64() {
$if !linux {
println('v -x64 can only generate Linux binaries for now')
println('You are not on a Linux system, so you will not ' +
'be able to run the resulting executable')
}
v.files << v.v_files_from_dir(filepath.join(v.pref.vlib_path, 'builtin', 'bare'))
v.files << v.dir
v.x64.generate_elf_header()
for f in v.files {
v.parse(f, .decl)
}
for f in v.files {
v.parse(f, .main)
}
v.x64.generate_elf_footer()
}

View File

@ -347,6 +347,26 @@ pub fn (v mut V) compile() {
v.cc()
}
pub fn (v mut V) compile_x64() {
$if !linux {
println('v -x64 can only generate Linux binaries for now')
println('You are not on a Linux system, so you will not ' +
'be able to run the resulting executable')
}
v.files << v.v_files_from_dir(filepath.join(v.pref.vlib_path, 'builtin', 'bare'))
v.files << v.dir
v.x64.generate_elf_header()
for f in v.files {
v.parse(f, .decl)
}
for f in v.files {
v.parse(f, .main)
}
v.x64.generate_elf_footer()
}
fn (v mut V) generate_init() {
$if js { return }
if v.pref.build_mode == .build_module {

View File

@ -88,7 +88,8 @@ pub fn (g mut Gen) generate_elf_footer() {
g.write64_at(file_size, g.file_size_pos) // set file size 64 bit value
g.write64_at(file_size, g.file_size_pos+8)
// Create the binary
f := os.create('out.bin') or { panic(err) }
f := os.create(g.out_name) or { panic(err) }
C.chmod(g.out_name.str, 0775)
f.write_bytes(g.buf.data, g.buf.len)
f.close()
println('x64 elf binary has been successfully generated')