go-compiler | a simple compiler in go | Parser library
kandi X-RAY | go-compiler Summary
kandi X-RAY | go-compiler Summary
a simple compiler in go
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- generates the AST of a node
- checker evaluates an AST node
- evalFunctionCall evaluates a function call
- evalInfixExpression evaluates InfixExpression
- genFunctionCall generates code for a function call .
- NewFunctionStatement creates a function statement .
- Compile compiles the code .
- evalFunctionStatement evaluates a function statement
- NewInfixExpression creates an InfixExpression .
- AppendFormalArgs appends args to a list of FormalArgs .
go-compiler Key Features
go-compiler Examples and Code Snippets
Community Discussions
Trending Discussions on go-compiler
QUESTION
How does one uses environment variables to optimize a go binary?
For instance, with C and GCC, you would set CFLAGS="-O2 -march=znv1
to build with tier 2 optimizations, with specific optimizations for the Zen microarchitecture.
I couldn't find an equivalent environment variable in Golang's documentation.
Go does provide a way to disable them all, but not to specify which one to use in case you are using gccgo as the compiler back-end. It is thus very different from other questions asked about optimizations flags for Go in general (Passing an optimization flag to a Go compiler? for instance)
...ANSWER
Answered 2020-Oct-14 at 14:46After searching for a very long while, I found the information I needed.
First of all, as Adrian mentionned, the standard gc compiler (which is usually the most up-to-date regarding the Go spec), does not support optimization flags (except for disabling them completely using -N -l
as mentionned here.
However, if you use GCCGO, there is an environment variable you can use, which is GOGCCFLAGS
.
Using go env
on my system with gcc-go installed, I saw that its default value was -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build920233973=/tmp/go-build -gno-record-gcc-switches -funwind-tables
.
One can thus override this environment variable and pass other optimizations, like those described in GCCGO's documentation.
Standard gcc options seems to work, like -march=native
for instance, which is exactly what I was searching for.
Edit: after more testing, it seems that Go often ignores this environment variable, so you have to add -gccgoflags="${GOGCCFLAGS}"
.
QUESTION
I am testing code-generation functionality and deliberately creating very large .go source files.
However I see errors with go compiler at line 1048575
(which is 0xFFFFF
) such as:
ANSWER
Answered 2020-Jan-28 at 14:54Is this a known limitation ?
No.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install go-compiler
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page