From 79e8921f76806f55aaef7acba94b1be671862eff Mon Sep 17 00:00:00 2001 From: visualfc Date: Fri, 21 Jun 2024 07:55:17 +0800 Subject: [PATCH] x/build: overlayFiles for fix math on amd64 --- internal/build/build.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/internal/build/build.go b/internal/build/build.go index 07257c8c3..eef97323c 100644 --- a/internal/build/build.go +++ b/internal/build/build.go @@ -111,6 +111,10 @@ const ( loadSyntax = loadTypes | packages.NeedSyntax | packages.NeedTypesInfo ) +var overlayFiles = map[string]string{ + "math/exp_amd64.go": "package math;", +} + func Do(args []string, conf *Config) { flags, patterns, verbose := ParseArgs(args, buildFlags) cfg := &packages.Config{ @@ -119,6 +123,13 @@ func Do(args []string, conf *Config) { Fset: token.NewFileSet(), } + if len(overlayFiles) > 0 { + cfg.Overlay = make(map[string][]byte) + for file, src := range overlayFiles { + cfg.Overlay[filepath.Join(runtime.GOROOT(), "src", file)] = []byte(src) + } + } + llssa.Initialize(llssa.InitAll) if verbose { llssa.SetDebug(llssa.DbgFlagAll)