at master 2.9 kB view raw
1{ 2 lib, 3 stdenv, 4 version, 5 buildPlatform, 6 hostPlatform, 7 targetPlatform, 8 gnat-bootstrap ? null, 9 langAda ? false, 10 langFortran, 11 langJit ? false, 12 langGo, 13 withoutTargetLibc, 14 enableShared, 15 enableMultilib, 16 pkgsBuildTarget, 17}: 18 19assert langAda -> gnat-bootstrap != null; 20 21lib.optionalString (hostPlatform.isSunOS && hostPlatform.is64bit) '' 22 export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g` 23 export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET" 24 export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET" 25 export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET" 26'' 27+ lib.optionalString langAda '' 28 export PATH=${gnat-bootstrap}/bin:$PATH 29'' 30 31# For a cross-built native compiler, i.e. build!=(host==target), the 32# bundled libgfortran needs a gfortran which can run on the 33# buildPlatform and emit code for the targetPlatform. The compiler 34# which is built alongside gfortran in this configuration doesn't 35# meet that need: it runs on the hostPlatform. 36+ 37 lib.optionalString 38 ( 39 langFortran 40 && ( 41 with stdenv; 42 (!lib.systems.equals buildPlatform hostPlatform) && (lib.systems.equals hostPlatform targetPlatform) 43 ) 44 ) 45 '' 46 export GFORTRAN_FOR_TARGET=${pkgsBuildTarget.gfortran}/bin/${stdenv.targetPlatform.config}-gfortran 47 '' 48 49# In order to properly install libgccjit on macOS Catalina, strip(1) 50# upon installation must not remove external symbols, otherwise the 51# install step errors with "symbols referenced by indirect symbol 52# table entries that can't be stripped". 53+ lib.optionalString (hostPlatform.isDarwin && langJit) '' 54 export STRIP='strip -x' 55'' 56 57# HACK: if host and target config are the same, but the platforms are 58# actually different we need to convince the configure script that it 59# is in fact building a cross compiler although it doesn't believe it. 60+ 61 lib.optionalString 62 (targetPlatform.config == hostPlatform.config && (!lib.systems.equals targetPlatform hostPlatform)) 63 '' 64 substituteInPlace configure --replace is_cross_compiler=no is_cross_compiler=yes 65 '' 66 67# Normally (for host != target case) --without-headers automatically 68# enables 'inhibit_libc=true' in gcc's gcc/configure.ac. But case of 69# gcc->clang or dynamic->static "cross"-compilation manages to evade it: there 70# ! lib.systems.equals hostPlatform targetPlatform, hostPlatform.config == targetPlatform.config. 71# We explicitly inhibit libc headers use in this case as well. 72+ 73 lib.optionalString 74 ( 75 (!lib.systems.equals targetPlatform hostPlatform) 76 && withoutTargetLibc 77 && targetPlatform.config == hostPlatform.config 78 ) 79 '' 80 export inhibit_libc=true 81 '' 82 83+ lib.optionalString ( 84 (!lib.systems.equals targetPlatform hostPlatform) && withoutTargetLibc && enableShared 85) (import ./libgcc-buildstuff.nix { inherit lib stdenv; })