From 15b41bfda278c43aef416fd546f4d10f7b1885dc Mon Sep 17 00:00:00 2001 From: Judah Jacobson Date: Thu, 9 Aug 2018 20:01:54 -0700 Subject: [PATCH 1/3] Fix CC configuration for Mac and latest rules_haskell. This matches up the C compiler that Nix's GHC was built against. On Linux it's just gcc, but on Mac it's clang -- and also needs some extra command-line flags similar to what's done in rules_haskell: https://github.com/tweag/rules_haskell/blob/258b3c962c4661f9425530c92b01c2135ff0500e/shell.nix#L16 --- WORKSPACE | 8 ++++---- compiler.nix | 27 +++++++++++++++++++++++++++ tools/bazel.rc | 2 ++ 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 compiler.nix create mode 100644 tools/bazel.rc diff --git a/WORKSPACE b/WORKSPACE index 086d16d..fa7b436 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -19,9 +19,9 @@ nixpkgs_git_repository( load("//:cc_configure_custom.bzl", "cc_configure_custom") nixpkgs_package( - name = "gcc", + name = "compiler", repository = "@nixpkgs", - attribute_path = "gcc", + nix_file = "//:compiler.nix", ) nixpkgs_package( @@ -32,12 +32,12 @@ nixpkgs_package( cc_configure_custom( name = "local_config_cc", - gcc = "@gcc//:bin/gcc", + gcc = "@compiler//:bin/gcc", ld = "@binutils//:bin/ld", ) -RULES_HASKELL_SHA = "f724288c61ea637e53561208d021df79d003c537" +RULES_HASKELL_SHA = "4964f8309a9f28b4a13340d22198e54926d3fa7e" http_archive( name = "io_tweag_rules_haskell", diff --git a/compiler.nix b/compiler.nix new file mode 100644 index 0000000..4483c2c --- /dev/null +++ b/compiler.nix @@ -0,0 +1,27 @@ +{ pkgs ? import {} }: + +let + frameworks = pkgs.darwin.apple_sdk.frameworks; + overrideClang = pkgs.stdenv.mkDerivation { + name = "enhanced-clang"; + phases = [ "installPhase" ]; + installPhase = '' + mkdir -p $out/bin + cat > $out/bin/gcc << EOL + #!/bin/sh + ${pkgs.clang}/bin/clang \ + -Wno-unused-command-line-argument \ + -I${pkgs.libcxx}/include/c++/v1 \ + -L${pkgs.libcxx}/lib \ + -F${frameworks.CoreFoundation}/Library/Frameworks \ + -F${frameworks.CoreServices}/Library/Frameworks \ + -F${frameworks.Security}/Library/Frameworks \ + -F${frameworks.Foundation}/Library/Frameworks \ + \''$@ + EOL + + chmod +x $out/bin/gcc + ''; + }; +in if pkgs.stdenv.isDarwin then overrideClang else pkgs.gcc + diff --git a/tools/bazel.rc b/tools/bazel.rc new file mode 100644 index 0000000..e9192db --- /dev/null +++ b/tools/bazel.rc @@ -0,0 +1,2 @@ +# Use the overrides from @local_config_cc on MacOS as well: +build --action_env=BAZEL_USE_CPP_ONLY_TOOLCHAIN=1 From e8c19ebd527439a6d9e6375c9e3fa8481dedc4ef Mon Sep 17 00:00:00 2001 From: Judah Jacobson Date: Fri, 10 Aug 2018 10:07:51 -0700 Subject: [PATCH 2/3] rename wrapper to `bin/cc` --- WORKSPACE | 2 +- compiler.nix | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index fa7b436..4e034df 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -32,7 +32,7 @@ nixpkgs_package( cc_configure_custom( name = "local_config_cc", - gcc = "@compiler//:bin/gcc", + gcc = "@compiler//:bin/cc", ld = "@binutils//:bin/ld", ) diff --git a/compiler.nix b/compiler.nix index 4483c2c..0b0248c 100644 --- a/compiler.nix +++ b/compiler.nix @@ -7,7 +7,7 @@ let phases = [ "installPhase" ]; installPhase = '' mkdir -p $out/bin - cat > $out/bin/gcc << EOL + cat > $out/bin/cc << EOL #!/bin/sh ${pkgs.clang}/bin/clang \ -Wno-unused-command-line-argument \ @@ -20,7 +20,7 @@ let \''$@ EOL - chmod +x $out/bin/gcc + chmod +x $out/bin/cc ''; }; in if pkgs.stdenv.isDarwin then overrideClang else pkgs.gcc From 3daec3d81543969d56068e7b910bebc2297652b7 Mon Sep 17 00:00:00 2001 From: Judah Jacobson Date: Fri, 10 Aug 2018 11:25:37 -0700 Subject: [PATCH 3/3] undo accidental push --- WORKSPACE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WORKSPACE b/WORKSPACE index 4e034df..f9b05b0 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -37,7 +37,7 @@ cc_configure_custom( ) -RULES_HASKELL_SHA = "4964f8309a9f28b4a13340d22198e54926d3fa7e" +RULES_HASKELL_SHA = "f724288c61ea637e53561208d021df79d003c537" http_archive( name = "io_tweag_rules_haskell",