python312Packages.linear-operator: 0.5.3 -> 0.6
[NixPkgs.git] / pkgs / development / compilers / gcc / common / pre-configure.nix
bloba8594171d90988061fba6758c234f5930cd92a6f
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,
19 assert langAda -> gnat-bootstrap != null;
21 lib.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"
27 + lib.optionalString langAda ''
28   export PATH=${gnat-bootstrap}/bin:$PATH
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.
37   lib.optionalString
38     (langFortran && (with stdenv; buildPlatform != hostPlatform && hostPlatform == targetPlatform))
39     ''
40       export GFORTRAN_FOR_TARGET=${pkgsBuildTarget.gfortran}/bin/${stdenv.targetPlatform.config}-gfortran
41     ''
43 # In order to properly install libgccjit on macOS Catalina, strip(1)
44 # upon installation must not remove external symbols, otherwise the
45 # install step errors with "symbols referenced by indirect symbol
46 # table entries that can't be stripped".
47 + lib.optionalString (hostPlatform.isDarwin && langJit) ''
48   export STRIP='strip -x'
51 # HACK: if host and target config are the same, but the platforms are
52 # actually different we need to convince the configure script that it
53 # is in fact building a cross compiler although it doesn't believe it.
55   lib.optionalString (targetPlatform.config == hostPlatform.config && targetPlatform != hostPlatform)
56     ''
57       substituteInPlace configure --replace is_cross_compiler=no is_cross_compiler=yes
58     ''
60 # Normally (for host != target case) --without-headers automatically
61 # enables 'inhibit_libc=true' in gcc's gcc/configure.ac. But case of
62 # gcc->clang or dynamic->static "cross"-compilation manages to evade it: there
63 # hostPlatform != targetPlatform, hostPlatform.config == targetPlatform.config.
64 # We explicitly inhibit libc headers use in this case as well.
66   lib.optionalString
67     (
68       targetPlatform != hostPlatform && withoutTargetLibc && targetPlatform.config == hostPlatform.config
69     )
70     ''
71       export inhibit_libc=true
72     ''
74 + lib.optionalString (targetPlatform != hostPlatform && withoutTargetLibc && enableShared) (
75   import ./libgcc-buildstuff.nix { inherit lib stdenv; }