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.
13 x86_64-freebsd = import ./bootstrap-files/x86_64-unknown-freebsd.nix;
16 table.${localSystem.system}
17 or (throw "unsupported platform ${localSystem.system} for the pure FreeBSD stdenv");
22 assert crossSystem == localSystem;
24 inherit (localSystem) system;
25 mkExtraBuildCommands0 = cc: ''
26 rsrc="$out/resource-root"
28 ln -s "${lib.getLib cc}/lib/clang/${lib.versions.major cc.version}/include" "$rsrc"
29 echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
31 mkExtraBuildCommands =
33 mkExtraBuildCommands0 cc
35 ln -s "${compiler-rt.out}/lib" "$rsrc/lib"
36 ln -s "${compiler-rt.out}/share" "$rsrc/share"
42 name = "bootstrap-archive";
43 pname = "bootstrap-archive";
45 builder = "${bootstrapFiles.unpack}/libexec/ld-elf.so.1";
47 "${bootstrapFiles.unpack}/bin/bash"
48 ./unpack-bootstrap-files.sh
50 LD_LIBRARY_PATH = "${bootstrapFiles.unpack}/lib";
51 src = bootstrapFiles.unpack;
52 inherit (bootstrapFiles) bootstrapTools;
62 name = attrs.name or (builtins.baseNameOf (builtins.elemAt attrs.paths 0));
63 src = bootstrapArchive;
64 builder = "${bootstrapArchive}/bin/bash";
65 args = [ ./linkBootstrap.sh ];
66 PATH = "${bootstrapArchive}/bin";
72 # commented linkBootstrap entries are provided but unused
74 expand-response-params = "";
75 bsdcp = linkBootstrap { paths = [ "bin/bsdcp" ]; };
76 patchelf = linkBootstrap { paths = [ "bin/patchelf" ]; };
77 bash = linkBootstrap {
83 shellPath = "/bin/bash";
85 curl = linkBootstrap {
91 clang-unwrapped = linkBootstrap {
97 # SYNCME: this version number must be synced with the one in make-bootstrap-tools.nix
100 libunwind = linkBootstrap {
106 "lib/libunwind.so.1.0"
107 "lib/libunwind_shared.so"
111 coreutils = linkBootstrap {
113 paths = map (str: "bin/" + str) [
212 diffutils = linkBootstrap {
214 paths = map (str: "bin/" + str) [
221 findutils = linkBootstrap {
228 iconv = linkBootstrap { paths = [ "bin/iconv" ]; };
229 patch = linkBootstrap { paths = [ "bin/patch" ]; };
230 gnutar = linkBootstrap { paths = [ "bin/tar" ]; };
231 gawk = linkBootstrap {
237 gnumake = linkBootstrap { paths = [ "bin/make" ]; };
238 gnugrep = linkBootstrap {
245 gnused = linkBootstrap { paths = [ "bin/sed" ]; };
246 gzip = linkBootstrap {
252 bzip2 = linkBootstrap {
267 binutils-unwrapped = linkBootstrap {
269 paths = map (str: "bin/" + str) [
288 locales = linkBootstrap { paths = [ "share/locale" ]; };
289 libc = linkBootstrap {
290 name = "bootstrapLibs";
307 "lib/libc_nonshared.a"
314 "lib/libdevstat.so.7"
320 "lib/libexecinfo.so.1"
333 "lib/libncurses.so.6"
335 "lib/libncursesw.so.6"
349 version = "bootstrap";
358 prevStage: super: self:
365 prevStage.bsdcp or (prevStage.runCommand "bsdcp" { }
366 "mkdir -p $out/bin; cp ${prevStage.freebsd.cp}/bin/cp $out/bin/bsdcp"
368 initialPath = with prevStage; [
385 shell = "${prevStage.bash}/bin/bash";
386 stdenvNoCC = import ../generic {
393 name = "stdenvNoCC-${name}";
394 buildPlatform = localSystem;
395 hostPlatform = localSystem;
396 targetPlatform = localSystem;
399 fetchurlBoot = import ../../build-support/fetchurl {
400 inherit lib stdenvNoCC;
401 inherit (prevStage) curl;
403 stdenv = import ../generic {
410 name = "stdenv-${name}";
411 buildPlatform = localSystem;
412 hostPlatform = localSystem;
413 targetPlatform = localSystem;
414 extraNativeBuildInputs = [
418 cc = lib.makeOverridable (import ../../build-support/cc-wrapper) {
419 inherit lib stdenvNoCC;
421 inherit (prevStage.freebsd) libc;
422 inherit (prevStage) gnugrep coreutils expand-response-params;
423 libcxx = prevStage.llvmPackages.libcxx or null;
424 runtimeShell = shell;
425 propagateDoc = false;
428 cc = prevStage.llvmPackages.clang-unwrapped;
430 extraPackages = lib.optionals hascxx [
431 prevStage.llvmPackages.compiler-rt
434 libcxx-cxxflags = lib.optionals (!hascxx) [ "-isystem ${prevStage.freebsd.libc}/include/c++/v1" ];
436 extraBuildCommands = lib.optionalString hascxx (
437 mkExtraBuildCommands prevStage.llvmPackages.clang-unwrapped prevStage.llvmPackages.compiler-rt
439 bintools = lib.makeOverridable (import ../../build-support/bintools-wrapper) {
440 inherit lib stdenvNoCC;
441 name = "${name}-bintools";
442 inherit (prevStage.freebsd) libc;
443 inherit (prevStage) gnugrep coreutils expand-response-params;
444 runtimeShell = shell;
445 bintools = prevStage.binutils-unwrapped;
446 propagateDoc = false;
451 overrides = overrides prevStage;
453 export NIX_ENFORCE_PURITY="''${NIX_ENFORCE_PURITY-1}"
454 export NIX_ENFORCE_NO_NATIVE="''${NIX_ENFORCE_NO_NATIVE-1}"
455 export PATH_LOCALE=${prevStage.freebsd.localesReal or prevStage.freebsd.locales}/share/locale
460 inherit config overlays stdenv;
467 name = "freebsd-boot-0";
469 overrides = prevStage: self: super: {
470 # 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
471 # 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
472 inherit (bootstrapTools)
490 binutils-unwrapped = builtins.removeAttrs bootstrapTools.binutils-unwrapped [ "src" ];
491 fetchurl = import ../../build-support/fetchurl {
493 inherit (self) stdenvNoCC;
494 inherit (prevStage) curl;
496 gettext = super.gettext.overrideAttrs {
497 NIX_CFLAGS_COMPILE = "-DHAVE_ICONV=1"; # we clearly have iconv. what do you want?
499 curlReal = super.curl;
500 tzdata = super.tzdata.overrideAttrs { NIX_CFLAGS_COMPILE = "-DHAVE_GETTEXT=0"; };
502 # make it so libcxx/libunwind are built in this stdenv and not the next
503 freebsd = super.freebsd.overrideScope (
505 inherit (prevStage.freebsd) locales;
506 stdenvNoLibcxx = self.overrideCC (self.stdenv // { name = "stdenv-freebsd-boot-0.4"; }) (
507 self.stdenv.cc.override {
508 name = "freebsd-boot-0.4-cc";
509 libc = self.freebsd.libc;
510 bintools = self.stdenv.cc.bintools.override {
511 name = "freebsd-boot-0.4-bintools";
512 libc = self.freebsd.libc;
518 llvmPackages = super.llvmPackages // {
520 (super.llvmPackages.libcxx.override {
521 stdenv = self.overrideCC (self.stdenv // { name = "stdenv-freebsd-boot-0.5"; }) (
522 self.stdenv.cc.override {
523 name = "freebsd-boot-0.5-cc";
524 libc = self.freebsd.libc;
525 bintools = self.stdenv.cc.bintools.override {
526 name = "freebsd-boot-0.5-bintools";
527 libc = self.freebsd.libc;
530 self.llvmPackages.compiler-rt
532 extraBuildCommands = mkExtraBuildCommands self.llvmPackages.clang-unwrapped self.llvmPackages.compiler-rt;
538 NIX_CFLAGS_COMPILE = "-nostdlib++";
539 NIX_LDFLAGS = "--allow-shlib-undefined";
540 cmakeFlags = builtins.filter (x: x != "-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib") super'.cmakeFlags;
548 name = "freebsd-boot-1";
549 overrides = prevStage: self: super: {
550 # this one's goal is to build all the tools that get imported into the final stdenv.
551 # we can import the foundational libs from boot-0
552 # we can import bins and libs that DON'T get imported OR LINKED into the final stdenv from boot-0
553 curl = prevStage.curlReal;
562 fetchurlReal = super.fetchurl;
563 freebsd = super.freebsd.overrideScope (
565 locales = prevStage.freebsd.locales;
566 localesReal = super'.locales;
567 libc = prevStage.freebsd.libc;
570 llvmPackages = super.llvmPackages // {
571 libcxx = prevStage.llvmPackages.libcxx;
577 overrides = prevStage: self: super: {
578 __bootstrapArchive = bootstrapArchive;
579 fetchurl = prevStage.fetchurlReal;
580 freebsd = super.freebsd.overrideScope (
581 self': super': { localesPrev = prevStage.freebsd.localesReal; }