Skip to content

About

No description, website, or topics provided.

Resources

Code of conduct

Security policy

Stars

6 stars

Watchers

13 watching

Forks

Latest commit

 

History

70 Commits

Folders and files

Repository files navigation

Firtool Resolver and LLVM Firtool Native

Firtool Resolver is a Scala library and command-line application for resolving and downloading LLVM Firtool. It downloads binaries directly from CIRCT's GitHub releases and verifies their SHA-256 checksums.

LLVM Firtool Native (org.chipsalliance:llvm-firtool) and FNDDS are legacy distribution mechanisms. The last version published to Maven Central is 1.162.0; existing artifacts and classpath overrides continue to work.

Using Firtool Resolver

import firtoolresolver.Resolve

Resolve(projectName = "chisel", defaultVersion = "1.163.0") match {
  case Right(binary) => println(binary.path)
  case Left(error) => sys.error(error)
}

The project name determines the names of the configuration settings. It must start with an ASCII letter and contain only ASCII letters, digits, and underscores. Use Resolve("chisel", "1.163.0", verbose = true) for debug logging or Resolve(logger, "chisel", "1.163.0") for a custom logger. The deprecated overloads without a project name behave as if you passed "chisel".

The command-line interface is firtool-resolver [--project <name>] [-v] <version>. The project defaults to chisel. For example:

cs launch --scala 2.13 org.chipsalliance::firtool-resolver:2.2.0 \
  --main firtoolresolver.Main -- -v 1.163.0

Resolution order

  1. Run firtool from the configured executable directory, if set. An invalid path or a binary that cannot run is an unrecoverable error.
  2. Choose the effective version: use the configured version override or the caller's default version. An explicit override skips the classpath lookup and warns if llvm-firtool is also on the classpath.
  3. If no explicit version is set, honor llvm-firtool on the classpath. This legacy mechanism logs a deprecation message at info level.
  4. Reuse the cached binary at <cache>/<effective-version>/bin/firtool.
  5. Download the effective version from GitHub, verify its checksum, and atomically install just the executable in the cache. Downloads are locked per version across processes.

Configuration

Settings are read from <project>.firtool.* system properties and <PROJECT>_FIRTOOL_* environment variables, where the project name is lowercased for system properties and uppercased for environment variables. For project chisel, the keys are:

Setting System property Environment variable Default
Executable directory chisel.firtool.path CHISEL_FIRTOOL_PATH Unset
Version override chisel.firtool.version CHISEL_FIRTOOL_VERSION Caller's default version
Release base URL / mirror chisel.firtool.url CHISEL_FIRTOOL_URL https://github.com/llvm/circt/releases/download
Cache directory chisel.firtool.cache CHISEL_FIRTOOL_CACHE OS-specific firtool cache directory

Properties take precedence over the corresponding environment variables.

Direct downloads require access to github.com and release-assets.githubusercontent.com. Standard JVM proxy properties (https.proxyHost, https.proxyPort, and the corresponding HTTP properties for HTTP mirrors) are honored.

To use an internal web server (HTTP or HTTPS), an Artifactory generic remote, or a local file: mirror, set the release base URL. The mirror must provide both the archive and its .sha256 file at:

<base>/firtool-<version>/firrtl-bin-<platform>.<ext>
<base>/firtool-<version>/firrtl-bin-<platform>.<ext>.sha256
Resolver platform Release asset
linux-x64 firrtl-bin-linux-x64.tar.gz
macos-x64 firrtl-bin-macos-x64.tar.gz
macos-aarch64 firrtl-bin-macos-arm64.tar.gz
windows-x64 firrtl-bin-windows-x64.zip

GitHub fetching supports versions starting at 1.45.0. Native macOS arm64 assets start at 1.144.0; earlier versions fall back to macOS x64 through Rosetta. For versions older than 1.45.0, provide a local binary or a legacy jar on the classpath.

Development and release

Run ./mill -i 'firtool-resolver[_].test' for the tests on both Scala versions, or ./mill -i 'firtool-resolver[2.13].test' for just Scala 2.13.

The tests are MUnit tests that run the resolver in real JVMs against local fixtures (a fake release mirror, classpath resources, and local HTTP servers), once from the unshaded classes and once from the shaded jar as published. They also check the contents of the published jar.

LiveTests downloads and runs a real firtool release from GitHub. It needs network access, is tagged live, and runs by default. Use MUnit's tag filters to select which tests to run:

# Hermetic tests only
./mill -i 'firtool-resolver[2.13].test' --exclude-tags=live

# Live tests only
./mill -i 'firtool-resolver[2.13].test' --include-tags=live

Firtool Native Dependency Distribution Specification (FNDDS) (legacy)

This specification follows Semantic Versioning 2.0.0.

Specification version: 1.0.0

  1. Platforms are defined to be a tuple of a operating system and an architecture written as <os>-<arch> which can also be written as <platform>.
  2. The defined operating systems are linux, windows, and macos.
  3. The defined architectures are x64 and aarch64.
  4. A Project SHALL have a groupId, artifactId, and version.
  5. A Project MAY support any number of Platforms.
  6. Artifacts SHALL be published as a Maven Artifact
    1. The Maven Artifact groupId SHALL be the same as the project groupId.
    2. The Maven Artifact artifactId SHALL be the project artifactId.
    3. The Maven Artifact version SHALL be the project version and MAY include a suffix starting with -.
    4. The Maven Artifact MAY include additional jars distinguished by classifiers corresponding to supported Platforms.
  7. The Maven Artifact SHALL contain a baseDirectory defined to be <groupId>/<artifactId>.
  8. The Maven Artifact SHALL contain one or more artifactDirectories defined to be <baseDirectory>/<platform> (for each supported Platform).
  9. The baseDirectory SHALL contain a file called FNDDS.version containing only the version of this specification adhered to by the artifact, encoded using UTF-8.
  10. The baseDirectory SHALL contain a file called project.version containing only the version of the artifact, encoded using UTF-8.
  11. Maven Artifacts published for various Platforms for a single Artifact must conform to the same FNDDS.version and project.version.
  12. The artifactDirectory for each supported Platform MAY contain any other project-specific files including executables compiled for the specific <platform>.

Revision History

1.0.0

Initial Version

Commentary on the specification

The purpose of this specification is to enable distributing native executables (especially Firtool) as standard Maven artifacts. It is indended to help bridge the gap between the cross-platform flexibility of JVM applications with the platform-specific requirements of native executables. As such, it is important that executables for different platforms can co-exist on the same Java classpath so that JVM applications may be distributed with a multitude of native libraries so they can appear to be platform-agnostic despite the native dependency. It may seem strange that the FNDDS.version file exists in the baseDirectory such that it will be clobbered by related artifacts for different architectures. This design decision is a compromise--it is expected that the Platform specification will evolve to support more platforms while all Maven Artifacts for a specific Artifact must have the same FNDDS.version.

About

No description, website, or topics provided.

Resources

Code of conduct

Security policy

Stars

6 stars

Watchers

13 watching

Forks

Releases

Packages

Used by

Contributors

Languages