build: support multiple link files in a package

This commit is contained in:
xushiwei
2024-05-08 18:57:14 +08:00
parent b0b38c02b2
commit 879e4a0061
11 changed files with 164 additions and 42 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 The GoPlus Authors (goplus.org). All rights reserved.
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,12 +14,37 @@
* limitations under the License.
*/
package gocmd
package llvmlink
import (
"io"
"os"
"os/exec"
)
// -----------------------------------------------------------------------------
type BuildConfig struct {
Output string
// Cmd represents a llvm-link command.
type Cmd struct {
app string
Stdout io.Writer
Stderr io.Writer
}
// New creates a new llvm-link command.
func New(app string) *Cmd {
if app == "" {
app = os.Getenv("LLGO_LLVM_ROOT") + "/bin/llvm-link"
}
return &Cmd{app, os.Stdout, os.Stderr}
}
func (p *Cmd) Exec(args ...string) error {
cmd := exec.Command(p.app, args...)
cmd.Stdout = p.Stdout
cmd.Stderr = p.Stderr
return cmd.Run()
}
// -----------------------------------------------------------------------------

View File

@@ -4,7 +4,7 @@
"cd build.dir",
"../sqlite/configure",
"make",
"clang -emit-llvm -S -o sqlite3.ll -c sqlite3.c",
"$LLGO_LLVM_ROOT/bin/llvm-link -o ../llgo_autogen.bc ../sqlite.ll sqlite3.ll",
"clang -emit-llvm -S -o ../llgo_autogen.ll -c sqlite3.c",
"cd ..; rm llgo_autogen.lla; zip llgo_autogen.lla llgo_autogen.ll sqlite.ll",
]
}

Binary file not shown.

View File

@@ -209,13 +209,15 @@ func (*Stmt) BindInt(idx Int, val Int) Errno { return 0 }
// llgo:link (*Stmt).BindInt64 C.sqlite3_bind_int64
func (*Stmt) BindInt64(idx Int, val int64) Errno { return 0 }
/*
const (
Static Int = 0 // val is a static string
Transient Int = -1 // val is a transient (temporary) string
Static = (func(Pointer))(nil) // val is a static string
Transient = (func(Pointer))(-1) // val is a transient (temporary) string
)
*/
// llgo:link (*Stmt).BindText C.sqlite3_bind_text
func (*Stmt) BindText(idx Int, val *Char, lenOrKind Int, destructor func(Pointer)) Errno { return 0 }
func (*Stmt) BindText(idx Int, val *Char, nByte Int, destructor func(Pointer)) Errno { return 0 }
// -----------------------------------------------------------------------------