From bd20ab29d175ab6a78f85e5abecd2fbada6fe83c Mon Sep 17 00:00:00 2001 From: Flier Lu Date: Tue, 9 Jan 2024 11:11:06 +0800 Subject: [PATCH 1/7] enable enc2 --- Cargo.toml | 9 ++++++++- build.rs | 11 +++++++++++ src/lib.rs | 4 ++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 68f09bc..fa97150 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,10 +11,17 @@ keywords = ["xed", "intel", "x86", "x86_64"] categories = ["encoding", "external-ffi-bindings", "hardware-support", "parsing", "no_std"] [badges] -appveyor = { repository = "rust-xed/xed-sys" } +appveyor = { repository = "rust-xed/xed-sys" } travis-ci = { repository = "rust-xed/xed-sys" } [features] +# Enable the enc2 module of XED. +# +# Note that this will somewhat dramatically slow down compilation of xed-sys. +# The enc2 module involves a large amount of generated code and the resulting +# bindgen definitions contain 40+MB of rust code. +enc2 = ["bindgen"] + # Generate bindings with bindgen at build-time instead of using the # pregenerated bindings. # diff --git a/build.rs b/build.rs index 3ad97a3..3f96a47 100644 --- a/build.rs +++ b/build.rs @@ -100,6 +100,10 @@ fn build_xed() { cmd.arg("--opt=0"); } + if cfg!(feature = "enc2") { + cmd.arg("--enc2"); + } + eprintln!("XED build command: {:?}", cmd); let status = cmd.status().expect("Failed to start xed build"); @@ -112,6 +116,13 @@ fn build_xed() { println!("cargo:rustc-link-search=native={}", lib_dir.display()); println!("cargo:rustc-link-lib=static=xed"); + + if cfg!(feature = "enc2") { + println!("cargo:rustc-link-lib=static=xed-enc2-m32-a32"); + println!("cargo:rustc-link-lib=static=xed-enc2-m64-a64"); + println!("cargo:rustc-link-lib=static=xed-chk-enc2-m32-a32"); + println!("cargo:rustc-link-lib=static=xed-chk-enc2-m64-a64"); + } } fn build_inline_shim() { diff --git a/src/lib.rs b/src/lib.rs index 9dc66c1..44a37e5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,6 +6,10 @@ //! //! # Features //! +//! - `enc2` - Enable the [fast XED encoder][1]. Note that enabling this feature +//! results in XED generating a rather large amount of code and the resulting +//! bindgen bindings are over 40MB in size. Expect 5+ minute compile times +//! when enabling this option. //! - `bindgen` - Don't use the bundled bindings files and instead regenerate //! rust bindings from scratch at compile time. You should never need to //! enable this manually but it will be enabled by other features. From 48733b53f49fcce249d144d4d23b3decb36ab1c0 Mon Sep 17 00:00:00 2001 From: Phantomical Date: Sat, 3 Feb 2024 00:09:49 -0800 Subject: [PATCH 2/7] Split enc2 into enc2-m32-a32 and enc2-m64-a64 features --- .github/workflows/build-and-test.yml | 3 +- Cargo.toml | 15 ++++++--- build.rs | 47 +++++++++++++++++++--------- src/lib.rs | 19 ++++++++--- xed.h | 5 ++- 5 files changed, 63 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index ee669d4..ea57e88 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -30,4 +30,5 @@ jobs: - uses: Swatinem/rust-cache@v2 - run: cargo test - - run: cargo test --all-features + - run: cargo test --features enc2-m32-a32 + - run: cargo test --features enc2-m64-a64 diff --git a/Cargo.toml b/Cargo.toml index fa97150..012c0f9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,10 +17,12 @@ travis-ci = { repository = "rust-xed/xed-sys" } [features] # Enable the enc2 module of XED. # -# Note that this will somewhat dramatically slow down compilation of xed-sys. -# The enc2 module involves a large amount of generated code and the resulting -# bindgen definitions contain 40+MB of rust code. -enc2 = ["bindgen"] +# Each feature enables a version of enc2 for a different module and operand +# size. Note that attempting to enable multiple enc2 feature variants is not +# supported and will result in a compile error (instead of the link error it +# would normally emit). +enc2-m32-a32 = ["bindgen", "_internal-enc2"] +enc2-m64-a64 = ["bindgen", "_internal-enc2"] # Generate bindings with bindgen at build-time instead of using the # pregenerated bindings. @@ -28,6 +30,11 @@ enc2 = ["bindgen"] # This will be slower but is required for certain feature combinations. bindgen = ["dep:bindgen"] +# Build xed with the enc2. +# +# This is an internal feature and you do not need to enable it manually. +_internal-enc2 = [] + [dependencies] [build-dependencies] diff --git a/build.rs b/build.rs index 3f96a47..5183de6 100644 --- a/build.rs +++ b/build.rs @@ -47,7 +47,7 @@ fn find_python() -> Command { panic!("Unable to find a working python installation. Tried `python3` and `python`."); } -fn build_xed() { +fn build_xed(_cc: &cc::Build) { println!("cargo:rerun-if-changed=xed/VERSION"); println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed-env=PROFILE"); @@ -82,7 +82,7 @@ fn build_xed() { .arg(&mfile_path) .arg("install") .arg(format!("--jobs={}", num_jobs)) - .arg("--silent") + // .arg("--silent") .arg("--static-stripped") .arg("--extra-ccflags=-fPIC") .arg("--no-werror") @@ -100,7 +100,7 @@ fn build_xed() { cmd.arg("--opt=0"); } - if cfg!(feature = "enc2") { + if cfg!(feature = "_internal-enc2") { cmd.arg("--enc2"); } @@ -117,25 +117,43 @@ fn build_xed() { println!("cargo:rustc-link-search=native={}", lib_dir.display()); println!("cargo:rustc-link-lib=static=xed"); - if cfg!(feature = "enc2") { - println!("cargo:rustc-link-lib=static=xed-enc2-m32-a32"); - println!("cargo:rustc-link-lib=static=xed-enc2-m64-a64"); - println!("cargo:rustc-link-lib=static=xed-chk-enc2-m32-a32"); - println!("cargo:rustc-link-lib=static=xed-chk-enc2-m64-a64"); + macro_rules! cfg_link_enc2 { + ($variant:literal) => { + if cfg!(feature = $variant) { + println!("cargo:rustc-link-lib=static=xed-{}", $variant); + println!("cargo:rustc-link-lib=static=xed-chk-{}", $variant); + } + }; } -} -fn build_inline_shim() { + cfg_link_enc2!("enc2-m32-a32"); + cfg_link_enc2!("enc2-m64-a64"); + + #[cfg(all(feature = "enc2-m32-a32", feature = "enc2-m64-a64"))] + compile_error!("Cannot enable both `enc2-m32-a32` and `enc2-m64-a64` features"); +} +fn build_inline_shim(mut cc: cc::Build) { let cwd = std::env::current_dir().unwrap(); let out_dir = PathBuf::from(env::var("OUT_DIR").expect("Failed to read OUT_DIR")); - let mut cc = cc::Build::new(); cc.include(out_dir.join("install/include")) .include(&cwd) // xed-static.c contains an instance of this. It's not an error and we // don't want to be modifying generated files so just silence the warning. .flag_if_supported("-Wno-duplicate-decl-specifier"); + macro_rules! cfg_define_enc2 { + ($variant:literal) => { + if cfg!(feature = $variant) { + let def = $variant.replace('-', "_").to_ascii_uppercase(); + cc.define(&format!("XED_SYS_{def}"), None); + } + }; + } + + cfg_define_enc2!("enc2-m32-a32"); + cfg_define_enc2!("enc2-m64-a64"); + if cfg!(feature = "bindgen") { cc.file(out_dir.join("xed-static.c")); } else { @@ -179,10 +197,9 @@ fn build_bindgen() { } fn main() { - build_xed(); - + let cc = cc::Build::new(); + build_xed(&cc); #[cfg(feature = "bindgen")] build_bindgen(); - - build_inline_shim(); + build_inline_shim(cc); } diff --git a/src/lib.rs b/src/lib.rs index 44a37e5..9534b29 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,15 +5,24 @@ //! Note that [`xed_tables_init()`][0] must be called before using the library. //! //! # Features -//! -//! - `enc2` - Enable the [fast XED encoder][1]. Note that enabling this feature -//! results in XED generating a rather large amount of code and the resulting -//! bindgen bindings are over 40MB in size. Expect 5+ minute compile times -//! when enabling this option. //! - `bindgen` - Don't use the bundled bindings files and instead regenerate //! rust bindings from scratch at compile time. You should never need to //! enable this manually but it will be enabled by other features. //! +//! ## `enc2` +//! XED has the option to enable its [`enc2`][1] encoder. This contains a +//! function to generate an x86 instruction for _every single instruction +//! variant_. As such, it is slow to compile and running bindgen on the +//! resulting headers generates a mountain (20+MB) of rust code. +//! +//! The generated static libraries also unfortunately have some duplicate +//! symbols so attempting to link both will result in linker errors. To make +//! the error less confusing this library will fail to compile if multiple +//! `enc2` features are enabled. +//! +//! - `enc2-m64-a64` - Enable enc2 for 64-bit mode with 64-bit addresses. +//! - `enc2-m32-a32` - Enable enc2 for 32-bit mode with 32-bit addresses. +//! //! [0]: crate::xed_tables_init //! [1]: https://github.com/intelxed/xed/wiki/The-fast-encoder---enc2 diff --git a/xed.h b/xed.h index 70fec29..b8e3a8a 100644 --- a/xed.h +++ b/xed.h @@ -7,9 +7,12 @@ #include "xed/xed-interface.h" #include "xed/xed-isa-set.h" -#ifdef XED_ENC2_ENCODER +#ifdef XED_SYS_ENC2_M32_A32 #include "xed/xed-enc2-m32-a32.h" #include "xed/xed-chk-enc2-m32-a32.h" +#endif + +#ifdef XED_SYS_ENC2_M64_A64 #include "xed/xed-enc2-m64-a64.h" #include "xed/xed-chk-enc2-m64-a64.h" #endif From 646ac21bd4cc81ed4b9d5e4d65a9ccb41ec90fb1 Mon Sep 17 00:00:00 2001 From: Phantomical Date: Sat, 3 Feb 2024 00:33:31 -0800 Subject: [PATCH 3/7] Add a `dylib` feature to allow linking xed dynamically When linking statically it is not possible to link both enc2 libraries. However, once they are compiled as dynamic libraries then linking both just works. --- .github/workflows/build-and-test.yml | 2 ++ Cargo.toml | 2 ++ build.rs | 36 +++++++++++++++++++++++----- src/lib.rs | 3 +++ 4 files changed, 37 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index ea57e88..852adc4 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -32,3 +32,5 @@ jobs: - run: cargo test - run: cargo test --features enc2-m32-a32 - run: cargo test --features enc2-m64-a64 + - run: cargo test --features dylib + - run: cargo test --all-features diff --git a/Cargo.toml b/Cargo.toml index 012c0f9..41bb03f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,8 @@ enc2-m64-a64 = ["bindgen", "_internal-enc2"] # This will be slower but is required for certain feature combinations. bindgen = ["dep:bindgen"] +dylib = [] + # Build xed with the enc2. # # This is an internal feature and you do not need to enable it manually. diff --git a/build.rs b/build.rs index 5183de6..5f98473 100644 --- a/build.rs +++ b/build.rs @@ -56,6 +56,10 @@ fn build_xed(_cc: &cc::Build) { let cwd = env::current_dir().expect("Failed to get CWD"); let target = env::var("TARGET").expect("Failed to read TARGET"); let profile = env::var("PROFILE").unwrap_or_else(|_| "debug".to_owned()); + let debug = match env::var("DEBUG") { + Ok(var) => var != "false", + _ => false, + }; let install_dir = out_dir.join("install"); let build_dir = out_dir.join("build"); @@ -82,8 +86,6 @@ fn build_xed(_cc: &cc::Build) { .arg(&mfile_path) .arg("install") .arg(format!("--jobs={}", num_jobs)) - // .arg("--silent") - .arg("--static-stripped") .arg("--extra-ccflags=-fPIC") .arg("--no-werror") .arg(format!( @@ -94,6 +96,16 @@ fn build_xed(_cc: &cc::Build) { )) .arg(format!("--install-dir={}", install_dir.display())); + if cfg!(feature = "dylib") { + cmd.arg("--shared"); + } else { + cmd.arg("--static-stripped"); + } + + if debug { + cmd.arg("--debug"); + } + if profile == "release" { cmd.arg("--opt=3"); } else { @@ -113,15 +125,19 @@ fn build_xed(_cc: &cc::Build) { } let lib_dir = install_dir.join("lib"); + let linkty = match cfg!(feature = "dylib") { + true => "dylib", + false => "static", + }; println!("cargo:rustc-link-search=native={}", lib_dir.display()); - println!("cargo:rustc-link-lib=static=xed"); + println!("cargo:rustc-link-lib={linkty}=xed"); macro_rules! cfg_link_enc2 { ($variant:literal) => { if cfg!(feature = $variant) { - println!("cargo:rustc-link-lib=static=xed-{}", $variant); - println!("cargo:rustc-link-lib=static=xed-chk-{}", $variant); + println!("cargo:rustc-link-lib={linkty}=xed-{}", $variant); + println!("cargo:rustc-link-lib={linkty}=xed-chk-{}", $variant); } }; } @@ -129,8 +145,12 @@ fn build_xed(_cc: &cc::Build) { cfg_link_enc2!("enc2-m32-a32"); cfg_link_enc2!("enc2-m64-a64"); + #[cfg(not(feature = "dylib"))] #[cfg(all(feature = "enc2-m32-a32", feature = "enc2-m64-a64"))] - compile_error!("Cannot enable both `enc2-m32-a32` and `enc2-m64-a64` features"); + compile_error!(concat!( + "Cannot enable both `enc2-m32-a32` and `enc2-m64-a64` features when linking statically.", + "You can avoid this by enabling the `dylib` feature to build these as dylibs." + )); } fn build_inline_shim(mut cc: cc::Build) { let cwd = std::env::current_dir().unwrap(); @@ -154,6 +174,10 @@ fn build_inline_shim(mut cc: cc::Build) { cfg_define_enc2!("enc2-m32-a32"); cfg_define_enc2!("enc2-m64-a64"); + if cfg!(feature = "dylib") { + cc.define("XED_DLL", None); + } + if cfg!(feature = "bindgen") { cc.file(out_dir.join("xed-static.c")); } else { diff --git a/src/lib.rs b/src/lib.rs index 9534b29..80d01a0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,6 +8,9 @@ //! - `bindgen` - Don't use the bundled bindings files and instead regenerate //! rust bindings from scratch at compile time. You should never need to //! enable this manually but it will be enabled by other features. +//! - `dylib` - Link XED (and `enc2` libraries if enabled) dynamically. This +//! allows you to work around the link errors that prevent you from linking +//! both enc2 libraries statically. //! //! ## `enc2` //! XED has the option to enable its [`enc2`][1] encoder. This contains a From 0b2b98d11d992a960d0408ee2ac7b5ba3416085c Mon Sep 17 00:00:00 2001 From: Phantomical Date: Sat, 3 Feb 2024 00:49:20 -0800 Subject: [PATCH 4/7] Don't cancel all CI runs after the first failure --- .github/workflows/build-and-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index e03f74f..aca23d0 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -15,6 +15,7 @@ jobs: runs-on: ${{ matrix.os }} continue-on-error: ${{ matrix.toolchain == 'nightly' }} strategy: + fail-fast: false matrix: toolchain: [stable, beta, nightly] os: From b5cfb28db4c869f05941c9490d1a92a3600fec51 Mon Sep 17 00:00:00 2001 From: Phantomical Date: Sat, 3 Feb 2024 01:01:15 -0800 Subject: [PATCH 5/7] Also add the bin dir to the search path on windows You need this in order for rustc to correctly set the path so that includes the xed DLLs. --- build.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/build.rs b/build.rs index 5f98473..269f00e 100644 --- a/build.rs +++ b/build.rs @@ -5,7 +5,7 @@ use std::{ str::FromStr, }; -use target_lexicon::Triple; +use target_lexicon::{OperatingSystem, Triple}; fn create_dir>(path: P) -> io::Result<()> { fs::create_dir(path).or_else(|e| match e.kind() { @@ -61,6 +61,8 @@ fn build_xed(_cc: &cc::Build) { _ => false, }; + let triple = Triple::from_str(&target).expect("TARGET was not a valid target triple"); + let install_dir = out_dir.join("install"); let build_dir = out_dir.join("build"); let mfile_path = cwd.join("xed/mfile.py"); @@ -88,12 +90,7 @@ fn build_xed(_cc: &cc::Build) { .arg(format!("--jobs={}", num_jobs)) .arg("--extra-ccflags=-fPIC") .arg("--no-werror") - .arg(format!( - "--host-cpu={}", - Triple::from_str(&target) - .expect("TARGET was not a valid target triple") - .architecture - )) + .arg(format!("--host-cpu={}", triple.architecture)) .arg(format!("--install-dir={}", install_dir.display())); if cfg!(feature = "dylib") { @@ -125,6 +122,7 @@ fn build_xed(_cc: &cc::Build) { } let lib_dir = install_dir.join("lib"); + let bin_dir = install_dir.join("bin"); let linkty = match cfg!(feature = "dylib") { true => "dylib", false => "static", @@ -133,6 +131,10 @@ fn build_xed(_cc: &cc::Build) { println!("cargo:rustc-link-search=native={}", lib_dir.display()); println!("cargo:rustc-link-lib={linkty}=xed"); + if triple.operating_system == OperatingSystem::Windows { + println!("cargo:rustc-link-search=native={}", bin_dir.display()); + } + macro_rules! cfg_link_enc2 { ($variant:literal) => { if cfg!(feature = $variant) { From 8504646cc30f6973c84380de8adb9295d3459d81 Mon Sep 17 00:00:00 2001 From: Phantomical Date: Sat, 3 Feb 2024 01:19:50 -0800 Subject: [PATCH 6/7] Disable the --all-features test for windows There is link issue when dylib and the enc2-chk libraries are linked that results in missing symbol warnings. This doesn't seem like something to fix in the current PR --- .github/workflows/build-and-test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index aca23d0..b29fa6d 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -34,4 +34,8 @@ jobs: - run: cargo test --features enc2-m32-a32 - run: cargo test --features enc2-m64-a64 - run: cargo test --features dylib + - run: cargo test --all-features + # Enabling enc2 features and dylib currently results in link errors + # on windows. + if: matrix.os != 'windows-latest' From 80a302a8ed5eac38db945ed95f9df6c00c92abb8 Mon Sep 17 00:00:00 2001 From: Phantomical Date: Sat, 3 Feb 2024 14:49:39 -0800 Subject: [PATCH 7/7] Split out the checked enc2 variants under a `enc2-chk` feature --- Cargo.toml | 3 +++ build.rs | 27 +++++++++++++++++++++++++-- src/lib.rs | 8 ++++++-- xed.h | 12 ++++++++---- 4 files changed, 42 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bfb9365..b5bc11d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,9 @@ rust-version = "1.64" enc2-m32-a32 = ["bindgen", "_internal-enc2"] enc2-m64-a64 = ["bindgen", "_internal-enc2"] +# Enable the checked variants for the enc2 module of XED. +enc2-chk = ["bindgen", "_internal-enc2"] + # Generate bindings with bindgen at build-time instead of using the # pregenerated bindings. # diff --git a/build.rs b/build.rs index 269f00e..52db1b4 100644 --- a/build.rs +++ b/build.rs @@ -139,7 +139,10 @@ fn build_xed(_cc: &cc::Build) { ($variant:literal) => { if cfg!(feature = $variant) { println!("cargo:rustc-link-lib={linkty}=xed-{}", $variant); - println!("cargo:rustc-link-lib={linkty}=xed-chk-{}", $variant); + + if cfg!(feature = "enc2-chk") { + println!("cargo:rustc-link-lib={linkty}=xed-chk-{}", $variant); + } } }; } @@ -176,6 +179,10 @@ fn build_inline_shim(mut cc: cc::Build) { cfg_define_enc2!("enc2-m32-a32"); cfg_define_enc2!("enc2-m64-a64"); + if cfg!(feature = "enc2-chk") { + cc.define("XED_SYS_ENC2_CHK", None); + } + if cfg!(feature = "dylib") { cc.define("XED_DLL", None); } @@ -195,7 +202,7 @@ fn build_bindgen() { let dot_rs = out_dir.join("xed.rs"); - let builder = bindgen::builder() + let mut builder = bindgen::builder() .clang_arg("-I") .clang_arg(out_dir.join("install/include").display().to_string()) .allowlist_type("xed3?_.*") @@ -209,6 +216,22 @@ fn build_bindgen() { .wrap_static_fns_path(out_dir.join("xed-static.c")) .wrap_static_fns_suffix("_xed_sys_inline"); + if cfg!(feater = "dylib") { + builder = builder.clang_arg("-DXED_DLL"); + } + + if cfg!(feature = "enc2-m32-a32") { + builder = builder.clang_arg("-DXED_SYS_ENC2_M32_A32"); + } + + if cfg!(feature = "enc2-m64-a64") { + builder = builder.clang_arg("-DXED_SYS_ENC2_M64_A64"); + } + + if cfg!(feature = "enc2-chk") { + builder = builder.clang_arg("-DXED_SYS_ENC2_CHK"); + } + let bindings = builder .header("xed.h") .generate() diff --git a/src/lib.rs b/src/lib.rs index 80d01a0..4058f71 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,11 +20,15 @@ //! //! The generated static libraries also unfortunately have some duplicate //! symbols so attempting to link both will result in linker errors. To make -//! the error less confusing this library will fail to compile if multiple -//! `enc2` features are enabled. +//! the error less confusing this library will fail to compile if both +//! `enc2-m64-a64` and `enc2-m32-a32` are enabled and the `dylib` feature is +//! not enabled. //! //! - `enc2-m64-a64` - Enable enc2 for 64-bit mode with 64-bit addresses. //! - `enc2-m32-a32` - Enable enc2 for 32-bit mode with 32-bit addresses. +//! - `enc2-chk` - Enable checked variants of the of the enc2 functions. Note +//! that this feature does nothing unless you have enabled one of the other +//! enc2 features. //! //! [0]: crate::xed_tables_init //! [1]: https://github.com/intelxed/xed/wiki/The-fast-encoder---enc2 diff --git a/xed.h b/xed.h index b8e3a8a..b536ae8 100644 --- a/xed.h +++ b/xed.h @@ -8,11 +8,15 @@ #include "xed/xed-isa-set.h" #ifdef XED_SYS_ENC2_M32_A32 -#include "xed/xed-enc2-m32-a32.h" -#include "xed/xed-chk-enc2-m32-a32.h" +# include "xed/xed-enc2-m32-a32.h" +# ifdef XED_SYS_ENC2_CHK +# include "xed/xed-chk-enc2-m32-a32.h" +# endif #endif #ifdef XED_SYS_ENC2_M64_A64 -#include "xed/xed-enc2-m64-a64.h" -#include "xed/xed-chk-enc2-m64-a64.h" +# include "xed/xed-enc2-m64-a64.h" +# ifdef XED_SYS_ENC2_CHK +# include "xed/xed-chk-enc2-m64-a64.h" +# endif #endif