Skip to content

Commit 1728ce0

Browse files
committed
remove malloc and friends
1 parent ead5efa commit 1728ce0

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

builder/build.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,15 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
851851
if fn := mod.NamedFunction("main"); !fn.IsNil() {
852852
fn.EraseFromParentAsFunction()
853853
}
854+
for _, name := range []string{"malloc", "calloc", "free"} {
855+
if fn := mod.NamedFunction(name); !fn.IsNil() {
856+
fn2 := llvm.AddFunction(mod, "__"+name, fn.Type())
857+
fn2.SetLinkage(llvm.ExternalLinkage)
858+
fn.ReplaceAllUsesWith(fn2)
859+
fn.EraseFromParentAsFunction()
860+
fn2.SetName(name)
861+
}
862+
}
854863
if config.Triple() == "xtensa" {
855864
for fn := mod.FirstFunction(); !fn.IsNil(); fn = llvm.NextFunction(fn) {
856865
if strings.HasPrefix(fn.Name(), "__atomic_") ||

0 commit comments

Comments
 (0)