uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead
https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948 this can do it nicely. Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
commit
56de2bcd43
30691 changed files with 3076956 additions and 0 deletions
230
pkgs/development/compilers/gcc/common/configure-flags.nix
Normal file
230
pkgs/development/compilers/gcc/common/configure-flags.nix
Normal file
|
|
@ -0,0 +1,230 @@
|
|||
{ lib, stdenv
|
||||
, targetPackages
|
||||
|
||||
, crossStageStatic, libcCross
|
||||
, version
|
||||
|
||||
, gmp, mpfr, libmpc, libelf, isl
|
||||
, cloog ? null
|
||||
|
||||
, enableLTO
|
||||
, enableMultilib
|
||||
, enablePlugin
|
||||
, enableShared
|
||||
|
||||
, langC
|
||||
, langCC
|
||||
, langD ? false
|
||||
, langFortran
|
||||
, langJava ? false, javaAwtGtk ? false, javaAntlr ? null, javaEcj ? null
|
||||
, langAda ? false
|
||||
, langGo
|
||||
, langObjC
|
||||
, langObjCpp
|
||||
, langJit
|
||||
}:
|
||||
|
||||
assert cloog != null -> lib.versionOlder version "5";
|
||||
assert langJava -> lib.versionOlder version "7";
|
||||
|
||||
# Note [Windows Exception Handling]
|
||||
# sjlj (short jump long jump) exception handling makes no sense on x86_64,
|
||||
# it's forcably slowing programs down as it produces a constant overhead.
|
||||
# On x86_64 we have SEH (Structured Exception Handling) and we should use
|
||||
# that. On i686, we do not have SEH, and have to use sjlj with dwarf2.
|
||||
# Hence it's now conditional on x86_32 (i686 is 32bit).
|
||||
#
|
||||
# ref: https://stackoverflow.com/questions/15670169/what-is-difference-between-sjlj-vs-dwarf-vs-seh
|
||||
|
||||
|
||||
let
|
||||
inherit (stdenv)
|
||||
buildPlatform hostPlatform targetPlatform;
|
||||
|
||||
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
|
||||
crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem";
|
||||
|
||||
targetPrefix = lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
|
||||
"${stdenv.targetPlatform.config}-";
|
||||
|
||||
crossConfigureFlags =
|
||||
# Ensure that -print-prog-name is able to find the correct programs.
|
||||
[
|
||||
"--with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as"
|
||||
"--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld"
|
||||
]
|
||||
++ (if crossStageStatic then [
|
||||
"--disable-libssp"
|
||||
"--disable-nls"
|
||||
"--without-headers"
|
||||
"--disable-threads"
|
||||
"--disable-libgomp"
|
||||
"--disable-libquadmath"
|
||||
"--disable-shared"
|
||||
"--disable-libatomic" # requires libc
|
||||
"--disable-decimal-float" # requires libc
|
||||
"--disable-libmpx" # requires libc
|
||||
] ++ lib.optionals crossMingw [
|
||||
"--with-headers=${lib.getDev libcCross}/include"
|
||||
"--with-gcc"
|
||||
"--with-gnu-as"
|
||||
"--with-gnu-ld"
|
||||
"--disable-debug"
|
||||
"--disable-win32-registry"
|
||||
"--enable-hash-synchronization"
|
||||
"--enable-libssp"
|
||||
"--disable-nls"
|
||||
# To keep ABI compatibility with upstream mingw-w64
|
||||
"--enable-fully-dynamic-string"
|
||||
] ++ lib.optionals (crossMingw && targetPlatform.isx86_32) [
|
||||
# See Note [Windows Exception Handling]
|
||||
"--enable-sjlj-exceptions"
|
||||
"--with-dwarf2"
|
||||
] else [
|
||||
(if crossDarwin then "--with-sysroot=${lib.getLib libcCross}/share/sysroot"
|
||||
else "--with-headers=${lib.getDev libcCross}${libcCross.incdir or "/include"}")
|
||||
"--enable-__cxa_atexit"
|
||||
"--enable-long-long"
|
||||
"--enable-threads=${if targetPlatform.isUnix then "posix"
|
||||
else if targetPlatform.isWindows then "mcf"
|
||||
else "single"}"
|
||||
"--enable-nls"
|
||||
] ++ lib.optionals (targetPlatform.libc == "uclibc" || targetPlatform.libc == "musl") [
|
||||
# libsanitizer requires netrom/netrom.h which is not
|
||||
# available in uclibc.
|
||||
"--disable-libsanitizer"
|
||||
] ++ lib.optionals (targetPlatform.libc == "uclibc") [
|
||||
# In uclibc cases, libgomp needs an additional '-ldl'
|
||||
# and as I don't know how to pass it, I disable libgomp.
|
||||
"--disable-libgomp"
|
||||
] ++ lib.optional (targetPlatform.libc == "newlib") "--with-newlib"
|
||||
++ lib.optional (targetPlatform.libc == "avrlibc") "--with-avrlibc"
|
||||
);
|
||||
|
||||
configureFlags =
|
||||
# Basic dependencies
|
||||
[
|
||||
"--with-gmp-include=${gmp.dev}/include"
|
||||
"--with-gmp-lib=${gmp.out}/lib"
|
||||
"--with-mpfr-include=${mpfr.dev}/include"
|
||||
"--with-mpfr-lib=${mpfr.out}/lib"
|
||||
"--with-mpc=${libmpc}"
|
||||
]
|
||||
++ lib.optional (libelf != null) "--with-libelf=${libelf}"
|
||||
++ lib.optional (!(crossMingw && crossStageStatic))
|
||||
"--with-native-system-header-dir=${lib.getDev stdenv.cc.libc}/include"
|
||||
|
||||
# Basic configuration
|
||||
++ [
|
||||
# Force target prefix. The behavior if `--target` and `--host`
|
||||
# are specified is inconsistent: Sometimes specifying `--target`
|
||||
# always causes a prefix to be generated, sometimes it's only
|
||||
# added if the `--host` and `--target` differ. This means that
|
||||
# sometimes there may be a prefix even though nixpkgs doesn't
|
||||
# expect one and sometimes there may be none even though nixpkgs
|
||||
# expects one (since not all information is serialized into the
|
||||
# config attribute). The easiest way out of these problems is to
|
||||
# always set the program prefix, so gcc will conform to our
|
||||
# expectations.
|
||||
"--program-prefix=${targetPrefix}"
|
||||
|
||||
(lib.enableFeature enableLTO "lto")
|
||||
"--disable-libstdcxx-pch"
|
||||
"--without-included-gettext"
|
||||
"--with-system-zlib"
|
||||
"--enable-static"
|
||||
"--enable-languages=${
|
||||
lib.concatStringsSep ","
|
||||
( lib.optional langC "c"
|
||||
++ lib.optional langCC "c++"
|
||||
++ lib.optional langD "d"
|
||||
++ lib.optional langFortran "fortran"
|
||||
++ lib.optional langJava "java"
|
||||
++ lib.optional langAda "ada"
|
||||
++ lib.optional langGo "go"
|
||||
++ lib.optional langObjC "objc"
|
||||
++ lib.optional langObjCpp "obj-c++"
|
||||
++ lib.optionals crossDarwin [ "objc" "obj-c++" ]
|
||||
++ lib.optional langJit "jit"
|
||||
)
|
||||
}"
|
||||
]
|
||||
|
||||
++ (if (enableMultilib || targetPlatform.isAvr)
|
||||
then ["--enable-multilib" "--disable-libquadmath"]
|
||||
else ["--disable-multilib"])
|
||||
++ lib.optional (!enableShared) "--disable-shared"
|
||||
++ [
|
||||
(lib.enableFeature enablePlugin "plugin")
|
||||
]
|
||||
|
||||
# Support -m32 on powerpc64le/be
|
||||
++ lib.optional (targetPlatform.system == "powerpc64le-linux")
|
||||
"--enable-targets=powerpcle-linux"
|
||||
++ lib.optional (targetPlatform.system == "powerpc64-linux")
|
||||
"--enable-targets=powerpc-linux"
|
||||
|
||||
# Fix "unknown long double size, cannot define BFP_FMT"
|
||||
++ lib.optional (targetPlatform.isPower && targetPlatform.isMusl)
|
||||
"--disable-decimal-float"
|
||||
|
||||
# Optional features
|
||||
++ lib.optional (isl != null) "--with-isl=${isl}"
|
||||
++ lib.optionals (cloog != null) [
|
||||
"--with-cloog=${cloog}"
|
||||
"--disable-cloog-version-check"
|
||||
"--enable-cloog-backend=isl"
|
||||
]
|
||||
|
||||
# Ada options, gcc can't build the runtime library for a cross compiler
|
||||
++ lib.optional langAda
|
||||
(if hostPlatform == targetPlatform
|
||||
then "--enable-libada"
|
||||
else "--disable-libada")
|
||||
|
||||
# Java options
|
||||
++ lib.optionals langJava [
|
||||
"--with-ecj-jar=${javaEcj}"
|
||||
|
||||
# Follow Sun's layout for the convenience of IcedTea/OpenJDK. See
|
||||
# <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>.
|
||||
"--enable-java-home"
|
||||
"--with-java-home=\${prefix}/lib/jvm/jre"
|
||||
]
|
||||
++ lib.optional javaAwtGtk "--enable-java-awt=gtk"
|
||||
++ lib.optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}"
|
||||
|
||||
# TODO: aarch64-darwin has clang stdenv and its arch and cpu flag values are incompatible with gcc
|
||||
++ lib.optional (!(stdenv.isDarwin && stdenv.isAarch64)) (import ../common/platform-flags.nix { inherit (stdenv) targetPlatform; inherit lib; })
|
||||
++ lib.optionals (targetPlatform != hostPlatform) crossConfigureFlags
|
||||
++ lib.optional (targetPlatform != hostPlatform) "--disable-bootstrap"
|
||||
|
||||
# Platform-specific flags
|
||||
++ lib.optional (targetPlatform == hostPlatform && targetPlatform.isx86_32) "--with-arch=${stdenv.hostPlatform.parsed.cpu.name}"
|
||||
++ lib.optional targetPlatform.isNetBSD "--disable-libssp" # Provided by libc.
|
||||
++ lib.optionals hostPlatform.isSunOS [
|
||||
"--enable-long-long" "--enable-libssp" "--enable-threads=posix" "--disable-nls" "--enable-__cxa_atexit"
|
||||
# On Illumos/Solaris GNU as is preferred
|
||||
"--with-gnu-as" "--without-gnu-ld"
|
||||
]
|
||||
++ lib.optional (targetPlatform.libc == "musl")
|
||||
# musl at least, disable: https://git.buildroot.net/buildroot/commit/?id=873d4019f7fb00f6a80592224236b3ba7d657865
|
||||
"--disable-libmpx"
|
||||
++ lib.optionals (targetPlatform == hostPlatform && targetPlatform.libc == "musl") [
|
||||
"--disable-libsanitizer"
|
||||
"--disable-symvers"
|
||||
"libat_cv_have_ifunc=no"
|
||||
"--disable-gnu-indirect-function"
|
||||
]
|
||||
++ lib.optionals langJit [
|
||||
"--enable-host-shared"
|
||||
]
|
||||
++ lib.optionals (langD) [
|
||||
"--with-target-system-zlib=yes"
|
||||
]
|
||||
# Make -fcommon default on gcc10
|
||||
# TODO: fix all packages (probably 100+) and remove that
|
||||
++ lib.optional (version >= "10.1.0") "--with-specs=%{!fno-common:%{!fcommon:-fcommon}}"
|
||||
;
|
||||
|
||||
in configureFlags
|
||||
33
pkgs/development/compilers/gcc/common/extra-target-flags.nix
Normal file
33
pkgs/development/compilers/gcc/common/extra-target-flags.nix
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
{ lib, stdenv, crossStageStatic, langD ? false, libcCross, threadsCross }:
|
||||
|
||||
let
|
||||
inherit (stdenv) hostPlatform targetPlatform;
|
||||
in
|
||||
|
||||
{
|
||||
# For non-cross builds these flags are currently assigned in builder.sh.
|
||||
# It would be good to consolidate the generation of makeFlags
|
||||
# ({C,CXX,LD}FLAGS_FOR_{BUILD,TARGET}, etc...) at some point.
|
||||
EXTRA_FLAGS_FOR_TARGET = let
|
||||
mkFlags = dep: langD: lib.optionals (targetPlatform != hostPlatform && dep != null && !langD) ([
|
||||
"-O2 -idirafter ${lib.getDev dep}${dep.incdir or "/include"}"
|
||||
] ++ lib.optionals (! crossStageStatic) [
|
||||
"-B${lib.getLib dep}${dep.libdir or "/lib"}"
|
||||
]);
|
||||
in mkFlags libcCross langD
|
||||
++ lib.optionals (!crossStageStatic) (mkFlags threadsCross langD)
|
||||
;
|
||||
|
||||
EXTRA_LDFLAGS_FOR_TARGET = let
|
||||
mkFlags = dep: lib.optionals (targetPlatform != hostPlatform && dep != null) ([
|
||||
"-Wl,-L${lib.getLib dep}${dep.libdir or "/lib"}"
|
||||
] ++ (if crossStageStatic then [
|
||||
"-B${lib.getLib dep}${dep.libdir or "/lib"}"
|
||||
] else [
|
||||
"-Wl,-rpath,${lib.getLib dep}${dep.libdir or "/lib"}"
|
||||
"-Wl,-rpath-link,${lib.getLib dep}${dep.libdir or "/lib"}"
|
||||
]));
|
||||
in mkFlags libcCross
|
||||
++ lib.optionals (!crossStageStatic) (mkFlags threadsCross)
|
||||
;
|
||||
}
|
||||
16
pkgs/development/compilers/gcc/common/platform-flags.nix
Normal file
16
pkgs/development/compilers/gcc/common/platform-flags.nix
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{ lib, targetPlatform }:
|
||||
|
||||
let
|
||||
p = targetPlatform.gcc or {}
|
||||
// targetPlatform.parsed.abi;
|
||||
in lib.concatLists [
|
||||
(lib.optional (!targetPlatform.isx86_64 && p ? arch) "--with-arch=${p.arch}") # --with-arch= is unknown flag on x86_64
|
||||
(lib.optional (p ? cpu) "--with-cpu=${p.cpu}")
|
||||
(lib.optional (p ? abi) "--with-abi=${p.abi}")
|
||||
(lib.optional (p ? fpu) "--with-fpu=${p.fpu}")
|
||||
(lib.optional (p ? float) "--with-float=${p.float}")
|
||||
(lib.optional (p ? mode) "--with-mode=${p.mode}")
|
||||
(lib.optional
|
||||
(let tp = targetPlatform; in tp.isPower && tp.libc == "glibc" && tp.is64bit)
|
||||
"--with-long-double-128")
|
||||
]
|
||||
67
pkgs/development/compilers/gcc/common/pre-configure.nix
Normal file
67
pkgs/development/compilers/gcc/common/pre-configure.nix
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
{ lib, version, hostPlatform, targetPlatform
|
||||
, gnatboot ? null
|
||||
, langAda ? false
|
||||
, langJava ? false
|
||||
, langJit ? false
|
||||
, langGo }:
|
||||
|
||||
assert langJava -> lib.versionOlder version "7";
|
||||
assert langAda -> gnatboot != null;
|
||||
|
||||
lib.optionalString (hostPlatform.isSunOS && hostPlatform.is64bit) ''
|
||||
export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g`
|
||||
export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET"
|
||||
export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET"
|
||||
export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET"
|
||||
'' + lib.optionalString (lib.versionOlder version "7" && (langJava || langGo)) ''
|
||||
export lib=$out;
|
||||
'' + lib.optionalString langAda ''
|
||||
export PATH=${gnatboot}/bin:$PATH
|
||||
''
|
||||
|
||||
# NOTE 2020/3/18: This environment variable prevents configure scripts from
|
||||
# detecting the presence of aligned_alloc on Darwin. There are many facts that
|
||||
# collectively make this fix necessary:
|
||||
# - Nix uses a fixed set of standard library headers on all MacOS systems,
|
||||
# regardless of their actual version. (Nix uses version 10.12 headers.)
|
||||
# - Nix uses the native standard library binaries for the build system. That
|
||||
# means the standard library binaries may not exactly match the standard
|
||||
# library headers.
|
||||
# - The aligned_alloc procedure is present in MacOS 10.15 (Catalina), but not
|
||||
# in earlier versions. Therefore on Catalina systems, aligned_alloc is
|
||||
# linkable (i.e. present in the binary libraries) but not present in the
|
||||
# headers.
|
||||
# - Configure scripts detect a procedure's existence by checking whether it is
|
||||
# linkable. They do not check whether it is present in the headers.
|
||||
# - GCC throws an error during compilation because aligned_alloc is not
|
||||
# defined in the headers---even though the linker can see it.
|
||||
#
|
||||
# This fix would not be necessary if ANY of the above were false:
|
||||
# - If Nix used native headers for each different MacOS version, aligned_alloc
|
||||
# would be in the headers on Catalina.
|
||||
# - If Nix used the same libary binaries for each MacOS version, aligned_alloc
|
||||
# would not be in the library binaries.
|
||||
# - If Catalina did not include aligned_alloc, this wouldn't be a problem.
|
||||
# - If the configure scripts looked for header presence as well as
|
||||
# linkability, they would see that aligned_alloc is missing.
|
||||
# - If GCC allowed implicit declaration of symbols, it would not fail during
|
||||
# compilation even if the configure scripts did not check header presence.
|
||||
#
|
||||
+ lib.optionalString (hostPlatform.isDarwin) ''
|
||||
export ac_cv_func_aligned_alloc=no
|
||||
''
|
||||
|
||||
# In order to properly install libgccjit on macOS Catalina, strip(1)
|
||||
# upon installation must not remove external symbols, otherwise the
|
||||
# install step errors with "symbols referenced by indirect symbol
|
||||
# table entries that can't be stripped".
|
||||
+ lib.optionalString (hostPlatform.isDarwin && langJit) ''
|
||||
export STRIP='strip -x'
|
||||
''
|
||||
|
||||
# HACK: if host and target config are the same, but the platforms are
|
||||
# actually different we need to convince the configure script that it
|
||||
# is in fact building a cross compiler although it doesn't believe it.
|
||||
+ lib.optionalString (targetPlatform.config == hostPlatform.config && targetPlatform != hostPlatform) ''
|
||||
substituteInPlace configure --replace is_cross_compiler=no is_cross_compiler=yes
|
||||
''
|
||||
Loading…
Add table
Add a link
Reference in a new issue