Create a LLVM based stdenv

This commit is contained in:
Sameer Rahmani 2023-12-03 19:00:20 +00:00
parent 9622dc8382
commit 5797bc2615
Signed by: lxsameer
GPG Key ID: B0A4AF28AB9FD90B
4 changed files with 226 additions and 61 deletions

View File

@ -20,10 +20,10 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"dirtyRev": "aa8d093e3bede559e5681ca69aa05e6e1ad4ee9a-dirty", "dirtyRev": "60a403eaffc56570ccc2fefebd1e09acd0ceab53-dirty",
"dirtyShortRev": "aa8d093e3bed-dirty", "dirtyShortRev": "60a403eaffc5-dirty",
"lastModified": 1700918627, "lastModified": 1701178202,
"narHash": "sha256-gcbm/2a4Hp4k2dpOl33hGARAiHMHH5HKyCSkzRGhpLQ=", "narHash": "sha256-WcFAx8yBoAGAUH6bCRJQWohtnzARZwpYh0H17LuAPZI=",
"type": "git", "type": "git",
"url": "file:///home/lxsameer/src/nixpkgs" "url": "file:///home/lxsameer/src/nixpkgs"
}, },

180
flake.nix
View File

@ -1,3 +1,18 @@
# Serene Programming Language
#
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
{ {
description = "Serene programming language"; description = "Serene programming language";
@ -7,6 +22,7 @@
outputs = inputs@{ self, nixpkgs, flake-utils, ... }: outputs = inputs@{ self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system: flake-utils.lib.eachDefaultSystem (system:
let let
zshDir = ./scripts/zsh;
llvm = { llvm = {
url = "https://devheroes.codes/Serene/llvm-project.git"; url = "https://devheroes.codes/Serene/llvm-project.git";
major = "16"; major = "16";
@ -16,32 +32,36 @@
rev-version = "17-disable-shared-1"; rev-version = "17-disable-shared-1";
}; };
overlays = [ overlays = [
(self: super: # (self: super:
{ # {
serene_toolchain = (super.callPackage (super.path + "/pkgs/development/compilers/llvm/${llvm.major}") ({ # serene_toolchain = (super.callPackage (super.path + "/pkgs/development/compilers/llvm/${llvm.major}") ({
inherit (super.stdenvAdapters) overrideCC; # inherit (super.stdenvAdapters) overrideCC;
buildLlvmTools = super.buildPackages.serene_toolchain.tools; # buildLlvmTools = super.buildPackages.serene_toolchain.tools;
targetLlvmLibraries = self.targetPackages.serene_toolchain.libraries or self.serene_toolchain.libraries; # targetLlvmLibraries = self.targetPackages.serene_toolchain.libraries or self.serene_toolchain.libraries;
targetLlvm = self.targetPackages.serene_toolchain.llvm or self.serene_toolchain.llvm; # targetLlvm = self.targetPackages.serene_toolchain.llvm or self.serene_toolchain.llvm;
monorepoSrc = super.fetchgit { # monorepoSrc = super.fetchgit {
url = llvm.url; # url = llvm.url;
rev = llvm.rev; # rev = llvm.rev;
hash = llvm.hash; # hash = llvm.hash;
}; # };
officialRelease = null; # officialRelease = null;
gitRelease = { # gitRelease = {
version = llvm.version; # version = llvm.version;
rev = llvm.rev; # rev = llvm.rev;
rev-version = llvm.rev-version; # rev-version = llvm.rev-version;
}; # };
})); # }));
}) # })
(final: prev: { (final: prev: {
cpio = prev.cpio.overrideAttrs (old: { p11-kit = prev.p11-kit.overrideAttrs (old: {
patches = [ patches = [
./patches/0001-configure-Include-needed-header-for-major-minor-macr.patch ./scripts/patches/p11-kit_skip_test.patch
]; ];
});
cpio = prev.cpio.overrideAttrs (old: {
nativeBuildInputs = [ prev.autoreconfHook ]; nativeBuildInputs = [ prev.autoreconfHook ];
NIX_CFLAGS_COMPILE = "-Wno-implicit-function-declaration"; NIX_CFLAGS_COMPILE = "-Wno-implicit-function-declaration";
}); });
@ -62,17 +82,34 @@
# We don't need systemd at all # We don't need systemd at all
util-linux = prev.util-linux.override { systemdSupport = false; }; util-linux = prev.util-linux.override { systemdSupport = false; };
# iwyu = (prev.include-what-you-use.overrideAttrs (old:
# let
# version = "0.20";
# in {
# inherit version;
# src = prev.fetchurl {
# url = "${old.meta.homepage}/downloads/${old.pname}-${version}.src.tar.gz";
# hash = "sha256-dfzh5khfKA+PE/TC0JCxHS/SECtQhXUHyEE6kZt6+Jk=";
# };
# cmakeFlags = [ "-DCMAKE_PREFIX_PATH=${prev.llvmPackages_16.llvm.dev}" ];
# })).override {
# llvmPackages = prev.__splicedPackages.llvmPackages_16;
# };
}) })
]; ];
get_pkgs = system: get_pkgs = system:
if system == "x86_64-linux" if system == "x86_64-linux"
then import nixpkgs { then import nixpkgs {
inherit system overlays; inherit system overlays;
crossSystem = nixpkgs.lib.systems.examples.musl64 // { useLLVM = true; }; crossSystem = nixpkgs.lib.systems.examples.musl64 // { useLLVM = true; };
config.replaceCrossStdenv = { buildPackages, baseStdenv }: config.replaceCrossStdenv = { buildPackages, baseStdenv }:
buildPackages.stdenvAdapters.overrideCC baseStdenv buildPackages.llvmPackages_16.clangUseLLVM; buildPackages.stdenvAdapters.overrideCC baseStdenv buildPackages.llvmPackages_16.clangUseLLVM;
} }
else import nixpkgs { else import nixpkgs {
inherit system overlays; inherit system overlays;
}; };
@ -83,54 +120,83 @@
#with pkgs; #with pkgs;
native_build_inputs = native_build_inputs =
let let
filterCmakeFlags = xs: builtins.filter
(x: !(x == "-DCMAKE_CROSSCOMPILING=True" || pkgs.lib.hasPrefix "-DLLVM_TABLEGEN=" x))
xs;
git' = pkgs.git.overrideAttrs (old: { git' = pkgs.git.overrideAttrs (old: {
preInstallCheck = preInstallCheck =
pkgs.lib.replaceStrings [ ''disable_test t0201-gettext-fallbacks'' ] pkgs.lib.replaceStrings [ ''disable_test t0201-gettext-fallbacks'' ]
[ '' [ ''
disable_test t0201-gettext-fallbacks disable_test t0201-gettext-fallbacks
disable_test t2082-parallel-checkout-attributes disable_test t2082-parallel-checkout-attributes
'' ] '' ]
old.preInstallCheck; old.preInstallCheck;
}); });
in with pkgs; [ # iwyu = (pkgs.include-what-you-use.overrideAttrs (old:
cmake # let
ninja # version = "0.20";
ccache # in {
# serene_toolchain.lldb # inherit version;
# serene_toolchain.lld
# serene_toolchain.libcxx
# serene_toolchain.libcxxabi
# serene_toolchain.compiler-rt
git'
zsh
python3
];
build_inputs = with pkgs; [ # src = pkgs.fetchurl {
# url = "${old.meta.homepage}/downloads/${old.pname}-${version}.src.tar.gz";
# hash = "sha256-dfzh5khfKA+PE/TC0JCxHS/SECtQhXUHyEE6kZt6+Jk=";
# };
# })).override {
# llvmPackages = pkgs.__splicedPackages.llvmPackages_16;# .overrideAttrs (oldLLVM: {
# # cmakeFlags = builtins.trace ">> ${toString(filterCmakeFlags oldLLVM.cmakeFlags)}" filterCmakeFlags oldLLVM.cmakeFlags;
# # });
# };
# mlir_16' = pkgs.mlir_16.overrideAttrs (old: {
# });
in with pkgs; [
cmake
ninja
ccache
git'
zsh
zsh-autosuggestions
zsh-autocomplete
zsh-syntax-highlighting
python3
# iwyu
];
build_inputs = with pkgs; [
boehmgc boehmgc
# llvm_16 # llvm_16
# llvm_16
# mlir_16
gtest gtest
gmock gmock
# zlib-ng # zlib-ng
# zstd # zstd
include-what-you-use
]; ];
in { in {
inherit pkgs; inherit pkgs;
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
nativeBuildInputs = native_build_inputs; nativeBuildInputs = native_build_inputs;
buildInputs = build_inputs; buildInputs = build_inputs;
shellHook = ''zsh --norcs && exit''; shellHook =
}; ''
ZDOTDIR=${zshDir} zsh -d && exit
'';
};
packages.cmake = pkgs.cmake; packages.cmake = pkgs.cmake;
packages.blah = pkgs.stdenv.mkDerivation { packages.blah = pkgs.stdenv.mkDerivation {
pname = "blah"; pname = "blah";
version = "0.1"; version = "0.1";
nativeBuildInputs = native_build_inputs; nativeBuildInputs = native_build_inputs;
buildInputs = build_inputs; buildInputs = build_inputs;
}; };
} packages.mlir = pkgs.mlir_16;
}
); );
} }

