mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 08:23:09 +00:00
arocc: init at 0-unstable-06-01
This commit is contained in:
parent
8045879c88
commit
9f589ea3a0
@ -27,8 +27,11 @@ for var in "${var_templates_bool[@]}"; do
|
||||
mangleVarBool "$var" ${role_suffixes[@]+"${role_suffixes[@]}"}
|
||||
done
|
||||
|
||||
# `-B@out@/bin' forces cc to use ld-wrapper.sh when calling ld.
|
||||
NIX_CFLAGS_COMPILE_@suffixSalt@="-B@out@/bin/ $NIX_CFLAGS_COMPILE_@suffixSalt@"
|
||||
# Arocc does not support "-B"
|
||||
if [[ -z "@isArocc@" ]]; then
|
||||
# `-B@out@/bin' forces cc to use ld-wrapper.sh when calling ld.
|
||||
NIX_CFLAGS_COMPILE_@suffixSalt@="-B@out@/bin/ $NIX_CFLAGS_COMPILE_@suffixSalt@"
|
||||
fi
|
||||
|
||||
# Export and assign separately in order that a failing $(..) will fail
|
||||
# the script.
|
||||
|
@ -79,6 +79,11 @@ if [ "$nonFlagArgs" = 0 ]; then
|
||||
dontLink=1
|
||||
fi
|
||||
|
||||
# Arocc does not link
|
||||
if [ "@isArocc@" = 1 ]; then
|
||||
dontLink=1
|
||||
fi
|
||||
|
||||
# Optionally filter out paths not refering to the store.
|
||||
if [[ "${NIX_ENFORCE_PURITY:-}" = 1 && -n "$NIX_STORE" ]]; then
|
||||
kept=()
|
||||
|
@ -15,7 +15,8 @@
|
||||
, propagateDoc ? cc != null && cc ? man
|
||||
, extraTools ? [], extraPackages ? [], extraBuildCommands ? ""
|
||||
, nixSupport ? {}
|
||||
, isGNU ? false, isClang ? cc.isClang or false, isZig ? cc.isZig or false, isCcache ? cc.isCcache or false
|
||||
, isGNU ? false, isClang ? cc.isClang or false, isZig ? cc.isZig or false
|
||||
, isArocc ? cc.isArocc or false, isCcache ? cc.isCcache or false
|
||||
, gnugrep ? null
|
||||
, expand-response-params
|
||||
, libcxx ? null
|
||||
@ -305,6 +306,9 @@ stdenvNoCC.mkDerivation {
|
||||
|
||||
outputs = [ "out" ] ++ optionals propagateDoc [ "man" "info" ];
|
||||
|
||||
# Cannot be in "passthru" due to "substituteAll"
|
||||
inherit isArocc;
|
||||
|
||||
passthru = {
|
||||
inherit targetPrefix suffixSalt;
|
||||
# "cc" is the generic name for a C compiler, but there is no one for package
|
||||
@ -392,6 +396,10 @@ stdenvNoCC.mkDerivation {
|
||||
ln -s ${targetPrefix}clang $out/bin/${targetPrefix}cc
|
||||
export named_cc=${targetPrefix}clang
|
||||
export named_cxx=${targetPrefix}clang++
|
||||
elif [ -e $ccPath/arocc ]; then
|
||||
wrap ${targetPrefix}arocc $wrapper $ccPath/arocc
|
||||
ln -s ${targetPrefix}arocc $out/bin/${targetPrefix}cc
|
||||
export named_cc=${targetPrefix}arocc
|
||||
fi
|
||||
|
||||
if [ -e $ccPath/${targetPrefix}g++ ]; then
|
||||
@ -476,7 +484,7 @@ stdenvNoCC.mkDerivation {
|
||||
#
|
||||
# TODO(@Ericson2314): Remove this after stable release and force
|
||||
# everyone to refer to bintools-wrapper directly.
|
||||
+ ''
|
||||
+ optionalString (!isArocc) ''
|
||||
if [[ -f "$bintools/nix-support/dynamic-linker" ]]; then
|
||||
ln -s "$bintools/nix-support/dynamic-linker" "$out/nix-support"
|
||||
fi
|
||||
@ -492,7 +500,7 @@ stdenvNoCC.mkDerivation {
|
||||
|
||||
echo "-B${gccForLibs}/lib/gcc/${targetPlatform.config}/${gccForLibs.version}" >> $out/nix-support/cc-cflags
|
||||
''
|
||||
+ optionalString useGccForLibs ''
|
||||
+ optionalString (useGccForLibs && !isArocc) ''
|
||||
echo "-L${gccForLibs}/lib/gcc/${targetPlatform.config}/${gccForLibs.version}" >> $out/nix-support/cc-ldflags
|
||||
echo "-L${gccForLibs_solib}/lib" >> $out/nix-support/cc-ldflags
|
||||
''
|
||||
@ -518,9 +526,9 @@ stdenvNoCC.mkDerivation {
|
||||
''
|
||||
# this ensures that when clang passes -lgcc_s to lld (as it does
|
||||
# when building e.g. firefox), lld is able to find libgcc_s.so
|
||||
+ concatMapStrings (libgcc: ''
|
||||
+ optionals (!isArocc) (concatMapStrings (libgcc: ''
|
||||
echo "-L${libgcc}/lib" >> $out/nix-support/cc-ldflags
|
||||
'') (toList (gccForLibs.libgcc or [])))
|
||||
'') (toList (gccForLibs.libgcc or []))))
|
||||
|
||||
##
|
||||
## General libc support
|
||||
@ -540,9 +548,10 @@ stdenvNoCC.mkDerivation {
|
||||
+ optionalString (libc != null) (''
|
||||
touch "$out/nix-support/libc-cflags"
|
||||
touch "$out/nix-support/libc-ldflags"
|
||||
'' + optionalString (!isArocc) ''
|
||||
echo "-B${libc_lib}${libc.libdir or "/lib/"}" >> $out/nix-support/libc-crt1-cflags
|
||||
'' + optionalString (!(cc.langD or false)) ''
|
||||
echo "-idirafter ${libc_dev}${libc.incdir or "/include"}" >> $out/nix-support/libc-cflags
|
||||
echo "-${if isArocc then "I" else "idirafter"} ${libc_dev}${libc.incdir or "/include"}" >> $out/nix-support/libc-cflags
|
||||
'' + optionalString (isGNU && (!(cc.langD or false))) ''
|
||||
for dir in "${cc}"/lib/gcc/*/*/include-fixed; do
|
||||
echo '-idirafter' ''${dir} >> $out/nix-support/libc-cflags
|
||||
@ -598,7 +607,7 @@ stdenvNoCC.mkDerivation {
|
||||
# ${cc_solib}/lib64 (even though it does actually search there...)..
|
||||
# This confuses libtool. So add it to the compiler tool search
|
||||
# path explicitly.
|
||||
+ optionalString (!nativeTools) ''
|
||||
+ optionalString (!nativeTools && !isArocc) ''
|
||||
if [ -e "${cc_solib}/lib64" -a ! -L "${cc_solib}/lib64" ]; then
|
||||
ccLDFlags+=" -L${cc_solib}/lib64"
|
||||
ccCFlags+=" -B${cc_solib}/lib64"
|
||||
@ -606,7 +615,7 @@ stdenvNoCC.mkDerivation {
|
||||
ccLDFlags+=" -L${cc_solib}/lib"
|
||||
ccCFlags+=" -B${cc_solib}/lib"
|
||||
|
||||
'' + optionalString cc.langAda or false ''
|
||||
'' + optionalString (cc.langAda or false && !isArocc) ''
|
||||
touch "$out/nix-support/gnat-cflags"
|
||||
touch "$out/nix-support/gnat-ldflags"
|
||||
basePath=$(echo $cc/lib/*/*/*)
|
||||
@ -627,7 +636,7 @@ stdenvNoCC.mkDerivation {
|
||||
+ optionalString propagateDoc ''
|
||||
ln -s ${cc.man} $man
|
||||
ln -s ${cc.info} $info
|
||||
'' + optionalString (cc.langD or cc.langJava or false) ''
|
||||
'' + optionalString (cc.langD or cc.langJava or false && !isArocc) ''
|
||||
echo "-B${zlib}${zlib.libdir or "/lib/"}" >> $out/nix-support/libc-cflags
|
||||
''
|
||||
|
||||
@ -668,7 +677,7 @@ stdenvNoCC.mkDerivation {
|
||||
hardening_unsupported_flags+=" stackprotector"
|
||||
''
|
||||
|
||||
+ optionalString (libc != null && targetPlatform.isAvr) ''
|
||||
+ optionalString (libc != null && targetPlatform.isAvr && !isArocc) ''
|
||||
for isa in avr5 avr3 avr4 avr6 avr25 avr31 avr35 avr51 avrxmega2 avrxmega4 avrxmega5 avrxmega6 avrxmega7 tiny-stack; do
|
||||
echo "-B${getLib libc}/avr/lib/$isa" >> $out/nix-support/libc-crt1-cflags
|
||||
done
|
||||
|
44
pkgs/development/compilers/arocc/default.nix
Normal file
44
pkgs/development/compilers/arocc/default.nix
Normal file
@ -0,0 +1,44 @@
|
||||
{
|
||||
lib,
|
||||
fetchFromGitHub,
|
||||
callPackage,
|
||||
zig_0_13,
|
||||
}:
|
||||
let
|
||||
versions = [
|
||||
{
|
||||
zig = zig_0_13;
|
||||
version = "0-unstable-06-01";
|
||||
src = fetchFromGitHub {
|
||||
owner = "Vexu";
|
||||
repo = "arocc";
|
||||
rev = "55cb6d1b682b83f75ad4f60e34c6fcd2336e8531";
|
||||
hash = "sha256-xs3zNQIC5drrQYT4nxL7Q69xSEdbdMv5+3hQpsX3q5A=";
|
||||
};
|
||||
}
|
||||
];
|
||||
|
||||
mkPackage =
|
||||
{
|
||||
zig,
|
||||
version,
|
||||
src,
|
||||
}:
|
||||
callPackage ./package.nix { inherit zig version src; };
|
||||
|
||||
pkgsList = lib.map mkPackage versions;
|
||||
|
||||
pkgsAttrsUnwrapped = lib.listToAttrs (
|
||||
lib.map (pkg: lib.nameValuePair "${pkg.version}-unwrapped" pkg) pkgsList
|
||||
);
|
||||
pkgsAttrsWrapped = lib.listToAttrs (
|
||||
lib.map (pkg: lib.nameValuePair pkg.version pkg.wrapped) pkgsList
|
||||
);
|
||||
|
||||
pkgsAttrs = pkgsAttrsWrapped // pkgsAttrsUnwrapped;
|
||||
in
|
||||
{
|
||||
latest-unwrapped = lib.last pkgsList;
|
||||
latest = (lib.last pkgsList).wrapped;
|
||||
}
|
||||
// pkgsAttrs
|
33
pkgs/development/compilers/arocc/package.nix
Normal file
33
pkgs/development/compilers/arocc/package.nix
Normal file
@ -0,0 +1,33 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
wrapCCWith,
|
||||
overrideCC,
|
||||
zig,
|
||||
version,
|
||||
src,
|
||||
}:
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "arocc";
|
||||
inherit version src;
|
||||
|
||||
nativeBuildInputs = [ zig.hook ];
|
||||
|
||||
passthru = {
|
||||
inherit zig;
|
||||
isArocc = true;
|
||||
wrapped = wrapCCWith { cc = finalAttrs.finalPackage; };
|
||||
stdenv = overrideCC stdenv finalAttrs.passthru.wrapped;
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "C compiler written in Zig.";
|
||||
homepage = "http://aro.vexu.eu/";
|
||||
license = with lib.licenses; [
|
||||
mit
|
||||
unicode-30
|
||||
];
|
||||
maintainers = with lib.maintainers; [ RossComputerGuy ];
|
||||
mainProgram = "arocc";
|
||||
};
|
||||
})
|
@ -77,6 +77,8 @@ in lib.init bootStages ++ [
|
||||
then buildPackages.llvmPackages.clang
|
||||
else if crossSystem.useZig or false
|
||||
then buildPackages.zig.cc
|
||||
else if crossSystem.useArocc or false
|
||||
then buildPackages.arocc
|
||||
else buildPackages.gcc;
|
||||
|
||||
extraNativeBuildInputs = old.extraNativeBuildInputs
|
||||
|
@ -16662,6 +16662,7 @@ with pkgs;
|
||||
|
||||
isGNU = cc.isGNU or false;
|
||||
isClang = cc.isClang or false;
|
||||
isArocc = cc.isArocc or false;
|
||||
isZig = cc.isZig or false;
|
||||
|
||||
inherit cc bintools libc libcxx extraPackages nixSupport zlib;
|
||||
@ -24698,6 +24699,11 @@ with pkgs;
|
||||
|
||||
zigStdenv = if stdenv.cc.isZig then stdenv else lowPrio zig.passthru.stdenv;
|
||||
|
||||
aroccPackages = recurseIntoAttrs (callPackage ../development/compilers/arocc {});
|
||||
arocc = aroccPackages.latest;
|
||||
|
||||
aroccStdenv = if stdenv.cc.isArocc then stdenv else lowPrio arocc.cc.passthru.stdenv;
|
||||
|
||||
zimlib = callPackage ../development/libraries/zimlib { };
|
||||
|
||||
zita-convolver = callPackage ../development/libraries/audio/zita-convolver { };
|
||||
|
@ -291,6 +291,7 @@ let
|
||||
agdaPackages = packagePlatforms pkgs.agdaPackages;
|
||||
|
||||
pkgsLLVM.stdenv = [ "x86_64-linux" "aarch64-linux" ];
|
||||
pkgsArocc.stdenv = [ "x86_64-linux" "aarch64-linux" ];
|
||||
pkgsZig.stdenv = [ "x86_64-linux" "aarch64-linux" ];
|
||||
pkgsMusl.stdenv = [ "x86_64-linux" "aarch64-linux" ];
|
||||
pkgsStatic.stdenv = [ "x86_64-linux" "aarch64-linux" ];
|
||||
|
@ -203,6 +203,21 @@ let
|
||||
};
|
||||
};
|
||||
|
||||
pkgsArocc = nixpkgsFun {
|
||||
overlays = [
|
||||
(self': super': {
|
||||
pkgsArocc = super';
|
||||
})
|
||||
] ++ overlays;
|
||||
# Bootstrap a cross stdenv using the Aro C compiler.
|
||||
# This is currently not possible when compiling natively,
|
||||
# so we don't need to check hostPlatform != buildPlatform.
|
||||
crossSystem = stdenv.hostPlatform // {
|
||||
useArocc = true;
|
||||
linker = "lld";
|
||||
};
|
||||
};
|
||||
|
||||
pkgsZig = nixpkgsFun {
|
||||
overlays = [
|
||||
(self': super': {
|
||||
|
Loading…
Reference in New Issue
Block a user