Update
This commit is contained in:
parent
d29fbac641
commit
198461b4bc
6 changed files with 176 additions and 30 deletions
6
.envrc
6
.envrc
|
@ -1,7 +1 @@
|
||||||
export CHICKEN_INSTALL_PREFIX="$(pwd)/.chicken"
|
|
||||||
export CHICKEN_REPOSITORY_PATH="${CHICKEN_REPOSITORY_PATH}:$(pwd)/.chicken/eggs"
|
|
||||||
export CHICKEN_INSTALL_REPOSITORY="$(pwd)/.chicken/eggs"
|
|
||||||
export CHICKEN_DOC_REPOSITORY="$(pwd)/.local/chicken/chicken-doc"
|
|
||||||
mkdir -p "${CHICKEN_DOC_REPOSITORY}"
|
|
||||||
curl https://3e8.org/pub/chicken-doc/chicken-doc-repo-5.tgz | gzip -d | tar -xf - -C "${CHICKEN_DOC_REPOSITORY}/.."
|
|
||||||
use flake . --impure --show-trace
|
use flake . --impure --show-trace
|
||||||
|
|
7
README.org
Normal file
7
README.org
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#+title: Chicken 6 Flake
|
||||||
|
|
||||||
|
A flake to use Chicken 6 with TinyCC.
|
||||||
|
|
||||||
|
** Adjusting the flake
|
||||||
|
|
||||||
|
If you want to use a newer revision of Chicken 6, update =rev= in =nix/chicken.nix=. Nix will tell you what to replace the =sha256= with, and will build Chicken 6 for you after a retry.
|
19
flake.lock
19
flake.lock
|
@ -2,11 +2,11 @@
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1726243404,
|
"lastModified": 1726755586,
|
||||||
"narHash": "sha256-sjiGsMh+1cWXb53Tecsm4skyFNag33GPbVgCdfj3n9I=",
|
"narHash": "sha256-PmUr/2GQGvFTIJ6/Tvsins7Q43KTMvMFhvG6oaYK+Wk=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "345c263f2f53a3710abe117f28a5cb86d0ba4059",
|
"rev": "c04d5652cfa9742b1d519688f65d1bbccea9eb7e",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -24,17 +24,16 @@
|
||||||
},
|
},
|
||||||
"systems": {
|
"systems": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1689347949,
|
"lastModified": 1681028828,
|
||||||
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
"owner": "nix-systems",
|
"owner": "nix-systems",
|
||||||
"repo": "default-linux",
|
"repo": "default",
|
||||||
"rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "nix-systems",
|
"id": "systems",
|
||||||
"repo": "default-linux",
|
"type": "indirect"
|
||||||
"type": "github"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
28
flake.nix
28
flake.nix
|
@ -1,9 +1,8 @@
|
||||||
{
|
{
|
||||||
description = "A flake to use a development version of Chicken.";
|
description = "A flake to use Chicken 6 with TinyCC.";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
systems.url = "github:nix-systems/default-linux";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = inputs @ {
|
outputs = inputs @ {
|
||||||
|
@ -13,8 +12,14 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (nixpkgs) lib;
|
inherit (nixpkgs) lib;
|
||||||
eachSystem = lib.genAttrs (import systems);
|
forAllSystems = lib.genAttrs [
|
||||||
pkgsFor = eachSystem (system:
|
"aarch64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
"aarch64-darwin"
|
||||||
|
"x86_64-darwin"
|
||||||
|
];
|
||||||
|
pkgsFor = forAllSystems (system:
|
||||||
import nixpkgs {
|
import nixpkgs {
|
||||||
localSystem.system = system;
|
localSystem.system = system;
|
||||||
overlays = with self.overlays; [chicken];
|
overlays = with self.overlays; [chicken];
|
||||||
|
@ -30,20 +35,29 @@
|
||||||
default = self.overlays.chicken;
|
default = self.overlays.chicken;
|
||||||
|
|
||||||
chicken = final: prev: {
|
chicken = final: prev: {
|
||||||
chicken = final.callPackage ./nix/default.nix {
|
tcc-mob = final.callPackage ./nix/tinycc.nix {
|
||||||
|
stdenv = final.gcc13Stdenv;
|
||||||
|
};
|
||||||
|
chicken = final.callPackage ./nix/chicken.nix {
|
||||||
stdenv = final.gcc13Stdenv;
|
stdenv = final.gcc13Stdenv;
|
||||||
version = version + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty");
|
version = version + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty");
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
devShells = eachSystem (system: {
|
devShells = forAllSystems (system: {
|
||||||
default = let
|
default = let
|
||||||
pkgs = import nixpkgs {
|
pkgs = import nixpkgs {
|
||||||
overlays = [ self.overlays.chicken ];
|
overlays = [ self.overlays.chicken ];
|
||||||
};
|
};
|
||||||
in pkgs.mkShell {
|
in pkgs.mkShell {
|
||||||
packages = [ pkgs.chicken ];
|
packages = with pkgs; [ tcc-mob chicken ];
|
||||||
|
shellHook = ''
|
||||||
|
export CC=${pkgs.tcc-mob}/bin/tcc
|
||||||
|
export CHICKEN_INSTALL_REPOSITORY="$(pwd)/.chicken/eggs"
|
||||||
|
export CHICKEN_REPOSITORY_PATH="${pkgs.chicken}/lib/chicken/11:$CHICKEN_REPOSITORY_PATH:$(pwd)/.chicken/eggs"
|
||||||
|
export PATH="$PATH:$CHICKEN_INSTALL_PREFIX/bin"
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
fetchurl,
|
fetchurl,
|
||||||
makeWrapper,
|
makeWrapper,
|
||||||
darwin,
|
darwin,
|
||||||
|
tcc-mob,
|
||||||
version ? "git",
|
version ? "git",
|
||||||
testers
|
testers
|
||||||
}:
|
}:
|
||||||
|
@ -25,7 +26,7 @@ stdenv.mkDerivation (finalAttrs: {
|
||||||
|
|
||||||
srcs = [
|
srcs = [
|
||||||
(fetchgit {
|
(fetchgit {
|
||||||
url = "https://code.call-cc.org/git/chicken-core.git";
|
url = "git://code.call-cc.org/chicken-core";
|
||||||
rev = "dbffda19e57c3be092e5a9174f1829632f5fa5a7";
|
rev = "dbffda19e57c3be092e5a9174f1829632f5fa5a7";
|
||||||
sha256 = "sha256-zWjf9JS4H1buBlkmUhIv+odCQzXaOPtI7VfIaQUhe6Q=";
|
sha256 = "sha256-zWjf9JS4H1buBlkmUhIv+odCQzXaOPtI7VfIaQUhe6Q=";
|
||||||
})
|
})
|
||||||
|
@ -52,10 +53,11 @@ stdenv.mkDerivation (finalAttrs: {
|
||||||
*)
|
*)
|
||||||
mkcmd=make;;
|
mkcmd=make;;
|
||||||
esac
|
esac
|
||||||
$mkcmd PREFIX="$(pwd)"/../snapshot
|
export CC="${tcc-mob}/bin/tcc"
|
||||||
$mkcmd PREFIX="$(pwd)"/../snapshot install
|
$mkcmd C_COMPILER=$CC PREFIX="$(pwd)"/../snapshot
|
||||||
|
$mkcmd C_COMPILER=$CC PREFIX="$(pwd)"/../snapshot install
|
||||||
cd ../..
|
cd ../..
|
||||||
./configure --chicken "$(pwd)"/boot/snapshot/bin/chicken
|
./configure --chicken "$(pwd)"/boot/snapshot/bin/chicken --c-compiler "${tcc-mob}/bin/tcc"
|
||||||
$mkcmd boot-chicken
|
$mkcmd boot-chicken
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
@ -71,7 +73,7 @@ stdenv.mkDerivation (finalAttrs: {
|
||||||
makeFlags = [
|
makeFlags = [
|
||||||
"PLATFORM=${platform}"
|
"PLATFORM=${platform}"
|
||||||
"PREFIX=$(out)"
|
"PREFIX=$(out)"
|
||||||
"C_COMPILER=$(CC)"
|
"C_COMPILER=${tcc-mob}/bin/tcc"
|
||||||
"CXX_COMPILER=$(CXX)"
|
"CXX_COMPILER=$(CXX)"
|
||||||
] ++ (lib.optionals stdenv.isDarwin [
|
] ++ (lib.optionals stdenv.isDarwin [
|
||||||
"XCODE_TOOL_PATH=${darwin.binutils.bintools}/bin"
|
"XCODE_TOOL_PATH=${darwin.binutils.bintools}/bin"
|
||||||
|
@ -79,19 +81,20 @@ stdenv.mkDerivation (finalAttrs: {
|
||||||
"POSTINSTALL_PROGRAM=install_name_tool"
|
"POSTINSTALL_PROGRAM=install_name_tool"
|
||||||
]) ++ (lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
]) ++ (lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
||||||
"HOSTSYSTEM=${stdenv.hostPlatform.config}"
|
"HOSTSYSTEM=${stdenv.hostPlatform.config}"
|
||||||
"TARGET_C_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"
|
"TARGET_C_COMPILER=${tcc-mob}/bin/${stdenv.cc.targetPrefix}tcc"
|
||||||
"TARGET_CXX_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++"
|
"TARGET_CXX_COMPILER=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
makeWrapper
|
makeWrapper
|
||||||
pkgs.hostname
|
pkgs.hostname
|
||||||
|
tcc-mob
|
||||||
] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
|
] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
|
||||||
darwin.autoSignDarwinBinariesHook
|
darwin.autoSignDarwinBinariesHook
|
||||||
];
|
];
|
||||||
|
|
||||||
configurePhase = ''
|
configurePhase = ''
|
||||||
./configure --chicken ./chicken-boot --prefix $PREFIX --platform=$PLATFORM
|
./configure --chicken ./chicken-boot --prefix $PREFIX --platform=$PLATFORM --c-compiler "${tcc-mob}/bin/tcc"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
doCheck = !stdenv.isDarwin;
|
doCheck = !stdenv.isDarwin;
|
129
nix/tinycc.nix
Normal file
129
nix/tinycc.nix
Normal file
|
@ -0,0 +1,129 @@
|
||||||
|
{ lib
|
||||||
|
, copyPkgconfigItems
|
||||||
|
, fetchFromRepoOrCz
|
||||||
|
, makePkgconfigItem
|
||||||
|
, perl
|
||||||
|
, stdenv
|
||||||
|
, texinfo
|
||||||
|
, which
|
||||||
|
}:
|
||||||
|
|
||||||
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
|
pname = "tcc-mob";
|
||||||
|
version = "0.9.29-unstable-2024-09-16";
|
||||||
|
|
||||||
|
src = fetchFromRepoOrCz {
|
||||||
|
repo = "tinycc";
|
||||||
|
rev = "b8b6a5fd7b4e8cab8e5a5d01064cf5bf2b5eed95";
|
||||||
|
hash = "sha256-jY0P2GErmo//YBaz6u4/jj/voOE3C2JaIDRmo0orXN8=";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = [ "out" "info" "man" ];
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
copyPkgconfigItems
|
||||||
|
perl
|
||||||
|
texinfo
|
||||||
|
which
|
||||||
|
];
|
||||||
|
|
||||||
|
strictDeps = true;
|
||||||
|
|
||||||
|
pkgconfigItems = let
|
||||||
|
libtcc-pcitem = {
|
||||||
|
name = "libtcc";
|
||||||
|
inherit (finalAttrs) version;
|
||||||
|
cflags = [ "-I${libtcc-pcitem.variables.includedir}" ];
|
||||||
|
libs = [
|
||||||
|
"-L${libtcc-pcitem.variables.libdir}"
|
||||||
|
"-Wl,--rpath ${libtcc-pcitem.variables.libdir}"
|
||||||
|
"-ltcc"
|
||||||
|
];
|
||||||
|
variables = {
|
||||||
|
prefix = "${placeholder "out"}";
|
||||||
|
includedir = "${placeholder "dev"}/include";
|
||||||
|
libdir = "${placeholder "lib"}/lib";
|
||||||
|
};
|
||||||
|
description = "Tiny C compiler backend";
|
||||||
|
};
|
||||||
|
in [
|
||||||
|
(makePkgconfigItem libtcc-pcitem)
|
||||||
|
];
|
||||||
|
|
||||||
|
postPatch = ''
|
||||||
|
patchShebangs texi2pod.pl
|
||||||
|
'';
|
||||||
|
|
||||||
|
configureFlags = [
|
||||||
|
"--cc=$CC"
|
||||||
|
"--ar=$AR"
|
||||||
|
"--crtprefix=${lib.getLib stdenv.cc.libc}/lib"
|
||||||
|
"--sysincludepaths=${lib.getDev stdenv.cc.libc}/include:{B}/include"
|
||||||
|
"--libpaths=${lib.getLib stdenv.cc.libc}/lib"
|
||||||
|
# build cross compilers
|
||||||
|
"--enable-cross"
|
||||||
|
] ++ lib.optionals stdenv.hostPlatform.isMusl [
|
||||||
|
"--config-musl"
|
||||||
|
];
|
||||||
|
|
||||||
|
preConfigure = let
|
||||||
|
# To avoid "malformed 32-bit x.y.z" error on mac when using clang
|
||||||
|
versionIsClean = version:
|
||||||
|
builtins.match "^[0-9]\\.+[0-9]+\\.[0-9]+" version != null;
|
||||||
|
in ''
|
||||||
|
${
|
||||||
|
if stdenv.isDarwin && ! versionIsClean finalAttrs.version
|
||||||
|
then "echo 'not overwriting VERSION since it would upset ld'"
|
||||||
|
else "echo ${finalAttrs.version} > VERSION"
|
||||||
|
}
|
||||||
|
configureFlagsArray+=("--elfinterp=$(< $NIX_CC/nix-support/dynamic-linker)")
|
||||||
|
'';
|
||||||
|
|
||||||
|
env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.cc.isClang [
|
||||||
|
"-Wno-error=implicit-int"
|
||||||
|
"-Wno-error=int-conversion"
|
||||||
|
]);
|
||||||
|
|
||||||
|
# Test segfault for static build
|
||||||
|
doCheck = !stdenv.hostPlatform.isStatic;
|
||||||
|
|
||||||
|
checkTarget = "test";
|
||||||
|
# https://www.mail-archive.com/tinycc-devel@nongnu.org/msg10142.html
|
||||||
|
preCheck = lib.optionalString (stdenv.isDarwin && stdenv.isx86_64) ''
|
||||||
|
rm tests/tests2/{108,114}*
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
homepage = "https://repo.or.cz/tinycc.git";
|
||||||
|
description = "Small, fast, and embeddable C compiler and interpreter";
|
||||||
|
longDescription = ''
|
||||||
|
TinyCC (aka TCC) is a small but hyper fast C compiler. Unlike other C
|
||||||
|
compilers, it is meant to be self-sufficient: you do not need an external
|
||||||
|
assembler or linker because TCC does that for you.
|
||||||
|
|
||||||
|
TCC compiles so fast that even for big projects Makefiles may not be
|
||||||
|
necessary.
|
||||||
|
|
||||||
|
TCC not only supports ANSI C, but also most of the new ISO C99 standard
|
||||||
|
and many GNU C extensions.
|
||||||
|
|
||||||
|
TCC can also be used to make C scripts, i.e. pieces of C source that you
|
||||||
|
run as a Perl or Python script. Compilation is so fast that your script
|
||||||
|
will be as fast as if it was an executable.
|
||||||
|
|
||||||
|
TCC can also automatically generate memory and bound checks while allowing
|
||||||
|
all C pointers operations. TCC can do these checks even if non patched
|
||||||
|
libraries are used.
|
||||||
|
|
||||||
|
With libtcc, you can use TCC as a backend for dynamic code generation.
|
||||||
|
'';
|
||||||
|
license = with lib.licenses; [ lgpl21Only ];
|
||||||
|
mainProgram = "tcc";
|
||||||
|
maintainers = with lib.maintainers; [ joachifm AndersonTorres ];
|
||||||
|
platforms = lib.platforms.unix;
|
||||||
|
# https://www.mail-archive.com/tinycc-devel@nongnu.org/msg10199.html
|
||||||
|
broken = stdenv.isDarwin && stdenv.isAarch64;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
# TODO: more multiple outputs
|
||||||
|
# TODO: self-compilation
|
Loading…
Reference in a new issue