cl:compile with clang++
This commit is contained in:
@@ -490,6 +490,8 @@ func linkMainPkg(ctx *context, pkg *packages.Package, pkgs []*aPackage, conf *Co
|
|||||||
}
|
}
|
||||||
linkArgs = append(linkArgs, exargs...)
|
linkArgs = append(linkArgs, exargs...)
|
||||||
|
|
||||||
|
fmt.Fprintf(os.Stderr, "linkArgs: %v\n", linkArgs)
|
||||||
|
|
||||||
err = compileAndLinkLLFiles(ctx, app, llFiles, linkArgs, verbose)
|
err = compileAndLinkLLFiles(ctx, app, llFiles, linkArgs, verbose)
|
||||||
check(err)
|
check(err)
|
||||||
|
|
||||||
|
|||||||
@@ -1,35 +1,33 @@
|
|||||||
typedef union
|
typedef union {
|
||||||
{
|
|
||||||
double d;
|
double d;
|
||||||
float f;
|
float f;
|
||||||
long v;
|
long v;
|
||||||
long long ll;
|
long long ll;
|
||||||
} castUnion;
|
} castUnion;
|
||||||
|
|
||||||
double llgoToFloat64(long long v)
|
extern "C" {
|
||||||
{
|
|
||||||
|
double llgoToFloat64(long long v) {
|
||||||
castUnion k;
|
castUnion k;
|
||||||
k.ll = v;
|
k.ll = v;
|
||||||
return k.d;
|
return k.d;
|
||||||
}
|
}
|
||||||
|
|
||||||
float llgoToFloat32(int v)
|
float llgoToFloat32(int v) {
|
||||||
{
|
|
||||||
castUnion k;
|
castUnion k;
|
||||||
k.v = v;
|
k.v = v;
|
||||||
return k.f;
|
return k.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
long long llgoFromFloat64(double v)
|
long long llgoFromFloat64(double v) {
|
||||||
{
|
|
||||||
castUnion k;
|
castUnion k;
|
||||||
k.d = v;
|
k.d = v;
|
||||||
return k.ll;
|
return k.ll;
|
||||||
}
|
}
|
||||||
|
|
||||||
int llgoFromFloat32(float v)
|
int llgoFromFloat32(float v) {
|
||||||
{
|
|
||||||
castUnion k;
|
castUnion k;
|
||||||
k.f = v;
|
k.f = v;
|
||||||
return k.v;
|
return k.v;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@@ -19,7 +19,7 @@ package bitcast
|
|||||||
import _ "unsafe"
|
import _ "unsafe"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
LLGoFiles = "_cast/cast.c"
|
LLGoFiles = "_cast/cast.cpp"
|
||||||
LLGoPackage = "link"
|
LLGoPackage = "link"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -9,13 +9,11 @@
|
|||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <libunwind.h>
|
#include <libunwind.h>
|
||||||
|
|
||||||
void *llgo_address() {
|
extern "C" {
|
||||||
return __builtin_return_address(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int llgo_addrinfo(void *addr, Dl_info *info) {
|
void *llgo_address() { return __builtin_return_address(0); }
|
||||||
return dladdr(addr, info);
|
|
||||||
}
|
int llgo_addrinfo(void *addr, Dl_info *info) { return dladdr(addr, info); }
|
||||||
|
|
||||||
void llgo_stacktrace(int skip, void *ctx, int (*fn)(void *ctx, void *pc, void *offset, void *sp, char *name)) {
|
void llgo_stacktrace(int skip, void *ctx, int (*fn)(void *ctx, void *pc, void *offset, void *sp, char *name)) {
|
||||||
unw_cursor_t cursor;
|
unw_cursor_t cursor;
|
||||||
@@ -33,9 +31,10 @@ void llgo_stacktrace(int skip, void *ctx, int (*fn)(void *ctx, void *pc, void *o
|
|||||||
if (unw_get_reg(&cursor, UNW_REG_IP, &pc) == 0) {
|
if (unw_get_reg(&cursor, UNW_REG_IP, &pc) == 0) {
|
||||||
unw_get_proc_name(&cursor, fname, sizeof(fname), &offset);
|
unw_get_proc_name(&cursor, fname, sizeof(fname), &offset);
|
||||||
unw_get_reg(&cursor, UNW_REG_SP, &sp);
|
unw_get_reg(&cursor, UNW_REG_SP, &sp);
|
||||||
if (fn(ctx, (void*)pc, (void*)offset, (void*)sp, fname) == 0) {
|
if (fn(ctx, (void *)pc, (void *)offset, (void *)sp, fname) == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
LLGoFiles = "_wrap/debug.c"
|
LLGoFiles = "_wrap/debug.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Info struct {
|
type Info struct {
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ func (p *Cmd) execWithFlags(flags []string, args ...string) error {
|
|||||||
if p.Env != nil {
|
if p.Env != nil {
|
||||||
cmd.Env = p.Env
|
cmd.Env = p.Env
|
||||||
}
|
}
|
||||||
|
fmt.Fprintln(os.Stderr, cmd.String())
|
||||||
return cmd.Run()
|
return cmd.Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,6 +132,8 @@ func (p *Cmd) CheckLinkArgs(cmdArgs []string, wasm bool) error {
|
|||||||
srcIn := strings.NewReader(src)
|
srcIn := strings.NewReader(src)
|
||||||
p.Stdin = srcIn
|
p.Stdin = srcIn
|
||||||
|
|
||||||
|
fmt.Fprintf(os.Stderr, "args: %v\n", args)
|
||||||
|
|
||||||
// Execute the command
|
// Execute the command
|
||||||
return p.execWithFlags([]string{"LDFLAGS", "CCFLAGS"}, args...)
|
return p.execWithFlags([]string{"LDFLAGS", "CCFLAGS"}, args...)
|
||||||
}
|
}
|
||||||
|
|||||||
2
xtool/env/llvm/llvm.go
vendored
2
xtool/env/llvm/llvm.go
vendored
@@ -72,7 +72,7 @@ func (e *Env) BinDir() string { return e.binDir }
|
|||||||
|
|
||||||
// Clang returns a new [clang.Cmd] instance.
|
// Clang returns a new [clang.Cmd] instance.
|
||||||
func (e *Env) Clang() *clang.Cmd {
|
func (e *Env) Clang() *clang.Cmd {
|
||||||
bin := filepath.Join(e.BinDir(), "clang")
|
bin := filepath.Join(e.BinDir(), "clang++")
|
||||||
return clang.New(bin)
|
return clang.New(bin)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user