nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at netboot-syslinux-multiplatform 249 lines 9.8 kB view raw
1{ lib, stdenv 2, targetPackages 3 4, crossStageStatic, libcCross 5, threadsCross 6, version 7 8, binutils, gmp, mpfr, libmpc, isl 9, cloog ? null 10 11, enableLTO 12, enableMultilib 13, enablePlugin 14, disableGdbPlugin ? !enablePlugin 15, enableShared 16 17, langC 18, langCC 19, langD ? false 20, langFortran 21, langJava ? false, javaAwtGtk ? false, javaAntlr ? null, javaEcj ? null 22, langAda ? false 23, langGo 24, langObjC 25, langObjCpp 26, langJit 27, disableBootstrap ? stdenv.targetPlatform != stdenv.hostPlatform 28}: 29 30assert !enablePlugin -> disableGdbPlugin; 31assert langJava -> lib.versionOlder version "7"; 32 33# Note [Windows Exception Handling] 34# sjlj (short jump long jump) exception handling makes no sense on x86_64, 35# it's forcably slowing programs down as it produces a constant overhead. 36# On x86_64 we have SEH (Structured Exception Handling) and we should use 37# that. On i686, we do not have SEH, and have to use sjlj with dwarf2. 38# Hence it's now conditional on x86_32 (i686 is 32bit). 39# 40# ref: https://stackoverflow.com/questions/15670169/what-is-difference-between-sjlj-vs-dwarf-vs-seh 41 42 43let 44 inherit (stdenv) 45 buildPlatform hostPlatform targetPlatform; 46 47 # See https://github.com/NixOS/nixpkgs/pull/209870#issuecomment-1500550903 48 disableBootstrap' = disableBootstrap && !langFortran && !langGo; 49 50 crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; 51 crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; 52 53 targetPrefix = lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) 54 "${stdenv.targetPlatform.config}-"; 55 56 crossConfigureFlags = 57 # Ensure that -print-prog-name is able to find the correct programs. 58 [ 59 "--with-as=${if targetPackages.stdenv.cc.bintools.isLLVM then binutils else targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" 60 "--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" 61 ] 62 ++ (if crossStageStatic then [ 63 "--disable-libssp" 64 "--disable-nls" 65 "--without-headers" 66 "--disable-threads" 67 "--disable-libgomp" 68 "--disable-libquadmath" 69 "--disable-shared" 70 "--disable-libatomic" # requires libc 71 "--disable-decimal-float" # requires libc 72 "--disable-libmpx" # requires libc 73 ] ++ lib.optionals crossMingw [ 74 "--with-headers=${lib.getDev libcCross}/include" 75 "--with-gcc" 76 "--with-gnu-as" 77 "--with-gnu-ld" 78 "--disable-debug" 79 "--disable-win32-registry" 80 "--enable-hash-synchronization" 81 "--enable-libssp" 82 "--disable-nls" 83 # To keep ABI compatibility with upstream mingw-w64 84 "--enable-fully-dynamic-string" 85 ] ++ lib.optionals (crossMingw && targetPlatform.isx86_32) [ 86 # See Note [Windows Exception Handling] 87 "--enable-sjlj-exceptions" 88 "--with-dwarf2" 89 ] else [ 90 (if crossDarwin then "--with-sysroot=${lib.getLib libcCross}/share/sysroot" 91 else "--with-headers=${lib.getDev libcCross}${libcCross.incdir or "/include"}") 92 "--enable-__cxa_atexit" 93 "--enable-long-long" 94 "--enable-threads=${if targetPlatform.isUnix then "posix" 95 else if targetPlatform.isWindows then (threadsCross.model or "win32") 96 else "single"}" 97 "--enable-nls" 98 ] ++ lib.optionals (targetPlatform.libc == "uclibc" || targetPlatform.libc == "musl") [ 99 # libsanitizer requires netrom/netrom.h which is not 100 # available in uclibc. 101 "--disable-libsanitizer" 102 ] ++ lib.optional (targetPlatform.libc == "newlib" || targetPlatform.libc == "newlib-nano") "--with-newlib" 103 ++ lib.optional (targetPlatform.libc == "avrlibc") "--with-avrlibc" 104 ); 105 106 configureFlags = 107 # Basic dependencies 108 [ 109 "--with-gmp-include=${gmp.dev}/include" 110 "--with-gmp-lib=${gmp.out}/lib" 111 "--with-mpfr-include=${mpfr.dev}/include" 112 "--with-mpfr-lib=${mpfr.out}/lib" 113 "--with-mpc=${libmpc}" 114 ] 115 ++ lib.optionals (!crossStageStatic) [ 116 (if libcCross == null 117 then "--with-native-system-header-dir=${lib.getDev stdenv.cc.libc}/include" 118 else "--with-native-system-header-dir=${lib.getDev libcCross}${libcCross.incdir or "/include"}") 119 # gcc builds for cross-compilers (build != host) or cross-built 120 # gcc (host != target) always apply the offset prefix to disentangle 121 # target headers from build or host headers: 122 # ${with_build_sysroot}${native_system_header_dir} 123 # or ${test_exec_prefix}/${target_noncanonical}/sys-include 124 # or ${with_sysroot}${native_system_header_dir} 125 # While native build (build == host == target) uses passed headers 126 # path as is: 127 # ${with_build_sysroot}${native_system_header_dir} 128 # 129 # Nixpkgs uses flat directory structure for both native and cross 130 # cases. As a result libc headers don't get found for cross case 131 # and many modern features get disabled (libssp is used instead of 132 # target-specific implementations and similar). More details at: 133 # https://github.com/NixOS/nixpkgs/pull/181802#issuecomment-1186822355 134 # 135 # We pick "/" path to effectively avoid sysroot offset and make it work 136 # as a native case. 137 "--with-build-sysroot=/" 138 ] 139 140 # Basic configuration 141 ++ [ 142 # Force target prefix. The behavior if `--target` and `--host` 143 # are specified is inconsistent: Sometimes specifying `--target` 144 # always causes a prefix to be generated, sometimes it's only 145 # added if the `--host` and `--target` differ. This means that 146 # sometimes there may be a prefix even though nixpkgs doesn't 147 # expect one and sometimes there may be none even though nixpkgs 148 # expects one (since not all information is serialized into the 149 # config attribute). The easiest way out of these problems is to 150 # always set the program prefix, so gcc will conform to our 151 # expectations. 152 "--program-prefix=${targetPrefix}" 153 154 (lib.enableFeature enableLTO "lto") 155 "--disable-libstdcxx-pch" 156 "--without-included-gettext" 157 "--with-system-zlib" 158 "--enable-static" 159 "--enable-languages=${ 160 lib.concatStringsSep "," 161 ( lib.optional langC "c" 162 ++ lib.optional langCC "c++" 163 ++ lib.optional langD "d" 164 ++ lib.optional langFortran "fortran" 165 ++ lib.optional langJava "java" 166 ++ lib.optional langAda "ada" 167 ++ lib.optional langGo "go" 168 ++ lib.optional langObjC "objc" 169 ++ lib.optional langObjCpp "obj-c++" 170 ++ lib.optionals crossDarwin [ "objc" "obj-c++" ] 171 ++ lib.optional langJit "jit" 172 ) 173 }" 174 ] 175 176 ++ (if (enableMultilib || targetPlatform.isAvr) 177 then ["--enable-multilib" "--disable-libquadmath"] 178 else ["--disable-multilib"]) 179 ++ lib.optional (!enableShared) "--disable-shared" 180 ++ lib.singleton (lib.enableFeature enablePlugin "plugin") 181 # Libcc1 is the GCC cc1 plugin for the GDB debugger which is only used by gdb 182 ++ lib.optional disableGdbPlugin "--disable-libcc1" 183 184 # Support -m32 on powerpc64le/be 185 ++ lib.optional (targetPlatform.system == "powerpc64le-linux") 186 "--enable-targets=powerpcle-linux" 187 ++ lib.optional (targetPlatform.system == "powerpc64-linux") 188 "--enable-targets=powerpc-linux" 189 190 # Fix "unknown long double size, cannot define BFP_FMT" 191 ++ lib.optional (targetPlatform.isPower && targetPlatform.isMusl) 192 "--disable-decimal-float" 193 194 # Optional features 195 ++ lib.optional (isl != null) "--with-isl=${isl}" 196 ++ lib.optionals (lib.versionOlder version "5" && cloog != null) [ 197 "--with-cloog=${cloog}" 198 "--disable-cloog-version-check" 199 "--enable-cloog-backend=isl" 200 ] 201 202 # Ada options, gcc can't build the runtime library for a cross compiler 203 ++ lib.optional langAda 204 (if hostPlatform == targetPlatform 205 then "--enable-libada" 206 else "--disable-libada") 207 208 # Java options 209 ++ lib.optionals langJava [ 210 "--with-ecj-jar=${javaEcj}" 211 212 # Follow Sun's layout for the convenience of IcedTea/OpenJDK. See 213 # <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>. 214 "--enable-java-home" 215 "--with-java-home=\${prefix}/lib/jvm/jre" 216 ] 217 ++ lib.optional javaAwtGtk "--enable-java-awt=gtk" 218 ++ lib.optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" 219 220 ++ import ../common/platform-flags.nix { inherit (stdenv) targetPlatform; inherit lib; } 221 ++ lib.optionals (targetPlatform != hostPlatform) crossConfigureFlags 222 ++ lib.optional disableBootstrap' "--disable-bootstrap" 223 224 # Platform-specific flags 225 ++ lib.optional (targetPlatform == hostPlatform && targetPlatform.isx86_32) "--with-arch=${stdenv.hostPlatform.parsed.cpu.name}" 226 ++ lib.optional targetPlatform.isNetBSD "--disable-libssp" # Provided by libc. 227 ++ lib.optionals hostPlatform.isSunOS [ 228 "--enable-long-long" "--enable-libssp" "--enable-threads=posix" "--disable-nls" "--enable-__cxa_atexit" 229 # On Illumos/Solaris GNU as is preferred 230 "--with-gnu-as" "--without-gnu-ld" 231 ] 232 ++ lib.optional (targetPlatform.libc == "musl") 233 # musl at least, disable: https://git.buildroot.net/buildroot/commit/?id=873d4019f7fb00f6a80592224236b3ba7d657865 234 "--disable-libmpx" 235 ++ lib.optionals (targetPlatform == hostPlatform && targetPlatform.libc == "musl") [ 236 "--disable-libsanitizer" 237 "--disable-symvers" 238 "libat_cv_have_ifunc=no" 239 "--disable-gnu-indirect-function" 240 ] 241 ++ lib.optionals langJit [ 242 "--enable-host-shared" 243 ] 244 ++ lib.optionals (langD) [ 245 "--with-target-system-zlib=yes" 246 ] 247 ; 248 249in configureFlags