lol
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 23.11-beta 441 lines 15 kB view raw
1{ lib, stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs 2, langC ? true, langCC ? true, langFortran ? false 3, langAda ? false 4, langObjC ? stdenv.targetPlatform.isDarwin 5, langObjCpp ? stdenv.targetPlatform.isDarwin 6, langD ? false 7, langGo ? false 8, reproducibleBuild ? true 9, profiledCompiler ? false 10, langJit ? false 11, staticCompiler ? false 12, enableShared ? stdenv.targetPlatform.hasSharedLibraries 13, enableLTO ? stdenv.hostPlatform.hasSharedLibraries 14, texinfo ? null 15, perl ? null # optional, for texi2pod (then pod2man) 16, gmp, mpfr, libmpc, gettext, which, patchelf, binutils 17, isl ? null # optional, for the Graphite optimization framework. 18, zlib ? null 19, libucontext ? null 20, gnat-bootstrap ? null 21, enableMultilib ? false 22, enablePlugin ? stdenv.hostPlatform == stdenv.buildPlatform # Whether to support user-supplied plug-ins 23, name ? "gcc" 24, libcCross ? null 25, threadsCross ? null # for MinGW 26, withoutTargetLibc ? false 27, gnused ? null 28, cloog # unused; just for compat with gcc4, as we override the parameter on some places 29, buildPackages 30, pkgsBuildTarget 31, libxcrypt 32, disableGdbPlugin ? !enablePlugin 33, nukeReferences 34, callPackage 35, majorMinorVersion 36, darwin 37 38# only for gcc<=6.x 39, langJava ? false 40, flex 41, boehmgc ? null 42, zip ? null, unzip ? null, pkg-config ? null 43, gtk2 ? null, libart_lgpl ? null 44, libX11 ? null, libXt ? null, libSM ? null, libICE ? null, libXtst ? null 45, libXrender ? null, xorgproto ? null 46, libXrandr ? null, libXi ? null 47, x11Support ? langJava 48}: 49 50let 51 versions = import ./versions.nix; 52 version = versions.fromMajorMinor majorMinorVersion; 53 54 majorVersion = lib.versions.major version; 55 atLeast13 = lib.versionAtLeast version "13"; 56 atLeast12 = lib.versionAtLeast version "12"; 57 atLeast11 = lib.versionAtLeast version "11"; 58 atLeast10 = lib.versionAtLeast version "10"; 59 atLeast9 = lib.versionAtLeast version "9"; 60 atLeast8 = lib.versionAtLeast version "8"; 61 atLeast7 = lib.versionAtLeast version "7"; 62 atLeast6 = lib.versionAtLeast version "6"; 63 atLeast49 = lib.versionAtLeast version "4.9"; 64 is13 = majorVersion == "13"; 65 is12 = majorVersion == "12"; 66 is11 = majorVersion == "11"; 67 is10 = majorVersion == "10"; 68 is9 = majorVersion == "9"; 69 is8 = majorVersion == "8"; 70 is7 = majorVersion == "7"; 71 is6 = majorVersion == "6"; 72 is49 = majorVersion == "4" && lib.versions.minor version == "9"; 73 is48 = majorVersion == "4" && lib.versions.minor version == "8"; 74in 75 76# We enable the isl cloog backend. 77assert !atLeast6 -> (cloog != null -> isl != null); 78 79assert langJava -> !atLeast7 && zip != null && unzip != null && zlib != null && boehmgc != null && perl != null; # for `--enable-java-home' 80 81# Make sure we get GNU sed. 82assert stdenv.buildPlatform.isDarwin -> gnused != null; 83 84# The go frontend is written in c++ 85assert langGo -> langCC; 86assert (atLeast6 && !is7 && !is8) -> (langAda -> gnat-bootstrap != null); 87 88# TODO: fixup D bootstapping, probably by using gdc11 (and maybe other changes). 89# error: GDC is required to build d 90assert atLeast12 -> !langD; 91 92# threadsCross is just for MinGW 93assert threadsCross != {} -> stdenv.targetPlatform.isWindows; 94 95# profiledCompiler builds inject non-determinism in one of the compilation stages. 96# If turned on, we can't provide reproducible builds anymore 97assert reproducibleBuild -> profiledCompiler == false; 98 99with lib; 100with builtins; 101 102let inherit version; 103 disableBootstrap = atLeast11 && !stdenv.hostPlatform.isDarwin && (atLeast12 -> !profiledCompiler); 104 105 inherit (stdenv) buildPlatform hostPlatform targetPlatform; 106 107 patches = callFile ./patches {}; 108 109 /* Cross-gcc settings (build == host != target) */ 110 crossMingw = targetPlatform != hostPlatform && targetPlatform.isMinGW; 111 stageNameAddon = optionalString withoutTargetLibc "-nolibc"; 112 crossNameAddon = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}${stageNameAddon}-"; 113 114 javaAwtGtk = langJava && x11Support; 115 xlibs = [ 116 libX11 libXt libSM libICE libXtst libXrender libXrandr libXi 117 xorgproto 118 ]; 119 callFile = lib.callPackageWith ({ 120 # lets 121 inherit 122 majorVersion 123 version 124 buildPlatform 125 hostPlatform 126 targetPlatform 127 patches 128 crossMingw 129 stageNameAddon 130 crossNameAddon 131 ; 132 # inherit generated with 'nix eval --json --impure --expr "with import ./. {}; lib.attrNames (lib.functionArgs gcc${majorVersion}.cc.override)" | jq '.[]' --raw-output' 133 inherit 134 binutils 135 buildPackages 136 cloog 137 withoutTargetLibc 138 disableBootstrap 139 disableGdbPlugin 140 enableLTO 141 enableMultilib 142 enablePlugin 143 enableShared 144 fetchpatch 145 fetchurl 146 gettext 147 gmp 148 gnat-bootstrap 149 gnused 150 isl 151 langAda 152 langC 153 langCC 154 langD 155 langFortran 156 langGo 157 langJit 158 langObjC 159 langObjCpp 160 lib 161 libcCross 162 libmpc 163 libucontext 164 libxcrypt 165 mpfr 166 name 167 noSysDirs 168 nukeReferences 169 patchelf 170 perl 171 pkgsBuildTarget 172 profiledCompiler 173 reproducibleBuild 174 staticCompiler 175 stdenv 176 targetPackages 177 texinfo 178 threadsCross 179 which 180 zip 181 zlib 182 ; 183 } // lib.optionalAttrs (!atLeast7) { 184 inherit 185 boehmgc 186 flex 187 gnat-bootstrap 188 gtk2 189 langAda 190 langJava 191 libICE 192 libSM 193 libX11 194 libXi 195 libXrandr 196 libXrender 197 libXt 198 libXtst 199 libart_lgpl 200 pkg-config 201 unzip 202 x11Support 203 xorgproto 204 javaAwtGtk 205 xlibs 206 ; 207 javaEcj = fetchurl { 208 # The `$(top_srcdir)/ecj.jar' file is automatically picked up at 209 # `configure' time. 210 211 # XXX: Eventually we might want to take it from upstream. 212 url = "ftp://sourceware.org/pub/java/ecj-4.3.jar"; 213 sha256 = "0jz7hvc0s6iydmhgh5h2m15yza7p2rlss2vkif30vm9y77m97qcx"; 214 }; 215 216 # Antlr (optional) allows the Java `gjdoc' tool to be built. We want a 217 # binary distribution here to allow the whole chain to be bootstrapped. 218 javaAntlr = fetchurl { 219 url = "https://www.antlr.org/download/antlr-4.4-complete.jar"; 220 sha256 = "02lda2imivsvsis8rnzmbrbp8rh1kb8vmq4i67pqhkwz7lf8y6dz"; 221 }; 222 }); 223 224in 225 226# We need all these X libraries when building AWT with GTK. 227assert !atLeast7 -> (x11Support -> (filter (x: x == null) ([ gtk2 libart_lgpl ] ++ xlibs)) == []); 228 229lib.pipe ((callFile ./common/builder.nix {}) ({ 230 pname = "${crossNameAddon}${name}"; 231 inherit version; 232 233 src = if is6 && stdenv.targetPlatform.isVc4 then fetchFromGitHub { 234 owner = "itszor"; 235 repo = "gcc-vc4"; 236 rev = "e90ff43f9671c760cf0d1dd62f569a0fb9bf8918"; 237 sha256 = "0gxf66hwqk26h8f853sybphqa5ca0cva2kmrw5jsiv6139g0qnp8"; 238 } else if is6 && stdenv.targetPlatform.isRedox then fetchFromGitHub { 239 owner = "redox-os"; 240 repo = "gcc"; 241 rev = "f360ac095028d286fc6dde4d02daed48f59813fa"; # `redox` branch 242 sha256 = "1an96h8l58pppyh3qqv90g8hgcfd9hj7igvh2gigmkxbrx94khfl"; 243 } else fetchurl { 244 url = if atLeast7 245 then "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz" 246 else if atLeast6 247 then "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.xz" 248 else "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.bz2"; 249 ${if is10 || is11 || is13 then "hash" else "sha256"} = 250 versions.srcHashForVersion version; 251 }; 252 253 inherit patches; 254 255 outputs = 256 if atLeast7 257 then [ "out" "man" "info" ] ++ lib.optional (!langJit) "lib" 258 else if atLeast49 && (langJava || langGo || (if atLeast6 then langJit else targetPlatform.isDarwin)) then ["out" "man" "info"] 259 else [ "out" "lib" "man" "info" ]; 260 261 setOutputFlags = false; 262 NIX_NO_SELF_RPATH = true; 263 264 libc_dev = stdenv.cc.libc_dev; 265 266 hardeningDisable = [ "format" "pie" ] 267 ++ lib.optionals (is11 && langAda) [ "fortify3" ]; 268 269 postPatch = lib.optionalString atLeast7 '' 270 configureScripts=$(find . -name configure) 271 for configureScript in $configureScripts; do 272 patchShebangs $configureScript 273 done 274 '' 275 # This should kill all the stdinc frameworks that gcc and friends like to 276 # insert into default search paths. 277 + lib.optionalString (atLeast6 && hostPlatform.isDarwin) '' 278 substituteInPlace gcc/config/darwin-c.c${lib.optionalString atLeast12 "c"} \ 279 --replace 'if (stdinc)' 'if (0)' 280 281 substituteInPlace libgcc/config/t-slibgcc-darwin \ 282 --replace "-install_name @shlib_slibdir@/\$(SHLIB_INSTALL_NAME)" "-install_name ''${!outputLib}/lib/\$(SHLIB_INSTALL_NAME)" 283 284 substituteInPlace libgfortran/configure \ 285 --replace "-install_name \\\$rpath/\\\$soname" "-install_name ''${!outputLib}/lib/\\\$soname" 286 '' 287 + ( 288 lib.optionalString (targetPlatform != hostPlatform || stdenv.cc.libc != null) 289 # On NixOS, use the right path to the dynamic linker instead of 290 # `/lib/ld*.so'. 291 (let 292 libc = if libcCross != null then libcCross else stdenv.cc.libc; 293 in 294 ( 295 '' echo "fixing the {GLIBC,UCLIBC,MUSL}_DYNAMIC_LINKER macros..." 296 for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h 297 do 298 grep -q ${lib.optionalString (!atLeast6) "LIBC"}_DYNAMIC_LINKER "$header" || continue 299 echo " fixing $header..." 300 sed -i "$header" \ 301 -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g' \ 302 -e 's|define[[:blank:]]*MUSL_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define MUSL_DYNAMIC_LINKER\1 "${libc.out}\2"|g' 303 done 304 '' + lib.optionalString (atLeast6 && targetPlatform.libc == "musl") '' 305 sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR' 306 '' 307 ) 308 )) 309 + lib.optionalString (atLeast7 && targetPlatform.isAvr) ('' 310 makeFlagsArray+=( 311 '-s' # workaround for hitting hydra log limit 312 'LIMITS_H_TEST=false' 313 ) 314 ''); 315 316 inherit noSysDirs staticCompiler withoutTargetLibc 317 libcCross crossMingw; 318 319 inherit (callFile ./common/dependencies.nix { }) depsBuildBuild nativeBuildInputs depsBuildTarget buildInputs depsTargetTarget; 320 321 preConfigure = (callFile ./common/pre-configure.nix { }) + lib.optionalString atLeast10 '' 322 ln -sf ${libxcrypt}/include/crypt.h libsanitizer/sanitizer_common/crypt.h 323 ''; 324 325 dontDisableStatic = true; 326 327 configurePlatforms = [ "build" "host" "target" ]; 328 329 configureFlags = (callFile ./common/configure-flags.nix { }) 330 ++ optional (is7 && targetPlatform.isAarch64) "--enable-fix-cortex-a53-843419" 331 ++ optional (is7 && targetPlatform.isNetBSD) "--disable-libcilkrts"; 332 333 targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null; 334 335 buildFlags = 336 # we do not yet have Nix-driven profiling 337 assert atLeast12 -> (profiledCompiler -> !disableBootstrap); 338 if atLeast11 339 then let target = 340 lib.optionalString (profiledCompiler) "profiled" + 341 lib.optionalString (targetPlatform == hostPlatform && hostPlatform == buildPlatform && !disableBootstrap) "bootstrap"; 342 in lib.optional (target != "") target 343 else 344 optional 345 (targetPlatform == hostPlatform && hostPlatform == buildPlatform) 346 (if profiledCompiler then "profiledbootstrap" else "bootstrap"); 347 348 inherit (callFile ./common/strip-attributes.nix { }) 349 stripDebugList 350 stripDebugListTarget 351 preFixup; 352 353 # https://gcc.gnu.org/PR109898 354 enableParallelInstalling = false; 355 356 # https://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 357 ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64"; 358 359 # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the 360 # library headers and binaries, regarless of the language being compiled. 361 # 362 # Note: When building the Java AWT GTK peer, the build system doesn't honor 363 # `--with-gmp' et al., e.g., when building 364 # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just add 365 # them to $CPATH and $LIBRARY_PATH in this case. 366 # 367 # Likewise, the LTO code doesn't find zlib. 368 # 369 # Cross-compiling, we need gcc not to read ./specs in order to build the g++ 370 # compiler (after the specs for the cross-gcc are created). Having 371 # LIBRARY_PATH= makes gcc read the specs from ., and the build breaks. 372 373 CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([] 374 ++ optional (zlib != null) zlib 375 ++ optional langJava boehmgc 376 ++ optionals javaAwtGtk xlibs 377 ++ optionals javaAwtGtk [ gmp mpfr ] 378 )); 379 380 LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath ( 381 optional (zlib != null) zlib 382 ++ optional langJava boehmgc 383 ++ optionals javaAwtGtk xlibs 384 ++ optionals javaAwtGtk [ gmp mpfr ] 385 )); 386 387 inherit (callFile ./common/extra-target-flags.nix { }) 388 EXTRA_FLAGS_FOR_TARGET 389 EXTRA_LDFLAGS_FOR_TARGET 390 ; 391 392 passthru = { 393 inherit langC langCC langObjC langObjCpp langAda langFortran langGo langD version; 394 isGNU = true; 395 } // lib.optionalAttrs (!atLeast12) { 396 hardeningUnsupportedFlags = lib.optionals is48 [ "stackprotector" ] ++ [ "fortify3" ]; 397 }; 398 399 enableParallelBuilding = true; 400 inherit enableShared enableMultilib; 401 402 meta = { 403 inherit (callFile ./common/meta.nix { }) 404 homepage 405 license 406 description 407 longDescription 408 platforms 409 maintainers 410 ; 411 } // lib.optionalAttrs (!atLeast11) { 412 badPlatforms = if !(is48 || is49) then [ "aarch64-darwin" ] else lib.platforms.darwin; 413 }; 414} // optionalAttrs is7 { 415 env.NIX_CFLAGS_COMPILE = lib.optionalString (stdenv.cc.isClang && langFortran) "-Wno-unused-command-line-argument"; 416} // lib.optionalAttrs (!atLeast10 && stdenv.hostPlatform.isDarwin) { 417 # GCC <10 requires default cctools `strip` instead of `llvm-strip` used by Darwin bintools. 418 preBuild = '' 419 makeFlagsArray+=('STRIP=${lib.getBin darwin.cctools-port}/bin/${stdenv.cc.targetPrefix}strip') 420 ''; 421} // optionalAttrs (!atLeast7) { 422 env.langJava = langJava; 423} // optionalAttrs atLeast6 { 424 NIX_LDFLAGS = lib.optionalString hostPlatform.isSunOS "-lm"; 425} // optionalAttrs (!atLeast8) { 426 doCheck = false; # requires a lot of tools, causes a dependency cycle for stdenv 427} // optionalAttrs enableMultilib { 428 dontMoveLib64 = true; 429} // optionalAttrs (((is49 && !stdenv.hostPlatform.isDarwin) || is6) && langJava) { 430 postFixup = '' 431 target="$(echo "$out/libexec/gcc"/*/*/ecj*)" 432 patchelf --set-rpath "$(patchelf --print-rpath "$target"):$out/lib" "$target" 433 ''; 434} 435)) 436([ 437 (callPackage ./common/libgcc.nix { inherit version langC langCC langJit targetPlatform hostPlatform withoutTargetLibc enableShared libcCross; }) 438] ++ optionals atLeast11 [ 439 (callPackage ./common/checksum.nix { inherit langC langCC; }) 440]) 441