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

Package request: Gem5 #348629

Open
Arya-Elfren opened this issue Oct 14, 2024 · 2 comments · May be fixed by #375739
Open

Package request: Gem5 #348629

Arya-Elfren opened this issue Oct 14, 2024 · 2 comments · May be fixed by #375739
Labels
0.kind: packaging request Request for a new package to be added

Comments

@Arya-Elfren
Copy link

Needs SCons (#348628)

Project description

The gem5 simulator is a modular platform for computer-system architecture research, encompassing system-level architecture as well as processor microarchitecture. gem5 is a community led project with an open governance model.

Metadata


Add a 👍 reaction to issues you find important.

@Arya-Elfren Arya-Elfren added the 0.kind: packaging request Request for a new package to be added label Oct 14, 2024
@mtoohey31
Copy link
Member

So I have a draft of this. I'm not 100% sure if I've split things up right/included everything someone might want to expose as a package though. The current layout is one main gem5 package that just contains a binary:

{ boost
, capstone
, fetchFromGitHub
, gperftools
, hdf5-cpp
, isa ? "X86"
, lib
, libpng
, m4
, protobuf_21
, python3
, scons
, stdenv
, variant ? "opt"
, zlib
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "gem5-${isa}-${variant}";
  version = "24.1.0.1";

  src = fetchFromGitHub {
    owner = "gem5";
    repo = "gem5";
    tag = "v${finalAttrs.version}";
    hash = "sha256-Q7+LuCGUINvsuF7GyiEC7/veADTVi1FpkUXajl2TDkA=";
  };

  patches = [ ./include-algorithm.patch ];

  nativeBuildInputs = [ m4 python3 scons ];

  buildInputs = [
    boost
    capstone
    gperftools # provides tcmalloc
    hdf5-cpp
    libpng
    protobuf_21
    zlib
  ];

  buildFlags = [ "build/${isa}/gem5.${variant}" ];

  enableParallelBuilding = true;

  preBuild = ''
    patchShebangs .
  '';

  installPhase = ''
    runHook preInstall

    mkdir -p $out/bin
    cp build/${isa}/gem5.${variant} $out/bin/
    cp -r include $out/include

    runHook postInstall
  '';

  meta = {
    description =
      "A modular platform for computer-system architecture research";
    homepage = "https://www.gem5.org/";
    license = lib.licenses.bsd3;
    platforms = lib.platforms.linux;
    mainProgram = "gem5";
  };
})

And then a separate python package for m5:

{ buildPythonPackage, gem5, lib, python3 }:
buildPythonPackage {
  pname = "m5";
  inherit (gem5) version src;
  format = "other";
  installPhase = ''
    mkdir -p $out/${python3.sitePackages}
    cp -r src/python/m5 $out/${python3.sitePackages}/m5
  '';
  postInstall = ''
    export PYTHONPATH=$out/${python3.sitePackages}:$PYTHONPATH
  '';
}

Does this seem right or is there anything I might've missed/another way to structure things? Maybe M5ops should also be supported... should that be a separate package then? It seems like it's built completely independently of the main gem5 binary, right?

@mtoohey31
Copy link
Member

mtoohey31 commented Jan 21, 2025

Here's M5ops:

{ fetchFromGitHub
, glibc
, isa ? "x86"
, lib
, pkg-config
, scons
, stdenv
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "m5-${isa}";
  version = "24.1.0.1";

  src = fetchFromGitHub {
    owner = "gem5";
    repo = "gem5";
    tag = "v${finalAttrs.version}";
    hash = "sha256-Q7+LuCGUINvsuF7GyiEC7/veADTVi1FpkUXajl2TDkA=";
  };

  nativeBuildInputs = [ pkg-config scons ];

  buildInputs = [ glibc.static ];

  sourceRoot = "source/util/m5";

  buildFlags = [ "build/${isa}/out/m5" ];

  enableParallelBuilding = true;

  postPatch = ''
    substituteInPlace SConstruct \
      --replace-fail "Environment()" "Environment(ENV=os.environ)"
  '';

  installPhase = ''
    runHook preInstall

    mkdir -p $out/lib
    cp build/${isa}/out/libm5.a $out/lib/

    runHook postInstall
  '';

  meta = {
    homepage = "https://www.gem5.org/";
    license = lib.licenses.bsd3;
    platforms = lib.platforms.linux;
  };
})

I'll try to clean everything up and put it into a pull request sometime soon.

@mtoohey31 mtoohey31 linked a pull request Jan 22, 2025 that will close this issue
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: packaging request Request for a new package to be added
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants