|
40 | 40 | # Prevent cargo aliases from using programs in `~/.cargo` to avoid conflicts
|
41 | 41 | # with rustup installations.
|
42 | 42 | export CARGO_HOME=$HOME/.cargo-nix
|
| 43 | + export DOCKER_BUILDKIT=1 |
| 44 | +
|
| 45 | + # Create a target directory and ensure lib64 is a symlink to lib. |
| 46 | + # Individual build steps may target either directory and later |
| 47 | + # create the symlink making some build outputs inaccessible. |
| 48 | + mkdir -p target/lib |
| 49 | + ln -sf lib target/lib64 |
43 | 50 | ''
|
44 | 51 | + pkgs.lib.optionalString pkgs.stdenv.isDarwin ''
|
45 | 52 | # Fix docker-buildx command on OSX. Can we do this in a cleaner way?
|
|
53 | 60 | {
|
54 | 61 | # This shell is only used for one make recipe because the other
|
55 | 62 | # shell is not able to build one recipe and we haven't managed to
|
56 |
| - # come up with a dev shell that works for everything. |
| 63 | + # come up with a dev shell that works for everything on OSX. |
57 | 64 | #
|
58 | 65 | # nix develop .#wasm -c make build-wasm-libs
|
59 | 66 | #
|
60 | 67 | # After that, the other shell can be used to run `make build`.
|
| 68 | + # |
| 69 | + # With nix the `clang` command is a wrapper that does not understand |
| 70 | + # some of the arguments that are passed to it during the build. This |
| 71 | + # dev shell uses the unwrapped clang command and sets the include |
| 72 | + # directory manually via `CPATH`. |
61 | 73 | wasm = pkgs.mkShell {
|
62 | 74 | # By default clang-unwrapped does not find its resource dir. See
|
63 | 75 | # https://discourse.nixos.org/t/why-is-the-clang-resource-dir-split-in-a-separate-package/34114
|
|
79 | 91 | export PATH="${pkgs.llvmPackages_16.clang-unwrapped}/bin:$PATH"
|
80 | 92 | '';
|
81 | 93 | };
|
82 |
| - default = pkgs.mkShell { |
83 | 94 |
|
84 |
| - packages = with pkgs; [ |
| 95 | + # mkShell brings in a `cc` that points to gcc, stdenv.mkDerivation from llvm avoids this. |
| 96 | + default = let llvmPkgs = pkgs.llvmPackages_16; in llvmPkgs.stdenv.mkDerivation { |
| 97 | + # By default stack protection is enabled by the clang wrapper but I |
| 98 | + # think it's not supported for wasm compilation. It causes this |
| 99 | + # error: |
| 100 | + # |
| 101 | + # Undefined stack protector symbols: __stack_chk_guard ... |
| 102 | + # in arbitrator/wasm-libraries/soft-float/SoftFloat/build/Wasm-Clang/extF80_div.o |
| 103 | + hardeningDisable = [ "stackprotector" ]; |
| 104 | + |
| 105 | + name = "espresso-nitro-dev-shell"; |
| 106 | + buildInputs = with pkgs; [ |
85 | 107 | cmake
|
86 | 108 | stableToolchain
|
87 | 109 |
|
88 |
| - # llvmPackages_16.clang # provides clang without wrapper |
89 |
| - # llvmPackages_16.bintools # provides wasm-ld |
| 110 | + llvmPkgs.clang |
| 111 | + llvmPkgs.bintools # provides wasm-ld |
90 | 112 |
|
91 | 113 | go
|
92 | 114 | # goimports, godoc, etc.
|
|
112 | 134 | darwin.libobjc
|
113 | 135 | darwin.IOKit
|
114 | 136 | darwin.apple_sdk.frameworks.CoreFoundation
|
| 137 | + ] ++ lib.optionals (! stdenv.isDarwin) [ |
| 138 | + glibc_multi.dev # provides gnu/stubs-32.h |
115 | 139 | ];
|
116 | 140 | inherit shellHook;
|
117 |
| - RUST_SRC_PATH = "${stableToolchain}/lib/rustlib/src/rust/library"; |
118 | 141 | };
|
119 | 142 | };
|
120 | 143 | });
|
|
0 commit comments