1
0
mirror of https://github.com/exaloop/codon.git synced 2025-06-03 15:03:52 +08:00
codon/docs/intro/intro.md
A. R. Shajii d5ce1f8ff9
Update docs (#28)
* Update docs

* Update docs

* Update docs

* GitBook: [#4] Add hint

* Update primer

* Re-organize docs

* Fix table

* Fix link

* GitBook: [#5] No subject

* GitBook: [#6] No subject

* Cleanup and doc fix

* Add IR docs

* Add ir docs

* Fix spelling error

* More IR docs

* Update README.md

* Update README.md

* Fix warning

* Update intro

* Update README.md

* Update docs

* Fix table

* Don't build docs

* Update docs

* Add Jupyter docs

* FIx snippet

* Update README.md

* Fix images

* Fix code block

* Update docs, update cmake

* Break up tutorial

* Update pipeline.svg

* Update docs for new version

* Add differences with Python docs
2022-07-26 16:08:42 -04:00

1.1 KiB

Using codon

The codon program can directly run Codon source in JIT mode:

codon run myprogram.codon

The default compilation and run mode is debug (-debug). Compile and run with optimizations with the -release option:

codon run -release myprogram.codon

codon can also build executables:

# generate 'myprogram' executable
codon build -exe myprogram.codon

# generate 'foo' executable
codon build -o foo myprogram.codon

codon can produce object files:

# generate 'myprogram.o' object file
codon build -obj myprogram.codon

# generate 'foo.o' object file
codon build -o foo.o myprogram.codon

codon can produce LLVM IR:

# generate 'myprogram.ll' object file
codon build -llvm myprogram.codon

# generate 'foo.ll' object file
codon build -o foo.ll myprogram.codon

Compile-time definitions

codon allows for compile-time definitions via the -D flag. For example, in the following code:

print(Int[BIT_WIDTH]())

BIT_WIDTH can be specified on the command line as such: codon run -DBIT_WIDTH=10 myprogram.codon.