A place to put HARVEST code that has not yet been migrated into its own repository.
First, you will need to install libClang if you do not already have it. If you use ubuntu, this you can do this by runing:
apt-get install libclang-dev
If you have rustup installed, you can build the code by running:
cargo build --releaseIf you do not use rustup, you will need a sufficiently-new stable Rust compiler (see rust-toolchain.toml for a toolchain version that is known to work).
You will also need an LLM server. This can be local, or remote. A couple options are given below:
You can follow Ollama's download instructions, or download its Docker image.
Once you have it installed, you need to download a model. By default,
harvest_translate uses codellama:7b:
ollama pull codellama:7b # If installed in your system
docker container run ollama pull codellama:7b # If using DockerYou will need to have Ollama running to run harvest_translate.
First, you'll need to provision an OpenAI API key.
Then, you'll need to set up a custom Harvest config file:
[tools.raw_source_to_cargo_llm]
backend = "openai"
model = "gpt-4o"
api_key = "your_key_here" # Will be read from environment if empty
address = "" # Not needed for OpenAI
max_tokens = 16384You should place this config at the OS-dependent harvest config location, which you can find by running:
cargo run -- --print-config-pathSome of the examples below assume you have a local copy of the TRACTOR
Test-Corpus repository in export TEST_CORPUS_PATH=/path/to/test-corpus.
cargo run --bin=translate --release -- /path/to/c/code -o /path/to/outputcargo run --bin=translate --release -- $TEST_CORPUS_PATH/Public-Tests/B01_synthetic/001_helloworld/test_case/ -o example_output/cargo run --bin=benchmark --release -- /path/to/input/dir /path/to/output/dircargo run --bin=benchmark --release -- $TEST_CORPUS_PATH/Public-Tests/B01_synthetic example_output/Optional: add --filter= to keep only matching benchmarks (by directory name)
cargo run --bin=benchmark --release -- $TEST_CORPUS_PATH/Public-Tests/B01_synthetic example_output/ --filter=".*_lib$"cargo run --bin=benchmark --release -- $TEST_CORPUS_PATH/Public-Tests example_output/ --filter="^B01"Optional: add --exclude= to exclude matching benchmarks (by directory name) Note: --filter and --exclude are mutually exclusive
cargo run --bin=benchmark --release -- $TEST_CORPUS_PATH/Public-Tests/B01_synthetic example_output/ --exclude=".*_lib$"cargo run --bin=benchmark --release -- $TEST_CORPUS_PATH/Public-Tests example_output/ --exclude="^test_"
Print config file location:
cargo run --bin=translate -- --print-config-pathYou can find more information on configuration in [doc/Configuration.md].