{"id":19277543,"url":"https://github.com/enzymead/rustbook","last_synced_at":"2025-04-21T23:32:24.278Z","repository":{"id":213037362,"uuid":"732867122","full_name":"EnzymeAD/rustbook","owner":"EnzymeAD","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-18T04:28:37.000Z","size":1311,"stargazers_count":11,"open_issues_count":2,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-18T09:04:08.547Z","etag":null,"topics":["autodiff","rust"],"latest_commit_sha":null,"homepage":"https://enzyme.mit.edu/rust/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EnzymeAD.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-12-18T03:20:25.000Z","updated_at":"2025-04-18T04:28:31.000Z","dependencies_parsed_at":"2024-04-14T18:44:29.460Z","dependency_job_id":"36d68c21-029d-4c4e-8796-63e5827c869a","html_url":"https://github.com/EnzymeAD/rustbook","commit_stats":null,"previous_names":["enzymead/rustbook"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EnzymeAD%2Frustbook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EnzymeAD%2Frustbook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EnzymeAD%2Frustbook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EnzymeAD%2Frustbook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EnzymeAD","download_url":"https://codeload.github.com/EnzymeAD/rustbook/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250150945,"owners_count":21383254,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autodiff","rust"],"created_at":"2024-11-09T21:06:10.095Z","updated_at":"2025-04-21T23:32:23.983Z","avatar_url":"https://github.com/EnzymeAD.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Enzyme-Rust Book\n\nThis book is build using [mdBook](https://rust-lang.github.io/mdBook/index.html)\n\nIt requires a working rustup installation.\nInstall mdBook with\n\n```console\n$ cargo install mdbook\n```\n\nBuild and run this book afterwards locally with\n```console\n$ mdbook serve --open\n```\n\n## Running tests\n\nThis book contains many code fragments that are important to test.\n\n### Rust-Enzyme toolchain\nWe assume that you have a rustup toolchain called `enzyme`. This would have been created in your rust build directory by running something like:\n\n```console\n$ rustup toolchain link enzyme $(pwd)/build/host/stage1\n```\n\nThe above only needs to be run once. The `enzyme` toolchain will also need `rustdoc` support. Again, from the Rust build directory, you'll need to have run something like\n\n```console\n$ x build --stage 1 library tools/rustdoc\n```\n\nThis will need to be re-run each time you `git pull`.\n\n### Configuring an override\n\nIt's unlikely that you want `enzyme` as your default toolchain for all your rust activities. Instead, you probably use `cargo +enzyme build` when working with Rust-Enyzme. You can specify a [directory override](https://rust-lang.github.io/rustup/overrides.html#directory-overrides) by running the following (once) in the Enzyme-rustbook directory:\n\n```console\n$ rustup override set enzyme\n```\n\n### Testing with Cargo\n\nCode samples worth testing are being migrated to the `samples` crate. You can run all samples with a simple\n\n``` console\n$ cargo test\n```\n\nor, using [cargo-nextest](https://nexte.st/),\n\n``` console\n$ cargo nextest run\n```\n\n### Testing with mdBook (deprecated)\n\nFinally, you can run tests for all chapters using\n\n```console\n$ mdbook test\n```\n\nor a specific chapter using that chapter's name, such as\n\n```console\n$ mdbook test -c Usage\n```\n\nThis testing mode is being phased out as we move testable code into the `samples` crate. When using this mode, you will need the following workaround:\n\n#### mdBook and `lto=fat` (temporary workaround)\n\nRust's Enzyme support currently requires `lto=fat`, which is not part of the default profile for `rustdoc` (which is invoked by `mdbook test`). My temporary hack has been to patch `mdbook` by applying the following.\n\n``` diff\ndiff --git i/src/book/mod.rs w/src/book/mod.rs\nindex c0ab8a5..409482f 100644\n--- i/src/book/mod.rs\n+++ w/src/book/mod.rs\n@@ -319,7 +319,11 @@ impl MDBook {\n                 tmpf.write_all(ch.content.as_bytes())?;\n \n                 let mut cmd = Command::new(\"rustdoc\");\n-                cmd.arg(\u0026path).arg(\"--test\").args(\u0026library_args);\n+                cmd.arg(\u0026path)\n+                    .arg(\"--test\")\n+                    .args(\u0026library_args)\n+                    .arg(\"-C\")\n+                    .arg(\"lto=fat\");\n \n                 if let Some(edition) = self.config.rust.edition {\n                     match edition {\n```\n\nI'll find a better solution and make a pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenzymead%2Frustbook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fenzymead%2Frustbook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenzymead%2Frustbook/lists"}