mirror of
https://github.com/exaloop/codon.git
synced 2025-06-03 15:03:52 +08:00
* 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
57 lines
1.1 KiB
Markdown
57 lines
1.1 KiB
Markdown
# Using `codon`
|
|
|
|
The `codon` program can directly `run` Codon source in JIT mode:
|
|
|
|
```bash
|
|
codon run myprogram.codon
|
|
```
|
|
|
|
The default compilation and run mode is _debug_ (`-debug`).
|
|
Compile and run with optimizations with the `-release` option:
|
|
|
|
```bash
|
|
codon run -release myprogram.codon
|
|
```
|
|
|
|
`codon` can also `build` executables:
|
|
|
|
```bash
|
|
# generate 'myprogram' executable
|
|
codon build -exe myprogram.codon
|
|
|
|
# generate 'foo' executable
|
|
codon build -o foo myprogram.codon
|
|
```
|
|
|
|
`codon` can produce object files:
|
|
|
|
```bash
|
|
# 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:
|
|
|
|
```bash
|
|
# 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:
|
|
|
|
```python
|
|
print(Int[BIT_WIDTH]())
|
|
```
|
|
|
|
`BIT_WIDTH` can be specified on the command line as such:
|
|
`codon run -DBIT_WIDTH=10 myprogram.codon`.
|