View File

@ -0,0 +1,27 @@
From 132b779414c2236c1350b578b59c8edcfc4c5a14 Mon Sep 17 00:00:00 2001
From: Sameer Rahmani <lxsameer@gnu.org>
Date: Sat, 25 Nov 2023 13:14:42 +0000
Subject: [PATCH] test
---
common/test.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/common/test.c b/common/test.c
index 6cdbd1fa2118..6cd6f84bcdc7 100644
--- a/common/test.c
+++ b/common/test.c
@@ -614,8 +614,9 @@ p11_test_copy_setgid (const char *input,
assert (fd >= 0);
copy_file (input, fd);
- if (fchown (fd, getuid (), group) < 0)
- assert_not_reached ();
+ if (fchown (fd, getuid (), group) < 0) {
+ return NULL;
+ }
if (fchmod (fd, 02750) < 0)
assert_not_reached ();
if (close (fd) < 0)
--
2.41.0

72
scripts/zsh/.zshrc Normal file
View File

@ -0,0 +1,72 @@
#! /bin/zsh
# shellcheck disable=all
# Serene Programming Language
#
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
mkdir -p "$HOME/.config/serene/"
export HISTFILE="$HOME/.config/serene/.zsh_history"
export HISTFILESIZE=500
export SAVEHIST=500
export HISTSIZE=500
setopt HIST_IGNORE_DUPS
setopt NO_HIST_BEEP
setopt PROMPT_SUBST
setopt NO_BEEP
setopt AUTO_CD
setopt CORRECT
setopt SHARE_HISTORY
setopt HIST_IGNORE_ALL_DUPS
function user_prompt () {
if [ $UID != 0 ]; then
echo "%F{028}%F{002}> "
else
echo "%F{001}# "
fi
}
autoload -U colors && colors
autoload -Uz compinit
compinit
# zstyle ':completion:*' auto-description 'specify: %d'
# zstyle ':completion:*' completer _expand _complete _correct _approximate
# zstyle ':completion:*' format 'Completing %d'
# zstyle ':completion:*' group-name ''
# if [ "$(uname 2> /dev/null)" = "Linux" ]; then
# zstyle ':completion:*' menu select=2 eval "$(dircolors -b)"
# fi
# zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
# zstyle ':completion:*' list-colors ''
# zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
# zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*'
# zstyle ':completion:*' menu select=long
# zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
# zstyle ':completion:*' use-compctl false
# zstyle ':completion:*' verbose true
# zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
# zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
echo "Welcome to serene's development environment"
PROMPT='
%F{015}[%F{099}SERENE%F{015}][%F{198}$(git branch --show-current)%F{015}]
%F{005}%~%F{003} $(user_prompt)%f'
export PROMPT