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" ]; };
252 binutils-unwrapped = linkBootstrap {
254 paths = map (str: "bin/" + str) [
273 locales = linkBootstrap { paths = [ "share/locale" ]; };
274 libc = linkBootstrap {
275 name = "bootstrapLibs";
283 version = "bootstrap";
292 prevStage: super: self:
299 prevStage.bsdcp or (prevStage.runCommand "bsdcp" { }
300 "mkdir -p $out/bin; cp ${prevStage.freebsd.cp}/bin/cp $out/bin/bsdcp"
302 initialPath = with prevStage; [
319 shell = "${prevStage.bash}/bin/bash";
320 stdenvNoCC = import ../generic {
327 name = "stdenvNoCC-${name}";
328 buildPlatform = localSystem;
329 hostPlatform = localSystem;
330 targetPlatform = localSystem;
333 fetchurlBoot = import ../../build-support/fetchurl {
334 inherit lib stdenvNoCC;
335 inherit (prevStage) curl;
337 stdenv = import ../generic {
344 name = "stdenv-${name}";
345 buildPlatform = localSystem;
346 hostPlatform = localSystem;
347 targetPlatform = localSystem;
348 extraNativeBuildInputs = [
352 cc = lib.makeOverridable (import ../../build-support/cc-wrapper) {
353 inherit lib stdenvNoCC;
355 inherit (prevStage.freebsd) libc;
356 inherit (prevStage) gnugrep coreutils expand-response-params;
357 libcxx = prevStage.llvmPackages.libcxx or null;
358 runtimeShell = shell;
359 propagateDoc = false;
362 cc = prevStage.llvmPackages.clang-unwrapped;
364 extraPackages = lib.optionals hascxx [
365 prevStage.llvmPackages.compiler-rt
368 libcxx-cxxflags = lib.optionals (!hascxx) [ "-isystem ${prevStage.freebsd.libc}/include/c++/v1" ];
370 extraBuildCommands = lib.optionalString hascxx (
371 mkExtraBuildCommands prevStage.llvmPackages.clang-unwrapped prevStage.llvmPackages.compiler-rt
373 bintools = lib.makeOverridable (import ../../build-support/bintools-wrapper) {
374 inherit lib stdenvNoCC;
375 name = "${name}-bintools";
376 inherit (prevStage.freebsd) libc;
377 inherit (prevStage) gnugrep coreutils expand-response-params;
378 runtimeShell = shell;
379 bintools = prevStage.binutils-unwrapped;
380 propagateDoc = false;
385 overrides = overrides prevStage;
387 export NIX_ENFORCE_PURITY="''${NIX_ENFORCE_PURITY-1}"
388 export NIX_ENFORCE_NO_NATIVE="''${NIX_ENFORCE_NO_NATIVE-1}"
389 export PATH_LOCALE=${prevStage.freebsd.localesReal or prevStage.freebsd.locales}/share/locale
394 inherit config overlays stdenv;
401 name = "freebsd-boot-0";
403 overrides = prevStage: self: super: {
404 # 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
405 # 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
406 inherit (bootstrapTools)
424 binutils-unwrapped = builtins.removeAttrs bootstrapTools.binutils-unwrapped [ "src" ];
425 fetchurl = import ../../build-support/fetchurl {
427 inherit (self) stdenvNoCC;
428 inherit (prevStage) curl;
430 gettext = super.gettext.overrideAttrs {
431 NIX_CFLAGS_COMPILE = "-DHAVE_ICONV=1"; # we clearly have iconv. what do you want?
433 curlReal = super.curl;
434 tzdata = super.tzdata.overrideAttrs { NIX_CFLAGS_COMPILE = "-DHAVE_GETTEXT=0"; };
436 # make it so libcxx/libunwind are built in this stdenv and not the next
437 freebsd = super.freebsd.overrideScope (self': super': {
438 inherit (prevStage.freebsd) locales;
440 self.overrideCC (self.stdenv // { name = "stdenv-freebsd-boot-0.4"; })
442 self.stdenv.cc.override {
443 name = "freebsd-boot-0.4-cc";
444 libc = self.freebsd.libc;
445 bintools = self.stdenv.cc.bintools.override {
446 name = "freebsd-boot-0.4-bintools";
447 libc = self.freebsd.libc;
452 llvmPackages = super.llvmPackages // {
454 (super.llvmPackages.libcxx.override {
455 stdenv = self.overrideCC (self.stdenv // { name = "stdenv-freebsd-boot-0.5"; }) (
456 self.stdenv.cc.override {
457 name = "freebsd-boot-0.5-cc";
458 libc = self.freebsd.libc;
459 bintools = self.stdenv.cc.bintools.override {
460 name = "freebsd-boot-0.5-bintools";
461 libc = self.freebsd.libc;
464 self.llvmPackages.compiler-rt
466 extraBuildCommands = mkExtraBuildCommands self.llvmPackages.clang-unwrapped self.llvmPackages.compiler-rt;
472 NIX_CFLAGS_COMPILE = "-nostdlib++";
473 NIX_LDFLAGS = "--allow-shlib-undefined";
474 cmakeFlags = builtins.filter (x: x != "-DCMAKE_SHARED_LINKER_FLAGS=-nostdlib") super'.cmakeFlags;
482 name = "freebsd-boot-1";
483 overrides = prevStage: self: super: {
484 # this one's goal is to build all the tools that get imported into the final stdenv.
485 # we can import the foundational libs from boot-0
486 # we can import bins and libs that DON'T get imported OR LINKED into the final stdenv from boot-0
487 curl = prevStage.curlReal;
496 fetchurlReal = super.fetchurl;
497 freebsd = super.freebsd.overrideScope (
499 locales = prevStage.freebsd.locales;
500 localesReal = super'.locales;
501 libc = prevStage.freebsd.libc;
504 llvmPackages = super.llvmPackages // {
505 libcxx = prevStage.llvmPackages.libcxx;
511 overrides = prevStage: self: super: {
512 __bootstrapArchive = bootstrapArchive;
513 fetchurl = prevStage.fetchurlReal;
514 freebsd = super.freebsd.overrideScope (
515 self': super': { localesPrev = prevStage.freebsd.localesReal; }