llvm cpu features
Этот коммит содержится в:
родитель
4442b1304e
коммит
0ae467d3e2
3 изменённых файлов: 9 добавлений и 1 удалений
|
@ -30,6 +30,7 @@ func init() {
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Triple string // LLVM target triple, e.g. x86_64-unknown-linux-gnu (empty string means default)
|
Triple string // LLVM target triple, e.g. x86_64-unknown-linux-gnu (empty string means default)
|
||||||
CPU string // LLVM CPU name, e.g. atmega328p (empty string means default)
|
CPU string // LLVM CPU name, e.g. atmega328p (empty string means default)
|
||||||
|
Features []string // LLVM CPU features
|
||||||
GOOS string //
|
GOOS string //
|
||||||
GOARCH string //
|
GOARCH string //
|
||||||
GC string // garbage collection strategy
|
GC string // garbage collection strategy
|
||||||
|
@ -101,7 +102,11 @@ func NewCompiler(pkgName string, config Config) (*Compiler, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
c.machine = target.CreateTargetMachine(config.Triple, config.CPU, "", llvm.CodeGenLevelDefault, llvm.RelocStatic, llvm.CodeModelDefault)
|
features := ""
|
||||||
|
if len(config.Features) > 0 {
|
||||||
|
features = strings.Join(config.Features, `,`)
|
||||||
|
}
|
||||||
|
c.machine = target.CreateTargetMachine(config.Triple, config.CPU, features, llvm.CodeGenLevelDefault, llvm.RelocStatic, llvm.CodeModelDefault)
|
||||||
c.targetData = c.machine.CreateTargetData()
|
c.targetData = c.machine.CreateTargetData()
|
||||||
|
|
||||||
c.ctx = llvm.NewContext()
|
c.ctx = llvm.NewContext()
|
||||||
|
|
1
main.go
1
main.go
|
@ -94,6 +94,7 @@ func Compile(pkgName, outpath string, spec *TargetSpec, config *BuildConfig, act
|
||||||
compilerConfig := compiler.Config{
|
compilerConfig := compiler.Config{
|
||||||
Triple: spec.Triple,
|
Triple: spec.Triple,
|
||||||
CPU: spec.CPU,
|
CPU: spec.CPU,
|
||||||
|
Features: spec.Features,
|
||||||
GOOS: spec.GOOS,
|
GOOS: spec.GOOS,
|
||||||
GOARCH: spec.GOARCH,
|
GOARCH: spec.GOARCH,
|
||||||
GC: config.gc,
|
GC: config.gc,
|
||||||
|
|
|
@ -24,6 +24,7 @@ type TargetSpec struct {
|
||||||
Inherits []string `json:"inherits"`
|
Inherits []string `json:"inherits"`
|
||||||
Triple string `json:"llvm-target"`
|
Triple string `json:"llvm-target"`
|
||||||
CPU string `json:"cpu"`
|
CPU string `json:"cpu"`
|
||||||
|
Features []string `json:"features"`
|
||||||
GOOS string `json:"goos"`
|
GOOS string `json:"goos"`
|
||||||
GOARCH string `json:"goarch"`
|
GOARCH string `json:"goarch"`
|
||||||
BuildTags []string `json:"build-tags"`
|
BuildTags []string `json:"build-tags"`
|
||||||
|
@ -52,6 +53,7 @@ func (spec *TargetSpec) copyProperties(spec2 *TargetSpec) {
|
||||||
if spec2.CPU != "" {
|
if spec2.CPU != "" {
|
||||||
spec.CPU = spec2.CPU
|
spec.CPU = spec2.CPU
|
||||||
}
|
}
|
||||||
|
spec.Features = append(spec.Features, spec2.Features...)
|
||||||
if spec2.GOOS != "" {
|
if spec2.GOOS != "" {
|
||||||
spec.GOOS = spec2.GOOS
|
spec.GOOS = spec2.GOOS
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче