1 # afaik the longest dependency chain is stdenv -> stdenv-1#coreutils -> stdenv-1#gmp -> stdenv-0#libcxx -> stdenv-0#libc
2 # this is only possible through aggressive hacking to make libcxx build with stdenv-0#libc instead of bootstrapTools.libc.
12 x86_64-freebsd = import ./bootstrap-files/x86_64-unknown-freebsd.nix;
14 files = table.${localSystem.system} or (throw "unsupported platform ${localSystem.system} for the pure FreeBSD stdenv");
18 assert crossSystem == localSystem;
20 inherit (localSystem) system;
21 mkExtraBuildCommands0 = cc: ''
22 rsrc="$out/resource-root"
24 ln -s "${lib.getLib cc}/lib/clang/${lib.versions.major cc.version}/include" "$rsrc"
25 echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
27 mkExtraBuildCommands =
29 mkExtraBuildCommands0 cc
31 ln -s "${compiler-rt.out}/lib" "$rsrc/lib"
32 ln -s "${compiler-rt.out}/share" "$rsrc/share"
38 name = "bootstrap-archive";
39 pname = "bootstrap-archive";
41 builder = "${bootstrapFiles.unpack}/libexec/ld-elf.so.1";
42 args = [ "${bootstrapFiles.unpack}/bin/bash" ./unpack-bootstrap-files.sh ];
43 LD_LIBRARY_PATH = "${bootstrapFiles.unpack}/lib";
44 src = bootstrapFiles.unpack;
45 inherit (bootstrapFiles) bootstrapTools;
55 name = attrs.name or (builtins.baseNameOf (builtins.elemAt attrs.paths 0));
56 src = bootstrapArchive;
57 builder = "${bootstrapArchive}/bin/bash";
58 args = [ ./linkBootstrap.sh ];
59 PATH = "${bootstrapArchive}/bin";
65 # commented linkBootstrap entries are provided but unused
67 expand-response-params = "";
68 bsdcp = linkBootstrap { paths = [ "bin/bsdcp" ]; };
69 patchelf = linkBootstrap { paths = [ "bin/patchelf" ]; };
70 bash = linkBootstrap {
76 shellPath = "/bin/bash";
78 curl = linkBootstrap {
84 clang-unwrapped = linkBootstrap {
90 # SYNCME: this version number must be synced with the one in make-bootstrap-tools.nix
93 libunwind = linkBootstrap {
99 "lib/libunwind.so.1.0"
100 "lib/libunwind_shared.so"
104 coreutils = linkBootstrap {
106 paths = map (str: "bin/" + str) [
205 diffutils = linkBootstrap {
207 paths = map (str: "bin/" + str) [
214 findutils = linkBootstrap {
221 iconv = linkBootstrap { paths = [ "bin/iconv" ]; };
222 patch = linkBootstrap { paths = [ "bin/patch" ]; };
223 gnutar = linkBootstrap { paths = [ "bin/tar" ]; };
224 gawk = linkBootstrap {
230 gnumake = linkBootstrap { paths = [ "bin/make" ]; };
231 gnugrep = linkBootstrap {
238 gnused = linkBootstrap { paths = [ "bin/sed" ]; };
239 gzip = linkBootstrap {
245 bzip2 = linkBootstrap { paths = [ "bin/bzip2" "lib/libbz2.so" "lib/libbz2.so.1" ]; };
254 binutils-unwrapped = linkBootstrap {
256 paths = map (str: "bin/" + str) [
275 locales = linkBootstrap { paths = [ "share/locale" ]; };
276 libc = linkBootstrap {
277 name = "bootstrapLibs";
294 "lib/libc_nonshared.a"
301 "lib/libdevstat.so.7"
307 "lib/libexecinfo.so.1"
320 "lib/libncurses.so.6"
322 "lib/libncursesw.so.6"
336 version = "bootstrap";
345 prevStage: super: self:
352 prevStage.bsdcp or (prevStage.runCommand "bsdcp" { }
353 "mkdir -p $out/bin; cp ${prevStage.freebsd.cp}/bin/cp $out/bin/bsdcp"
355 initialPath = with prevStage; [
372 shell = "${prevStage.bash}/bin/bash";
373 stdenvNoCC = import ../generic {
380 name = "stdenvNoCC-${name}";
381 buildPlatform = localSystem;
382 hostPlatform = localSystem;
383 targetPlatform = localSystem;
386 fetchurlBoot = import ../../build-support/fetchurl {
387 inherit lib stdenvNoCC;
388 inherit (prevStage) curl;
390 stdenv = import ../generic {
397 name = "stdenv-${name}";
398 buildPlatform = localSystem;
399 hostPlatform = localSystem;
400 targetPlatform = localSystem;
401 extraNativeBuildInputs = [
405 cc = lib.makeOverridable (import ../../build-support/cc-wrapper) {
406 inherit lib stdenvNoCC;
408 inherit (prevStage.freebsd) libc;
409 inherit (prevStage) gnugrep coreutils expand-response-params;
410 libcxx = prevStage.llvmPackages.libcxx or null;
411 runtimeShell = shell;
412 propagateDoc = false;
415 cc = prevStage.llvmPackages.clang-unwrapped;
417 extraPackages = lib.optionals hascxx [
418 prevStage.llvmPackages.compiler-rt
421 libcxx-cxxflags = lib.optionals (!hascxx) [ "-isystem ${prevStage.freebsd.libc}/include/c++/v1" ];
423 extraBuildCommands = lib.optionalString hascxx (
424 mkExtraBuildCommands prevStage.llvmPackages.clang-unwrapped prevStage.llvmPackages.compiler-rt
426 bintools = lib.makeOverridable (import ../../build-support/bintools-wrapper) {
427 inherit lib stdenvNoCC;
428 name = "${name}-bintools";
429 inherit (prevStage.freebsd) libc;
430 inherit (prevStage) gnugrep coreutils expand-response-params;
431 runtimeShell = shell;
432 bintools = prevStage.binutils-unwrapped;
433 propagateDoc = false;
438 overrides = overrides prevStage;
440 export NIX_ENFORCE_PURITY="''${NIX_ENFORCE_PURITY-1}"
441 export NIX_ENFORCE_NO_NATIVE="''${NIX_ENFORCE_NO_NATIVE-1}"
442 export PATH_LOCALE=${prevStage.freebsd.localesReal or prevStage.freebsd.locales}/share/locale
447 inherit config overlays stdenv;
454 name = "freebsd-boot-0";
456 overrides = prevStage: self: super: {
457 # this one's goal is to build foundational libs like libc and libcxx. we want to override literally every possible bin package we can with bootstrap tools
458 # we CAN'T import LLVM because the compiler built here is used to build the final compiler and the final compiler must not be built by the bootstrap compiler
459 inherit (bootstrapTools)
477 binutils-unwrapped = builtins.removeAttrs bootstrapTools.binutils-unwrapped [ "src" ];
478 fetchurl = import ../../build-support/fetchurl {
480 inherit (self) stdenvNoCC;
481 inherit (prevStage) curl;
483 gettext = super.gettext.overrideAttrs {
484 NIX_CFLAGS_COMPILE = "-DHAVE_ICONV=1"; # we clearly have iconv. what do you want?
486 curlReal = super.curl;
487 tzdata = super.tzdata.overrideAttrs { NIX_CFLAGS_COMPILE = "-DHAVE_GETTEXT=0"; };
489 # make it so libcxx/libunwind are built in this stdenv and not the next
490 freebsd = super.freebsd.overrideScope (self': super': {
491 inherit (prevStage.freebsd) locales;
493 self.overrideCC (self.stdenv // { name = "stdenv-freebsd-boot-0.4"; })
495 self.stdenv.cc.override {
496 name = "freebsd-boot-0.4-cc";
497 libc = self.freebsd.libc;
498 bintools = self.stdenv.cc.bintools.override {
499 name = "freebsd-boot-0.4-bintools";
500 libc = self.freebsd.libc;
505 llvmPackages = super.llvmPackages // {
507 (super.llvmPackages.libcxx.override {
508 stdenv = self.overrideCC (self.stdenv // { name = "stdenv-freebsd-boot-0.5"; }) (
509 self.stdenv.cc.override {
510 name = "freebsd-boot-0.5-cc";
511 libc = self.freebsd.libc;
512 bintools = self.stdenv.cc.bintools.override {
513 name = "freebsd-boot-0.5-bintools";
514 libc = self.freebsd.libc;
517 self.llvmPackages.compiler-rt
519 extraBuildCommands = mkExtraBuildCommands self.llvmPackages.clang-unwrapped self.llvmPackages.compiler-rt;
525 NIX_CFLAGS_COMPILE = "-nostdlib++";
526 NIX_LDFLAGS = "--allow-shlib-undefined";
527 cmakeFlags = builtins.filter (x: x != "-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib") super'.cmakeFlags;
535 name = "freebsd-boot-1";
536 overrides = prevStage: self: super: {
537 # this one's goal is to build all the tools that get imported into the final stdenv.
538 # we can import the foundational libs from boot-0
539 # we can import bins and libs that DON'T get imported OR LINKED into the final stdenv from boot-0
540 curl = prevStage.curlReal;
549 fetchurlReal = super.fetchurl;
550 freebsd = super.freebsd.overrideScope (
552 locales = prevStage.freebsd.locales;
553 localesReal = super'.locales;
554 libc = prevStage.freebsd.libc;
557 llvmPackages = super.llvmPackages // {
558 libcxx = prevStage.llvmPackages.libcxx;
564 overrides = prevStage: self: super: {
565 __bootstrapArchive = bootstrapArchive;
566 fetchurl = prevStage.fetchurlReal;
567 freebsd = super.freebsd.overrideScope (
568 self': super': { localesPrev = prevStage.freebsd.localesReal; }