Skip to content

Commit 0fdf08d

Browse files
dgryskideadprogram
authored andcommitted
add -nobounds (similar to -gcflags=-B)
1 parent 133e32c commit 0fdf08d

File tree

5 files changed

+9
-0
lines changed

5 files changed

+9
-0
lines changed

builder/build.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
214214
MaxStackAlloc: config.MaxStackAlloc(),
215215
NeedsStackObjects: config.NeedsStackObjects(),
216216
Debug: !config.Options.SkipDWARF, // emit DWARF except when -internal-nodwarf is passed
217+
Nobounds: config.Options.Nobounds,
217218
PanicStrategy: config.PanicStrategy(),
218219
}
219220

compileopts/options.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type Options struct {
4343
PrintCommands func(cmd string, args ...string) `json:"-"`
4444
Semaphore chan struct{} `json:"-"` // -p flag controls cap
4545
Debug bool
46+
Nobounds bool
4647
PrintSizes string
4748
PrintAllocs *regexp.Regexp // regexp string
4849
PrintStacks bool

compiler/compiler.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ type Config struct {
5858
MaxStackAlloc uint64
5959
NeedsStackObjects bool
6060
Debug bool // Whether to emit debug information in the LLVM module.
61+
Nobounds bool // Whether to skip bounds checks
6162
PanicStrategy string
6263
}
6364

compiler/symbol.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,10 @@ func (c *compilerContext) parsePragmas(info *functionInfo, f *ssa.Function) {
438438
}
439439
}
440440
}
441+
442+
if c.Nobounds {
443+
info.nobounds = true
444+
}
441445
}
442446

443447
// Check whether this function can be used in //go:wasmimport or

main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,6 +1514,7 @@ func main() {
15141514
printCommands := flag.Bool("x", false, "Print commands")
15151515
parallelism := flag.Int("p", runtime.GOMAXPROCS(0), "the number of build jobs that can run in parallel")
15161516
nodebug := flag.Bool("no-debug", false, "strip debug information")
1517+
nobounds := flag.Bool("nobounds", false, "do not emit bounds checks")
15171518
ocdCommandsString := flag.String("ocd-commands", "", "OpenOCD commands, overriding target spec (can specify multiple separated by commas)")
15181519
ocdOutput := flag.Bool("ocd-output", false, "print OCD daemon output during debug")
15191520
port := flag.String("port", "", "flash port (can specify multiple candidates separated by commas)")
@@ -1625,6 +1626,7 @@ func main() {
16251626
SkipDWARF: *skipDwarf,
16261627
Semaphore: make(chan struct{}, *parallelism),
16271628
Debug: !*nodebug,
1629+
Nobounds: *nobounds,
16281630
PrintSizes: *printSize,
16291631
PrintStacks: *printStacks,
16301632
PrintAllocs: printAllocs,

0 commit comments

Comments
 (0)