Add the serene_llvm package as the default toolchain
This commit is contained in:
parent
5797bc2615
commit
75c3fff58e
15
flake.nix
15
flake.nix
|
@ -98,7 +98,6 @@
|
||||||
# })).override {
|
# })).override {
|
||||||
# llvmPackages = prev.__splicedPackages.llvmPackages_16;
|
# llvmPackages = prev.__splicedPackages.llvmPackages_16;
|
||||||
# };
|
# };
|
||||||
|
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -117,9 +116,16 @@
|
||||||
|
|
||||||
pkgs = get_pkgs system;
|
pkgs = get_pkgs system;
|
||||||
|
|
||||||
|
sereneLLVM = pkgs.callPackage ./nix/llvm.nix {
|
||||||
|
inherit (pkgs) lib stdenv cmake ninja ccache zlib libxml2 fetchgit;
|
||||||
|
};
|
||||||
|
|
||||||
|
stdenv = pkgs.stdenvAdapters.overrideCC pkgs.stdenv sereneLLVM;
|
||||||
#with pkgs;
|
#with pkgs;
|
||||||
native_build_inputs =
|
native_build_inputs =
|
||||||
let
|
let
|
||||||
|
|
||||||
|
|
||||||
filterCmakeFlags = xs: builtins.filter
|
filterCmakeFlags = xs: builtins.filter
|
||||||
(x: !(x == "-DCMAKE_CROSSCOMPILING=True" || pkgs.lib.hasPrefix "-DLLVM_TABLEGEN=" x))
|
(x: !(x == "-DCMAKE_CROSSCOMPILING=True" || pkgs.lib.hasPrefix "-DLLVM_TABLEGEN=" x))
|
||||||
xs;
|
xs;
|
||||||
|
@ -153,7 +159,7 @@
|
||||||
# mlir_16' = pkgs.mlir_16.overrideAttrs (old: {
|
# mlir_16' = pkgs.mlir_16.overrideAttrs (old: {
|
||||||
|
|
||||||
# });
|
# });
|
||||||
in with pkgs; [
|
in builtins.trace ">> ${sereneLLVM}" (with pkgs; [
|
||||||
cmake
|
cmake
|
||||||
ninja
|
ninja
|
||||||
ccache
|
ccache
|
||||||
|
@ -163,8 +169,9 @@
|
||||||
zsh-autocomplete
|
zsh-autocomplete
|
||||||
zsh-syntax-highlighting
|
zsh-syntax-highlighting
|
||||||
python3
|
python3
|
||||||
|
sereneLLVM
|
||||||
# iwyu
|
# iwyu
|
||||||
];
|
]);
|
||||||
|
|
||||||
build_inputs = with pkgs; [
|
build_inputs = with pkgs; [
|
||||||
boehmgc
|
boehmgc
|
||||||
|
@ -180,7 +187,7 @@
|
||||||
|
|
||||||
in {
|
in {
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = (pkgs.mkShell.override {inherit stdenv;}) {
|
||||||
nativeBuildInputs = native_build_inputs;
|
nativeBuildInputs = native_build_inputs;
|
||||||
buildInputs = build_inputs;
|
buildInputs = build_inputs;
|
||||||
shellHook =
|
shellHook =
|
||||||
|
|
|
@ -0,0 +1,163 @@
|
||||||
|
# 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/>.
|
||||||
|
{ lib,
|
||||||
|
stdenv,
|
||||||
|
cmake,
|
||||||
|
ninja,
|
||||||
|
libxml2,
|
||||||
|
python3,
|
||||||
|
fetchgit,
|
||||||
|
zlib,
|
||||||
|
ccache ? null,
|
||||||
|
useCcache ? false,
|
||||||
|
url ? "https://github.com/llvm/llvm-project.git",
|
||||||
|
hash ? "sha256-8MEDLLhocshmxoEBRSKlJ/GzJ8nfuzQ8qn0X/vLA+ag=",
|
||||||
|
version ? "17.0.6",
|
||||||
|
ref ? "refs/tags/llvmorg-${version}"
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
ncpus = builtins.getEnv "NIX_BUILD_CORES";
|
||||||
|
in builtins.trace ">>> ${toString ncpus}" stdenv.mkDerivation rec {
|
||||||
|
inherit version;
|
||||||
|
pname = "serene_llvm";
|
||||||
|
|
||||||
|
src = fetchgit {
|
||||||
|
inherit url hash;
|
||||||
|
rev = ref;
|
||||||
|
};
|
||||||
|
|
||||||
|
sourceRoot = "${src.name}/llvm";
|
||||||
|
|
||||||
|
nativeBuildInputs = [ cmake ninja python3 zlib ];
|
||||||
|
buildInputs = [ libxml2 zlib ];
|
||||||
|
|
||||||
|
NIX_CFLAGS_COMPILE = ["-fno-rtti"];
|
||||||
|
#ninjaFlags = [ "-v" ];
|
||||||
|
cmakeFlags = [
|
||||||
|
# "-DLLVM_PARALLEL_COMPILE_JOBS=${ncpus}"
|
||||||
|
# "-DLLVM_PARALLEL_LINK_JOBS=1"
|
||||||
|
"-DLLVM_BUILD_EXAMPLES=ON"
|
||||||
|
"-DLLVM_TARGETS_TO_BUILD='X86'"
|
||||||
|
"-DCMAKE_BUILD_TYPE=Release"
|
||||||
|
"-DLLVM_ENABLE_ASSERTIONS=ON"
|
||||||
|
"-DLLVM_CCACHE_BUILD=OFF"
|
||||||
|
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
|
||||||
|
|
||||||
|
# No lldb? Yes, lldb links against liblldb.so and since we use
|
||||||
|
# -static with our executables that wouldn't be easy to handle
|
||||||
|
# and I'm lazy. We can just compile the lldb or any other debugger
|
||||||
|
# on the host
|
||||||
|
"-DLLVM_ENABLE_PROJECTS='clang;lld;mlir;clang-tools-extra'"
|
||||||
|
"-DLLVM_RUNTIME_TARGETS='compiler-rt;libcxx;libcxxabi;libunwind'"
|
||||||
|
"-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
|
||||||
|
"-DLLVM_RUNTIME_TARGET=${stdenv.hostPlatform.config}"
|
||||||
|
# Serene uses static libs, so no shared lib
|
||||||
|
"-DLLVM_ENABLE_PIC=OFF"
|
||||||
|
#"-DLLVM_BUILD_STATIC=ON"
|
||||||
|
"-DLLVM_LINK_LLVM_DYLIB=off"
|
||||||
|
|
||||||
|
"-DLLVM_ENABLE_LIBXML2=OFF"
|
||||||
|
"-DLLVM_BUILD_DOCS=OFF"
|
||||||
|
"-DLLVM_ENABLE_SPHINX=OFF"
|
||||||
|
"-DSPHINX_OUTPUT_MAN=OFF"
|
||||||
|
"-DSPHINX_OUTPUT_HTML=OFF"
|
||||||
|
|
||||||
|
"-DCMAKE_POSITION_INDEPENDENT_CODE=ON"
|
||||||
|
"-DCLANG_DEFAULT_CXX_STDLIB=libc++"
|
||||||
|
"-DCLANG_DEFAULT_LINKER=lld"
|
||||||
|
"-DCLANG_DEFAULT_OBJCOPY=llvm-objcopy"
|
||||||
|
"-DCLANG_DEFAULT_RTLIB=compiler-rt"
|
||||||
|
"-DCLANG_VENDOR_UTI=serene.toolchain"
|
||||||
|
"-DLLVM_ENABLE_LIBCXX=ON"
|
||||||
|
|
||||||
|
"-DLLVM_ENABLE_NEW_PASS_MANAGER=ON"
|
||||||
|
"-DLLVM_BUILD_TESTS=OFF"
|
||||||
|
"-DLLVM_ENABLE_ASSERTIONS=ON"
|
||||||
|
"-DLLVM_ENABLE_LIBXML2=OFF"
|
||||||
|
"-DLLVM_ENABLE_TERMINFO=OFF"
|
||||||
|
#"-DLLVM_ENABLE_ZLIB=FORCE_ON"
|
||||||
|
"-DLLVM_INCLUDE_BENCHMARKS=OFF"
|
||||||
|
"-DLLVM_INCLUDE_EXAMPLES=OFF"
|
||||||
|
"-DLLVM_INCLUDE_TESTS=OFF"
|
||||||
|
"-DLLVM_INCLUDE_GO_TESTS=OFF"
|
||||||
|
"-DLLVM_ENABLE_BINDINGS=OFF"
|
||||||
|
#"-DLLVM_TARGETS_TO_BUILD": "X86;AArch64;AMDGPU;ARM;RISCV;WebAssembly"
|
||||||
|
"-DLLVM_STATIC_LINK_CXX_STDLIB=ON"
|
||||||
|
"-DPACKAGE_VENDOR=Serene"
|
||||||
|
"-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON"
|
||||||
|
"-DENABLE_X86_RELAX_RELOCATIONS=ON"
|
||||||
|
"-DBUILD_SHARED_LIBS=OFF"
|
||||||
|
"-DCLANG_ENABLE_BOOTSTRAP=ON"
|
||||||
|
"-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON"
|
||||||
|
"-DLIBCXXABI_ENABLE_SHARED=OFF"
|
||||||
|
"-DLIBCXX_ABI_VERSION=2"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"-DLIBCLANG_BUILD_STATIC=ON"
|
||||||
|
|
||||||
|
"-DCMAKE_INSTALL_PREFIX=${placeholder "out"}"
|
||||||
|
"-DCMAKE_INSTALL_BINDIR=${placeholder "out"}/bin"
|
||||||
|
"-DCMAKE_INSTALL_INCLUDEDIR=${placeholder "out"}/include"
|
||||||
|
"-DCMAKE_INSTALL_LIBDIR=${placeholder "out"}/lib"
|
||||||
|
"-DCMAKE_INSTALL_LIBEXECDIR=${placeholder "out"}/libexec"
|
||||||
|
] ++ lib.optional stdenv.hostPlatform.isMusl [
|
||||||
|
"-DDLIBCXX_HAS_MUSL_LIBC=ON"
|
||||||
|
] ++ lib.optional stdenv.hostPlatform.isStatic [
|
||||||
|
"-DLIBCLANG_BUILD_STATIC=ON"
|
||||||
|
] ++ lib.optional useCcache [
|
||||||
|
"-DLLVM_CCACHE_BUILD=ON"
|
||||||
|
];
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
homepage = "https://llvm.org/";
|
||||||
|
description = "A collection of modular and reusable compiler and toolchain technologies";
|
||||||
|
longDescription = ''
|
||||||
|
The LLVM Project is a collection of modular and reusable compiler and
|
||||||
|
toolchain technologies. Despite its name, LLVM has little to do with
|
||||||
|
traditional virtual machines. The name "LLVM" itself is not an acronym; it
|
||||||
|
is the full name of the project.
|
||||||
|
LLVM began as a research project at the University of Illinois, with the
|
||||||
|
goal of providing a modern, SSA-based compilation strategy capable of
|
||||||
|
supporting both static and dynamic compilation of arbitrary programming
|
||||||
|
languages. Since then, LLVM has grown to be an umbrella project consisting
|
||||||
|
of a number of subprojects, many of which are being used in production by
|
||||||
|
a wide variety of commercial and open source projects as well as being
|
||||||
|
widely used in academic research. Code in the LLVM project is licensed
|
||||||
|
under the "Apache 2.0 License with LLVM exceptions".
|
||||||
|
'';
|
||||||
|
license = lib.licenses.ncsa;
|
||||||
|
|
||||||
|
# TODO: Add the maintainer
|
||||||
|
# maintainers = "Sameer Rahmani []";
|
||||||
|
|
||||||
|
# See llvm/cmake/config-ix.cmake.
|
||||||
|
platforms =
|
||||||
|
lib.platforms.aarch64 ++
|
||||||
|
lib.platforms.arm ++
|
||||||
|
lib.platforms.mips ++
|
||||||
|
lib.platforms.power ++
|
||||||
|
lib.platforms.s390x ++
|
||||||
|
lib.platforms.wasi ++
|
||||||
|
lib.platforms.x86 ++
|
||||||
|
lib.platforms.riscv ++
|
||||||
|
lib.platforms.m68k;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
# -DCMAKE_C_COMPILER=clang \ # If you have clang installed already
|
||||||
|
# -DCMAKE_CXX_COMPILER=clang++ \ # If you have clang installed already
|
||||||
|
# -DLLVM_ENABLE_LLD=ON
|
|
@ -0,0 +1,19 @@
|
||||||
|
# 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/>.
|
||||||
|
{ lib }:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue