1 { lib, version, hostPlatform
8 assert langJava -> lib.versionOlder version "7";
9 assert langAda -> gnatboot != null;
11 lib.optionalString (hostPlatform.isSunOS && hostPlatform.is64bit) ''
12 export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g`
13 export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET"
14 export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET"
15 export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET"
16 '' + lib.optionalString (lib.versionOlder version "7" && (langJava || langGo)) ''
18 '' + lib.optionalString langAda ''
19 export PATH=${gnatboot}/bin:$PATH
22 # NOTE 2020/3/18: This environment variable prevents configure scripts from
23 # detecting the presence of aligned_alloc on Darwin. There are many facts that
24 # collectively make this fix necessary:
25 # - Nix uses a fixed set of standard library headers on all MacOS systems,
26 # regardless of their actual version. (Nix uses version 10.12 headers.)
27 # - Nix uses the native standard library binaries for the build system. That
28 # means the standard library binaries may not exactly match the standard
30 # - The aligned_alloc procedure is present in MacOS 10.15 (Catalina), but not
31 # in earlier versions. Therefore on Catalina systems, aligned_alloc is
32 # linkable (i.e. present in the binary libraries) but not present in the
34 # - Configure scripts detect a procedure's existence by checking whether it is
35 # linkable. They do not check whether it is present in the headers.
36 # - GCC throws an error during compilation because aligned_alloc is not
37 # defined in the headers---even though the linker can see it.
39 # This fix would not be necessary if ANY of the above were false:
40 # - If Nix used native headers for each different MacOS version, aligned_alloc
41 # would be in the headers on Catalina.
42 # - If Nix used the same libary binaries for each MacOS version, aligned_alloc
43 # would not be in the library binaries.
44 # - If Catalina did not include aligned_alloc, this wouldn't be a problem.
45 # - If the configure scripts looked for header presence as well as
46 # linkability, they would see that aligned_alloc is missing.
47 # - If GCC allowed implicit declaration of symbols, it would not fail during
48 # compilation even if the configure scripts did not check header presence.
50 + lib.optionalString (hostPlatform.isDarwin) ''
51 export ac_cv_func_aligned_alloc=no
54 # In order to properly install libgccjit on macOS Catalina, strip(1)
55 # upon installation must not remove external symbols, otherwise the
56 # install step errors with "symbols referenced by indirect symbol
57 # table entries that can't be stripped".
58 + lib.optionalString (hostPlatform.isDarwin && langJit) ''
59 export STRIP='strip -x'