Skip to content

Commit

Permalink
Set supported versions to 15-18
Browse files Browse the repository at this point in the history
  • Loading branch information
stuxnot committed Nov 1, 2024
1 parent 31a0104 commit 2327bcf
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 19 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ This section provides instructions on how to get started with Nyxstone, covering

### Prerequisites

Before building Nyxstone, ensure clang and LLVM (version >= 15) are present on your system. Nyxstone looks for `llvm-config` in your system's `$PATH` or the specified environment variable `$NYXSTONE_LLVM_PREFIX/bin`.
Before building Nyxstone, ensure clang and LLVM are present on your system. Nyxstone supports LLVM major versions 15-18.
When building it looks for `llvm-config` in your system's `$PATH` or the specified environment variable `$NYXSTONE_LLVM_PREFIX/bin`.

Installation Options for LLVM versions 15-18:

Expand Down Expand Up @@ -176,7 +177,7 @@ $ ./nyxstone -p "0x1000" -l ".label=0x1238" "jmp .label"

### C++ Library

To use Nyxstone as a C++ library, your C++ code has to be linked against Nyxstone and LLVM 15.
To use Nyxstone as a C++ library, your C++ code has to be linked against Nyxstone and LLVM.

The following cmake example assumes Nyxstone in a subdirectory `nyxstone` in your project:

Expand Down
2 changes: 1 addition & 1 deletion bindings/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

## Installation

You need to have LLVM (with at least version 15) installed to build the nyxstone bindings. The `setup.py` searches for LLVM in the `PATH` or in the directory set in the environment variable `NYXSTONE_LLVM_PREFIX`. Specifically, it searches for the binary `$NYXSTONE_LLVM_PREFIX/bin/llvm-config` and uses it to set the required libraries and cpp flags.
You need to have LLVM (with major version in the range 15-18) installed to build the nyxstone bindings. The `setup.py` searches for LLVM in the `PATH` or in the directory set in the environment variable `NYXSTONE_LLVM_PREFIX`. Specifically, it searches for the binary `$NYXSTONE_LLVM_PREFIX/bin/llvm-config` and uses it to set the required libraries and cpp flags.

Running

Expand Down
4 changes: 2 additions & 2 deletions bindings/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ def __init__(self):

major_version = int(version.split(".")[0])

if major_version < 15:
if major_version < 15 or major_version > 18:
print(
f"LLVM Major version must be at least 15, found {major_version}! Set the environment variable ${LLVM_PREFIX_NAME} to tell nyxstone about the install location of LLVM."
f"LLVM Major version must be in the range 15-18, found {major_version}! Set the environment variable ${LLVM_PREFIX_NAME} to tell nyxstone about the install location of LLVM."
)
exit(1)

Expand Down
9 changes: 5 additions & 4 deletions bindings/rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ Official bindings for the Nyxstone assembler/disassembler engine.

## Building

The project can be build via `cargo build`, as long as LLVM (with at least version 15) is installed in the `$PATH` or the environment variable `$NYXSTONE_LLVM_PREFIX` points to the installation location of a LLVM library.
The project can be build via `cargo build`, as long as LLVM with a major version in the range 15-18 is installed in the `$PATH` or the environment variable `$NYXSTONE_LLVM_PREFIX` points to the installation location of a LLVM library.

LLVM might be linked against FFI, but not correctly report this fact via `llvm-config`. If your LLVM does link FFI and
Nyxstone fails to run, set the `NYXSTONE_LINK_FFI` environment variable to some value, which will ensure that Nyxstone
links `libffi`.
Nyxstone fails to run, set the `NYXSTONE_LINK_FFI` environment variable to `1`, which will ensure that Nyxstone
links against `libffi`.

## Installation

Expand All @@ -21,7 +21,8 @@ Add nyxstone as a dependency in your `Cargo.toml`:
nyxstone = "0.1"
```

Building nyxstone requires a C/C++ compiler to be installed on your system. Furthermore, Nyxstone requires LLVM 15 to be installed. Refer to the Building section for more information about setting the install location of LLVM.
Building nyxstone requires a C/C++ compiler to be installed on your system. Additionally, Nyxstone requires LLVM with
a major version in the range 15-18.

## Sample

Expand Down
26 changes: 16 additions & 10 deletions bindings/rust/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use anyhow::{anyhow, Context, Result};
use anyhow::{anyhow, ensure, Context, Result};
use std::env;
use std::ffi::OsStr;
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -131,9 +131,11 @@ fn search_llvm_config() -> Result<PathBuf> {

let version = version.parse::<u32>().context("Parsing LLVM version")?;

if version < 15 {
return Err(anyhow!("LLVM major version is {}, must be 18.", version));
}
ensure!(
(15..=18).contains(&version),
"LLVM major version is {}, must be 15-18.",
version
);

return Ok(llvm_config);
}
Expand Down Expand Up @@ -194,12 +196,16 @@ fn target_os_is(name: &str) -> bool {

/// Return an iterator over possible names for the llvm-config binary.
fn llvm_config_binary_names() -> impl Iterator<Item = String> {
let base_names = [
"llvm-config".into(),
format!("llvm-config-{}", 18),
format!("llvm-config{}", 18),
format!("llvm{}-config", 18),
];
let base_names = (15..=18)
.flat_map(|version| {
[
format!("llvm-config-{}", version),
format!("llvm-config{}", version),
format!("llvm{}-config", version),
]
})
.chain(["llvm-config".into()])
.collect::<Vec<_>>();

// On Windows, also search for llvm-config.exe
if target_os_is("windows") {
Expand Down

0 comments on commit 2327bcf

Please sign in to comment.