añade simple-scalar
This commit is contained in:
parent
de11780539
commit
e21cfa7a46
|
@ -1,5 +1,4 @@
|
||||||
pkgs:
|
pkgs:
|
||||||
{
|
{
|
||||||
#andesight = pkgs.callPackage ./andesight {};
|
simplescalar = pkgs.callPackage ./simple-scalar {};
|
||||||
#netextender = pkgs.callPackage ./netextender {};
|
|
||||||
}
|
}
|
||||||
|
|
25
pkgs/simple-scalar/0001-fix-case-of-YY_CURRENT_BUFFER.patch
Normal file
25
pkgs/simple-scalar/0001-fix-case-of-YY_CURRENT_BUFFER.patch
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
From 33f6fb023c09464467eea4538f18e2a131acee3a Mon Sep 17 00:00:00 2001
|
||||||
|
From: Alejandro Soto <alejandro@34project.org>
|
||||||
|
Date: Wed, 26 Apr 2023 13:37:32 -0600
|
||||||
|
Subject: [PATCH] fix case of YY_CURRENT_BUFFER
|
||||||
|
|
||||||
|
---
|
||||||
|
ld/ldlex.l | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/simpleutils-990811/ld/ldlex.l b/simpleutils-990811/ld/ldlex.l
|
||||||
|
index 2eef80f..561b8af 100644
|
||||||
|
--- a/simpleutils-990811/ld/ldlex.l
|
||||||
|
+++ b/simpleutils-990811/ld/ldlex.l
|
||||||
|
@@ -585,7 +585,7 @@ yy_input (buf, result, max_size)
|
||||||
|
int max_size;
|
||||||
|
{
|
||||||
|
*result = 0;
|
||||||
|
- if (yy_current_buffer->yy_input_file)
|
||||||
|
+ if (YY_CURRENT_BUFFER->yy_input_file)
|
||||||
|
{
|
||||||
|
if (yyin)
|
||||||
|
{
|
||||||
|
--
|
||||||
|
2.38.4
|
||||||
|
|
24
pkgs/simple-scalar/0002-define-sys_nerr.patch
Normal file
24
pkgs/simple-scalar/0002-define-sys_nerr.patch
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
From 442edcc1d281a62a0092bcde19038ba3c976e499 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Alejandro Soto <alejandro@34project.org>
|
||||||
|
Date: Wed, 26 Apr 2023 13:35:21 -0600
|
||||||
|
Subject: [PATCH 1/3] define sys_nerr
|
||||||
|
|
||||||
|
---
|
||||||
|
gcc.c | 1 +
|
||||||
|
1 file changed, 1 insertion(+)
|
||||||
|
|
||||||
|
diff --git a/gcc-2.7.2.3/gcc.c b/gcc-2.7.2.3/gcc.c
|
||||||
|
index fe7de5b..1ac933f 100644
|
||||||
|
--- a/gcc-2.7.2.3/gcc.c
|
||||||
|
+++ b/gcc-2.7.2.3/gcc.c
|
||||||
|
@@ -176,6 +176,7 @@ extern int errno;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern int sys_nerr;
|
||||||
|
+int __attribute__((weak)) sys_nerr = 0;
|
||||||
|
#ifndef HAVE_STRERROR
|
||||||
|
#if defined(bsd4_4)
|
||||||
|
extern const char *const sys_errlist[];
|
||||||
|
--
|
||||||
|
2.38.4
|
||||||
|
|
25
pkgs/simple-scalar/0003-fix-obstack.h-post-increment.patch
Normal file
25
pkgs/simple-scalar/0003-fix-obstack.h-post-increment.patch
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
From b074acb822459a42d2507ad5729e9e60bb1de572 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Alejandro Soto <alejandro@34project.org>
|
||||||
|
Date: Wed, 26 Apr 2023 13:35:42 -0600
|
||||||
|
Subject: [PATCH 2/3] fix obstack.h post-increment
|
||||||
|
|
||||||
|
---
|
||||||
|
obstack.h | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/gcc-2.7.2.3/obstack.h b/gcc-2.7.2.3/obstack.h
|
||||||
|
index 28bcd44..3a517b5 100644
|
||||||
|
--- a/gcc-2.7.2.3/obstack.h
|
||||||
|
+++ b/gcc-2.7.2.3/obstack.h
|
||||||
|
@@ -338,7 +338,7 @@ __extension__ \
|
||||||
|
if (__o->next_free + sizeof (void *) > __o->chunk_limit) \
|
||||||
|
_obstack_newchunk (__o, sizeof (void *)); \
|
||||||
|
if (!__o->alloc_failed) \
|
||||||
|
- *((void **)__o->next_free)++ = ((void *)datum); \
|
||||||
|
+ *((void **)__o->next_free++) = ((void *)datum); \
|
||||||
|
(void) 0; })
|
||||||
|
|
||||||
|
#define obstack_int_grow(OBSTACK,datum) \
|
||||||
|
--
|
||||||
|
2.38.4
|
||||||
|
|
25
pkgs/simple-scalar/0004-stdarg.h-instead-of-varargs.h.patch
Normal file
25
pkgs/simple-scalar/0004-stdarg.h-instead-of-varargs.h.patch
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
From 12c34c7ff8e4e00ba54bd0b90f2ca6905109cb5d Mon Sep 17 00:00:00 2001
|
||||||
|
From: Alejandro Soto <alejandro@34project.org>
|
||||||
|
Date: Wed, 26 Apr 2023 13:35:57 -0600
|
||||||
|
Subject: [PATCH 3/3] stdarg.h instead of varargs.h
|
||||||
|
|
||||||
|
---
|
||||||
|
protoize.c | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/gcc-2.7.2.3/protoize.c b/gcc-2.7.2.3/protoize.c
|
||||||
|
index 9728bf2..fb82ef0 100644
|
||||||
|
--- a/gcc-2.7.2.3/protoize.c
|
||||||
|
+++ b/gcc-2.7.2.3/protoize.c
|
||||||
|
@@ -57,7 +57,7 @@ Boston, MA 02111-1307, USA. */
|
||||||
|
#define _POSIX_SOURCE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
-#include <varargs.h>
|
||||||
|
+#include <stdarg.h>
|
||||||
|
/* On some systems stdio.h includes stdarg.h;
|
||||||
|
we must bring in varargs.h first. */
|
||||||
|
#include <stdio.h>
|
||||||
|
--
|
||||||
|
2.38.4
|
||||||
|
|
118
pkgs/simple-scalar/default.nix
Normal file
118
pkgs/simple-scalar/default.nix
Normal file
|
@ -0,0 +1,118 @@
|
||||||
|
# https://www.cse.iitd.ac.in/~cs5070217/csl718/assignment1/ss_install_instructions.html
|
||||||
|
{ bison, fetchurl, flex, multiStdenv, stdenv_32bit, strace }:
|
||||||
|
let
|
||||||
|
host = "i686-pc-linux";
|
||||||
|
target = "sslittle-na-sstrix";
|
||||||
|
|
||||||
|
gcc-version = "2.7.2.3";
|
||||||
|
makeflags = "LANGUAGES=c CC=\"$CC -m32 $CFLAGS\" prefix=$out";
|
||||||
|
in
|
||||||
|
multiStdenv.mkDerivation {
|
||||||
|
pname = "SimpleScalar";
|
||||||
|
version = "1998-08-11"; # !!!
|
||||||
|
|
||||||
|
nativeBuildInputs = [ flex bison ];
|
||||||
|
|
||||||
|
sourceRoot = ".";
|
||||||
|
|
||||||
|
srcs = [
|
||||||
|
(fetchTarball {
|
||||||
|
name = "simplesim-3.0";
|
||||||
|
|
||||||
|
url = "https://www.cse.iitd.ac.in/~cs5070217/csl718/simplesim-3v0d.tgz";
|
||||||
|
sha256 = "sha256:022rlniimzl30c1874765hl001dxc716vfwm40ij256h1qk2dwgw";
|
||||||
|
})
|
||||||
|
|
||||||
|
(fetchTarball {
|
||||||
|
name = "simpleutils-990811";
|
||||||
|
|
||||||
|
url = "https://www.cse.iitd.ac.in/~cs5070217/csl718/simpleutils-990811.tar.gz";
|
||||||
|
sha256 = "sha256:0w952z382s7ghrxwrad7fd058b1kj5ad1abh8idxwwk47va72cdf";
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
|
# El código es muy viejo y Nix usa opciones muy estrictas por defecto
|
||||||
|
CFLAGS = "-O3 -Wno-error=format-security";
|
||||||
|
|
||||||
|
# Algunas tarballs vienen sin directorio de primer nivel y además requieren arreglos
|
||||||
|
postUnpack =
|
||||||
|
let
|
||||||
|
simpletools = fetchurl {
|
||||||
|
url = "https://www.cse.iitd.ac.in/~cs5070217/csl718/simpletools-2v0.tgz";
|
||||||
|
sha256 = "sha256-FTDTqyQWZCnuNPmTcu3Hcjgp4pHNoUcC0GOGhSJV9Iw=";
|
||||||
|
};
|
||||||
|
|
||||||
|
gcc-ss = fetchurl {
|
||||||
|
url = "https://www.cse.iitd.ac.in/~cs5070217/csl718/gcc-${gcc-version}.ss.tar.gz";
|
||||||
|
sha256 = "sha256-3R3wsLmxoN3MkEW4gaxnhIyTBs0CUiSiH7C1/hF2atM=";
|
||||||
|
};
|
||||||
|
|
||||||
|
ar-and-ranlib = fetchurl {
|
||||||
|
url = "https://www.cse.iitd.ac.in/~cs5070217/csl718/ar_and_ranlib.tar.gz";
|
||||||
|
sha256 = "sha256-MRTO6cAg3WeXlk3jDy2lVuiSXDRz1+LLa2XDkBDygMU=";
|
||||||
|
};
|
||||||
|
in
|
||||||
|
''
|
||||||
|
tar xf ${simpletools}
|
||||||
|
rm -r gcc-2.6.3
|
||||||
|
|
||||||
|
tar xf ${gcc-ss}
|
||||||
|
|
||||||
|
mkdir ar-and-ranlib
|
||||||
|
tar xf ${ar-and-ranlib} -C ar-and-ranlib
|
||||||
|
|
||||||
|
chmod -R +w gcc-${gcc-version} ar-and-ranlib
|
||||||
|
'';
|
||||||
|
|
||||||
|
patches = [
|
||||||
|
./0001-fix-case-of-YY_CURRENT_BUFFER.patch
|
||||||
|
./0002-define-sys_nerr.patch
|
||||||
|
./0003-fix-obstack.h-post-increment.patch
|
||||||
|
./0004-stdarg.h-instead-of-varargs.h.patch
|
||||||
|
];
|
||||||
|
|
||||||
|
postPatch = ''
|
||||||
|
patchelf \
|
||||||
|
--set-interpreter "$(<${stdenv_32bit.cc}/nix-support/dynamic-linker-m32)" \
|
||||||
|
ar-and-ranlib/{ar,ranlib}
|
||||||
|
'';
|
||||||
|
|
||||||
|
configurePhase = ''
|
||||||
|
BUILD=$PWD
|
||||||
|
|
||||||
|
cd $BUILD/simplesim-3.0
|
||||||
|
make config-pisa
|
||||||
|
|
||||||
|
cd $BUILD/simpleutils-990811
|
||||||
|
./configure --host=${host} --target=${target} --with-gnu-as --with-gnu-ld --prefix=$out
|
||||||
|
|
||||||
|
cd $BUILD/gcc-${gcc-version}
|
||||||
|
./configure --host=${host} --target=${target} --with-gnu-as --with-gnu-ld --prefix=$out
|
||||||
|
'';
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
make -C $BUILD/simplesim-3.0
|
||||||
|
make -C $BUILD/simpleutils-990811
|
||||||
|
|
||||||
|
# GCC necesita binutils para compilar
|
||||||
|
make -C $BUILD/simpleutils-990811 install
|
||||||
|
cp $BUILD/ar-and-ranlib/{ar,ranlib} $out/${target}/bin/
|
||||||
|
|
||||||
|
cd $BUILD/gcc-${gcc-version}
|
||||||
|
|
||||||
|
mkdir -p $out/lib
|
||||||
|
cp patched/sys/cdefs.h $BUILD/${target}/include/sys/cdefs.h
|
||||||
|
cp -r $BUILD/${target} $out/
|
||||||
|
cp $BUILD/${target}/lib/{libc.a,crt0.o} $out/lib/
|
||||||
|
sed -i '130s@-I/usr/include@-I./include@' Makefile
|
||||||
|
|
||||||
|
! make ${makeflags}
|
||||||
|
sed -i 's/\(return "FIXME\\n\)/\1\\/g' insn-output.c
|
||||||
|
PATH="$out/${target}/bin:$PATH" make ${makeflags}
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
cp $BUILD/simplesim-3.0/{sim-{outorder,cache,profile,bpred,eio,safe,fast},sysprobe} $out/bin/
|
||||||
|
PATH="$out/${target}/bin:$PATH" make -C $BUILD/gcc-${gcc-version} ${makeflags} install
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Reference in a new issue