Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixup versioning for simics APIs and add versioned tests #75

Merged
merged 17 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
config.mk
.package-list
.modcache
Dockerfile
.project-properties/
bin/
linux64/
win64/
packageinfo/
target/
documentation
simics
simics-eclipse
simics-gui
compiler.mk
# Ignore dockerfile so re-runs with dockerfile-only fixes don't rebuild
**/Dockerfile
**/target/
**/*.img
**/*.diff.craff
1 change: 0 additions & 1 deletion .github/builder/.dockerignore

This file was deleted.

28 changes: 13 additions & 15 deletions .github/builder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,15 @@ FROM fedora:20

ENV PATH="${PATH}:/root/.cargo/bin/"

RUN yum -y update && \
yum -y install \
coreutils \
gcc \
gcc-c++ \
make && \
yum clean all

COPY .github/builder/rsrc/rustup-init /install/rustup-init
COPY .github/builder/rsrc/make-4.4.1.tar.gz /install/make-4.4.1.tar.gz
COPY .github/builder/rsrc/cmake-3.28.0-rc5-linux-x86_64.tar.gz /install/cmake-3.28.0-rc5-linux-x86_64.tar.gz
COPY .github/builder/rsrc/llvm-5.0.2.src.tar.xz /install/llvm-5.0.2.src.tar.xz
COPY .github/builder/rsrc/lld-5.0.2.src.tar.xz /install/lld-5.0.2.src.tar.xz
COPY .github/builder/rsrc/cfe-5.0.2.src.tar.xz /install/cfe-5.0.2.src.tar.xz
COPY .github/builder/rsrc/patchelf-0.18.0-x86_64.tar.gz /install/patchelf-0.18.0-x86_64.tar.gz
COPY .github/builder/rsrc/llvm-5.0.2.src.tar.xz /install/llvm-5.0.2.src.tar.xz
COPY .github/builder/rsrc/rpms /install/rpms

RUN yum -y install /install/rpms/*.rpm && yum clean all

RUN chmod +x /install/rustup-init && \
/install/rustup-init -y --default-toolchain nightly && \
Expand All @@ -30,8 +25,10 @@ RUN chmod +x /install/rustup-init && \
popd && \
tar -C /usr/local/ --strip-components=1 -xf /install/cmake-3.28.0-rc5-linux-x86_64.tar.gz && \
mkdir -p /llvm/tools/clang && \
mkdir -p /llvm/tools/lld && \
tar -C /llvm --strip-components=1 -xf /install/llvm-5.0.2.src.tar.xz && \
tar -C /llvm/tools/clang --strip-components=1 -xf /install/cfe-5.0.2.src.tar.xz && \
tar -C /llvm/tools/lld --strip-components=1 -xf /install/lld-5.0.2.src.tar.xz && \
mkdir -p /llvm/build && \
pushd /llvm/build && \
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="MinSizeRel" -DLLVM_TARGETS_TO_BUILD="X86" .. && \
Expand All @@ -40,8 +37,7 @@ RUN chmod +x /install/rustup-init && \
make clean && \
rm -rf /llvm/build/ && \
popd && \
rm -rf /make /llvm && \
tar -C /usr/local/ --strip-components=1 -xf /install/patchelf-0.18.0-x86_64.tar.gz
rm -rf /make /llvm

WORKDIR /

Expand All @@ -56,9 +52,11 @@ WORKDIR /tsffs/
RUN mkdir -p /simics/ispm && \
tar -C /simics/ispm --strip-components=1 -xf .github/builder/rsrc/ispm.tar.gz && \
ispm settings install-dir /simics && \
ispm packages --install-bundle .github/builder/rsrc/simics.ispm --non-interactive --trust-insecure-packages && \
ls -lah /simics/ && \
ispm packages --install-bundle .github/builder/rsrc/simics.ispm --non-interactive --trust-insecure-packages

RUN RUSTFLAGS="-C linker=clang -C link-arg=-fuse-ld=$(which ld.lld)" && \
export RUSTFLAGS && \
cargo install --path simics-rs/cargo-simics-build && \
cargo simics-build --with-patchelf -r && \
cargo simics-build -r && \
mkdir -p /packages && \
cp target/release/*.ispm /packages
17 changes: 13 additions & 4 deletions .github/builder/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

# NOTE: Do not just copy-paste scripts/build.sh!

LLD_URL="https://releases.llvm.org/5.0.2/lld-5.0.2.src.tar.xz"
CFE_URL="https://releases.llvm.org/5.0.2/cfe-5.0.2.src.tar.xz"
LLVM_SRC_URL="https://releases.llvm.org/5.0.2/llvm-5.0.2.src.tar.xz"
MAKE_SRC_URL="https://ftp.gnu.org/gnu/make/make-4.4.1.tar.gz"
RUSTUP_INIT_URL="https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init"
CMAKE_URL="https://github.com/Kitware/CMake/releases/download/v3.28.0-rc5/cmake-3.28.0-rc5-linux-x86_64.tar.gz"
PATCHELF_URL="https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0-x86_64.tar.gz"
PUBLIC_SIMICS_PKGS_URL="https://registrationcenter-download.intel.com/akdlm/IRC_NAS/ead79ef5-28b5-48c7-8d1f-3cde7760798f/simics-6-packages-2024-05-linux64.ispm"
PUBLIC_SIMICS_ISPM_URL="https://registrationcenter-download.intel.com/akdlm/IRC_NAS/ead79ef5-28b5-48c7-8d1f-3cde7760798f/intel-simics-package-manager-1.8.3-linux64.tar.gz"
PUBLIC_SIMICS_PACKAGE_VERSION_1000="6.0.185"
Expand All @@ -31,6 +31,11 @@ if [ ! -f "${BUILDER_DIR}/rsrc/simics.ispm" ]; then
"${PUBLIC_SIMICS_PKGS_URL}"
fi

if [ ! -f "${BUILDER_DIR}/rsrc/lld-5.0.2.src.tar.xz" ]; then
curl --noproxy '*.intel.com' -L -o "${BUILDER_DIR}/rsrc/lld-5.0.2.src.tar.xz" \
"${LLD_URL}"
fi

if [ ! -f "${BUILDER_DIR}/rsrc/cfe-5.0.2.src.tar.xz" ]; then
curl --noproxy '*.intel.com' -L -o "${BUILDER_DIR}/rsrc/cfe-5.0.2.src.tar.xz" \
"${CFE_URL}"
Expand All @@ -57,9 +62,13 @@ if [ ! -f "${BUILDER_DIR}/rsrc/cmake-3.28.0-rc5-linux-x86_64.tar.gz" ]; then
"${CMAKE_URL}"
fi

if [ ! -f "${BUILDER_DIR}/rsrc/patchelf-0.18.0-x86_64.tar.gz" ]; then
curl --noproxy '*.intel.com' -L -o "${BUILDER_DIR}/rsrc/patchelf-0.18.0-x86_64.tar.gz" \
"${PATCHELF_URL}"
if [ ! -d "${BUILDER_DIR}/rsrc/rpms" ]; then
echo "RPM dependencies not found. Downloading..."
# NOTE: This may stop working at some point, as Fedora 20 is EOL. Therefore, we download the
# packages with the expectation that we will provide them separately if they are no longer
# available.
docker run -v "${BUILDER_DIR}/rsrc/rpms:/rpms" fedora:20 bash -c \
'yum -y update && yum install --downloadonly --downloaddir=/rpms coreutils gcc gcc-c++ make which && chmod -R 755 /rpms/'
fi

unset SIMICS_BASE
Expand Down
19 changes: 10 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ on:
env:
CARGO_TERM_COLOR: always
CFE_URL: "https://releases.llvm.org/5.0.2/cfe-5.0.2.src.tar.xz"
LLD_URL: "https://releases.llvm.org/5.0.2/lld-5.0.2.src.tar.xz"
LLVM_SRC_URL: "https://releases.llvm.org/5.0.2/llvm-5.0.2.src.tar.xz"
MAKE_SRC_URL: "https://ftp.gnu.org/gnu/make/make-4.4.1.tar.gz"
RUSTUP_INIT_URL: "https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init"
CMAKE_URL: "https://github.com/Kitware/CMake/releases/download/v3.28.0-rc5/cmake-3.28.0-rc5-linux-x86_64.tar.gz"
PATCHELF_URL: "https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0-x86_64.tar.gz"
PUBLIC_SIMICS_PKGS_URL_WINDOWS: "https://registrationcenter-download.intel.com/akdlm/IRC_NAS/ead79ef5-28b5-48c7-8d1f-3cde7760798f/simics-6-packages-2024-05-win64.ispm"
# NOTE: We use the old ISPM because there is something wrong with 1.8.3 with unattended installation
# PUBLIC_SIMICS_ISPM_URL_WINDOWS: "https://registrationcenter-download.intel.com/akdlm/IRC_NAS/881ee76a-c24d-41c0-af13-5d89b2a857ff/intel-simics-package-manager-1.7.5-win64.exe"
Expand All @@ -23,11 +23,11 @@ env:
PUBLIC_SIMICS_ISPM_URL: "https://registrationcenter-download.intel.com/akdlm/IRC_NAS/ead79ef5-28b5-48c7-8d1f-3cde7760798f/intel-simics-package-manager-1.8.3-linux64.tar.gz"
PUBLIC_SIMICS_PACKAGE_VERSION_1000: "6.0.185"
PUBLIC_SIMICS_ISPM_VERSION: "1.8.3"
BUILDER_LLD_VERSION: "5.0.2"
BUILDER_CFE_VERSION: "5.0.2"
BUILDER_LLVM_VERSION: "5.0.2"
BUILDER_MAKE_VERSION: "4.4.1"
BUILDER_CMAKE_VERSION: "3.28.0-rc5"
BUILDER_PATCHELF_VERSION: "0.18.0"
MINGW_URL: "https://github.com/brechtsanders/winlibs_mingw/releases/download/13.2.0-16.0.6-11.0.0-ucrt-r1/winlibs-x86_64-posix-seh-gcc-13.2.0-llvm-16.0.6-mingw-w64ucrt-11.0.0-r1.7z"
MINGW_VERSION: "13.2.0-16.0.6-11.0.0-ucrt-r1"

Expand All @@ -50,7 +50,7 @@ jobs:
id: cache-simics-packages
uses: actions/cache@v4
with:
path: ~/simics
path: "${HOME}/simics"
key: simics-linux-${{ env.PUBLIC_SIMICS_PACKAGE_VERSION_1000 }}-${{ env.PUBLIC_SIMICS_ISPM_VERSION }}

- name: Install SIMICS (External)
Expand Down Expand Up @@ -78,8 +78,7 @@ jobs:
run: |
mkdir bin && \
cp "${HOME}/simics/simics-${{ env.PUBLIC_SIMICS_PACKAGE_VERSION_1000 }}/linux64/bin/craff" bin/craff && \
cp "${HOME}/simics/simics-${{ env.PUBLIC_SIMICS_PACKAGE_VERSION_1000 }}/linux64/bin/craff-fs" bin/craff-fs && \
rm -rf "${HOME}/simics/"
cp "${HOME}/simics/simics-${{ env.PUBLIC_SIMICS_PACKAGE_VERSION_1000 }}/linux64/bin/craff-fs" bin/craff-fs

- name: Upload Test Artifacts
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -483,7 +482,7 @@ jobs:

- name: Test Project
run: |
SIMICS_TEST_CLEANUP_EACH=1 SIMICS_TEST_LOCAL_PACKAGES_ONLY=1 cargo test --no-fail-fast -r || ( echo "❗ Tests failed" && exit 1 )
SIMICS_TEST_CLEANUP_EACH=1 SIMICS_TEST_LOCAL_PACKAGES_ONLY=1 cargo test --no-fail-fast -r _latest || ( echo "❗ Tests failed" && exit 1 )
echo "✅ Tests passed"

- name: Build Docs
Expand Down Expand Up @@ -593,7 +592,7 @@ jobs:
uses: actions/cache@v4
with:
path: .github/builder/rsrc
key: "cache-builder-dependencies-${{ env.PUBLIC_SIMICS_ISPM_VERSION }}-${{ env.BUILDER_CFE_VERSION }}-${{ env.BUILDER_LLVM_VERSION }}-${{ env.BUILDER_MAKE_VERSION }}-${{ env.BUILDER_CMAKE_VERSION }}"
key: "cache-builder-dependencies-${{ env.PUBLIC_SIMICS_ISPM_VERSION }}-${{ env.BUILDER_LLD_VERSION }}-${{ env.BUILDER_CFE_VERSION }}-${{ env.BUILDER_LLVM_VERSION }}-${{ env.BUILDER_MAKE_VERSION }}-${{ env.BUILDER_CMAKE_VERSION }}"

- name: Download Builder Dependencies
if: ${{ steps.cache-builder-dependencies.outputs.cache-hit != 'true' }}
Expand All @@ -605,6 +604,8 @@ jobs:
"${{ env.PUBLIC_SIMICS_PKGS_URL }}"
curl -L -o .github/builder/rsrc/cfe-5.0.2.src.tar.xz \
"${{ env.CFE_URL }}"
curl -L -o .github/builder/rsrc/lld-5.0.2.src.tar.xz \
"${{ env.LLD_URL }}"
curl -L -o .github/builder/rsrc/llvm-5.0.2.src.tar.xz \
"${{ env.LLVM_SRC_URL }}"
curl -L -o .github/builder/rsrc/make-4.4.1.tar.gz \
Expand All @@ -614,8 +615,8 @@ jobs:
chmod +x .github/builder/rsrc/rustup-init
curl -L -o .github/builder/rsrc/cmake-3.28.0-rc5-linux-x86_64.tar.gz \
"${{ env.CMAKE_URL }}"
curl -L -o .github/builder/rsrc/patchelf-0.18.0-x86_64.tar.gz \
"${{ env.PATCHELF_URL}}"
docker run -v "$(pwd)/.github/builder/rsrc/rpms:/rpms" fedora:20 bash -c \
'yum -y update && yum install --downloadonly --downloaddir=/rpms coreutils gcc gcc-c++ make which && chmod -R 755 /rpms/'

- name: Build Distribution Package
run: |
Expand Down
26 changes: 22 additions & 4 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0


LLD_URL="https://releases.llvm.org/5.0.2/lld-5.0.2.src.tar.xz"
CFE_URL="https://releases.llvm.org/5.0.2/cfe-5.0.2.src.tar.xz"
LLVM_SRC_URL="https://releases.llvm.org/5.0.2/llvm-5.0.2.src.tar.xz"
MAKE_SRC_URL="https://ftp.gnu.org/gnu/make/make-4.4.1.tar.gz"
RUSTUP_INIT_URL="https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init"
CMAKE_URL="https://github.com/Kitware/CMake/releases/download/v3.28.0-rc5/cmake-3.28.0-rc5-linux-x86_64.tar.gz"
PATCHELF_URL="https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0-x86_64.tar.gz"
PUBLIC_SIMICS_PKGS_URL="https://registrationcenter-download.intel.com/akdlm/IRC_NAS/ead79ef5-28b5-48c7-8d1f-3cde7760798f/simics-6-packages-2024-05-linux64.ispm"
PUBLIC_SIMICS_ISPM_URL="https://registrationcenter-download.intel.com/akdlm/IRC_NAS/ead79ef5-28b5-48c7-8d1f-3cde7760798f/intel-simics-package-manager-1.8.3-linux64.tar.gz"
PUBLIC_SIMICS_PACKAGE_VERSION_1000="6.0.185"
Expand All @@ -22,44 +23,61 @@ CONTAINER_NAME="${IMAGE_NAME}-tmp-${CONTAINER_UID}"
mkdir -p "${BUILDER_DIR}/rsrc"

if [ ! -f "${BUILDER_DIR}/rsrc/ispm.tar.gz" ]; then
echo "ISPM not found. Downloading..."
curl --noproxy '*.intel.com' -L -o "${BUILDER_DIR}/rsrc/ispm.tar.gz" \
"${PUBLIC_SIMICS_ISPM_URL}"
fi

if [ ! -f "${BUILDER_DIR}/rsrc/simics.ispm" ]; then
echo "Simics not found. Downloading..."
curl --noproxy '*.intel.com' -L -o "${BUILDER_DIR}/rsrc/simics.ispm" \
"${PUBLIC_SIMICS_PKGS_URL}"
fi

if [ ! -f "${BUILDER_DIR}/rsrc/lld-5.0.2.src.tar.xz" ]; then
echo "LLD not found. Downloading..."
curl --noproxy '*.intel.com' -L -o "${BUILDER_DIR}/rsrc/lld-5.0.2.src.tar.xz" \
"${LLD_URL}"
fi

if [ ! -f "${BUILDER_DIR}/rsrc/cfe-5.0.2.src.tar.xz" ]; then
echo "CFE not found. Downloading..."
curl --noproxy '*.intel.com' -L -o "${BUILDER_DIR}/rsrc/cfe-5.0.2.src.tar.xz" \
"${CFE_URL}"
fi

if [ ! -f "${BUILDER_DIR}/rsrc/llvm-5.0.2.src.tar.xz" ]; then
echo "LLVM not found. Downloading..."
curl --noproxy '*.intel.com' -L -o "${BUILDER_DIR}/rsrc/llvm-5.0.2.src.tar.xz" \
"${LLVM_SRC_URL}"
fi

if [ ! -f "${BUILDER_DIR}/rsrc/make-4.4.1.tar.gz" ]; then
echo "Make not found. Downloading..."
curl --noproxy '*.intel.com' -L -o "${BUILDER_DIR}/rsrc/make-4.4.1.tar.gz" \
"${MAKE_SRC_URL}"
fi

if [ ! -f "${BUILDER_DIR}/rsrc/rustup-init" ]; then
echo "rustup not found. Downloading..."
curl --noproxy '*.intel.com' -L -o "${BUILDER_DIR}/rsrc/rustup-init" \
"${RUSTUP_INIT_URL}"
chmod +x "${BUILDER_DIR}/rsrc/rustup-init"
fi

if [ ! -f "${BUILDER_DIR}/rsrc/cmake-3.28.0-rc5-linux-x86_64.tar.gz" ]; then
echo "CMake not found. Downloading..."
curl --noproxy '*.intel.com' -L -o "${BUILDER_DIR}/rsrc/cmake-3.28.0-rc5-linux-x86_64.tar.gz" \
"${CMAKE_URL}"
fi

if [ ! -f "${BUILDER_DIR}/rsrc/patchelf-0.18.0-x86_64.tar.gz" ]; then
curl --noproxy '*.intel.com' -L -o "${BUILDER_DIR}/rsrc/patchelf-0.18.0-x86_64.tar.gz" \
"${PATCHELF_URL}"
if [ ! -d "${BUILDER_DIR}/rsrc/rpms" ]; then
echo "RPM dependencies not found. Downloading..."
# NOTE: This may stop working at some point, as Fedora 20 is EOL. Therefore, we download the
# packages with the expectation that we will provide them separately if they are no longer
# available.
docker run -v "${BUILDER_DIR}/rsrc/rpms:/rpms" fedora:20 bash -c \
'yum -y update && yum install --downloadonly --downloaddir=/rpms coreutils gcc gcc-c++ make which && chmod -R 755 /rpms/'
fi

unset SIMICS_BASE
Expand Down
48 changes: 1 addition & 47 deletions simics-rs/cargo-simics-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ pub enum SimicsBuildCmd {
args: Args,
#[clap(long)]
simics_base: Option<PathBuf>,
#[clap(long)]
with_patchelf: bool,
},
}

Expand All @@ -116,11 +114,7 @@ type Result<T> = std::result::Result<T, Error>;

impl App {
pub fn run(cmd: Cmd) -> Result<PathBuf> {
let SimicsBuildCmd::SimicsBuild {
args,
simics_base,
with_patchelf,
} = cmd.simics_build;
let SimicsBuildCmd::SimicsBuild { args, simics_base } = cmd.simics_build;

let subcommand = Subcommand::new(args)?;
let cargo = var("CARGO")?;
Expand Down Expand Up @@ -235,46 +229,6 @@ impl App {

signed.write(&signed_module_cdylib)?;

signed_module_cdylib = signed_module_cdylib.canonicalize()?;

if with_patchelf {
// We need to use patchelf to replace absolute paths to shared objects with
// just names
String::from_utf8(
Command::new("patchelf")
.arg("--print-needed")
.arg(&signed_module_cdylib)
.check()?
.stdout,
)?
.lines()
.filter(|l| l.starts_with('/'))
.try_for_each(|l| {
let path = PathBuf::from(l);
let file_name = path
.file_name()
.ok_or_else(|| Error::NoFilename {
path: PathBuf::from(l),
})?
.to_str()
.ok_or_else(|| Error::NoFilename {
path: PathBuf::from(l),
})?;
println!("Replacing needed library {} with {}", l, file_name);
Command::new("patchelf")
.arg("--remove-needed")
.arg(&l)
.arg(&signed_module_cdylib)
.check()?;
Command::new("patchelf")
.arg("--add-needed")
.arg(file_name)
.arg(&signed_module_cdylib)
.check()?;
Ok::<(), Error>(())
})?;
}

let target_profile_build_dir = subcommand.build_dir(subcommand.target()).join("build");

// Find interfaces
Expand Down
Loading