From e95040bccc0121755ed9fdb9c75f90f42eb34c67 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 12 Jul 2022 13:58:04 +0200 Subject: [PATCH 1/2] Use the `cc` tool for c2hs instead of `cpp` The `cpp` tool on Darwin (and Windows) errors out when using the `-x c` flags: ``` $ cpp -x c /tmp/ch2s.h clang: error: no input files ``` When using `cpp` as the tool for the `c2hs --cpp=` option, `c2hs` adds the `-x c` flags automatically which then causes the error. (see [Config.hs]) Using the C compiler instead (with `-E`) makes this work on all systems. Re-activate tests that had been disabled because of `c2hs` failing with `clang: error: no input files`. Fixes #1486 [Config.hs]: https://github.com/haskell/c2hs/blob/bb7079f4bf3ca4af00f6178d05a8da9238ddff7c/src/C2HS/Config.hs#L53-L67 --- haskell/c2hs.bzl | 2 +- tests/c2hs/BUILD.bazel | 15 --------------- tests/c2hs/repo/BUILD.bazel | 5 ----- tests/haskell_module/repl/BUILD.bazel | 10 ---------- tests/repl-targets/BUILD.bazel | 15 --------------- tests/version-macros/BUILD.bazel | 10 ---------- 6 files changed, 1 insertion(+), 56 deletions(-) diff --git a/haskell/c2hs.bzl b/haskell/c2hs.bzl index 0fad061c1..cdaa1d74d 100644 --- a/haskell/c2hs.bzl +++ b/haskell/c2hs.bzl @@ -42,7 +42,7 @@ def _c2hs_library_impl(ctx): args.add_all([chs_file.path, "-o", hs_file.path]) args.add("-C-E") - args.add_all(["--cpp", cc.tools.cpp]) + args.add_all(["--cpp", cc.tools.cc]) args.add("-C-includeghcplatform.h") args.add("-C-includeghcversion.h") args.add_all(["-C" + x for x in cc.cpp_flags]) diff --git a/tests/c2hs/BUILD.bazel b/tests/c2hs/BUILD.bazel index b39a6eb36..d16d33483 100644 --- a/tests/c2hs/BUILD.bazel +++ b/tests/c2hs/BUILD.bazel @@ -10,22 +10,12 @@ c2hs_library( name = "foo", srcs = ["src/Foo/Foo.chs"], src_strip_prefix = "src", - tags = [ - # See https://github.com/tweag/rules_haskell/issues/1486 - "dont_test_on_darwin_with_bindist", - "dont_test_on_windows", - ], deps = ["//tests:zlib"], ) c2hs_library( name = "bar", srcs = ["Bar.chs"], - tags = [ - # See https://github.com/tweag/rules_haskell/issues/1486 - "dont_test_on_darwin_with_bindist", - "dont_test_on_windows", - ], deps = [":foo"], ) @@ -36,11 +26,6 @@ haskell_library( ":foo", "@c2hs_repo//:baz", ], - tags = [ - # See https://github.com/tweag/rules_haskell/issues/1486 - "dont_test_on_darwin_with_bindist", - "dont_test_on_windows", - ], deps = ["//tests/hackage:base"], ) diff --git a/tests/c2hs/repo/BUILD.bazel b/tests/c2hs/repo/BUILD.bazel index 424f251e4..3b5545e71 100644 --- a/tests/c2hs/repo/BUILD.bazel +++ b/tests/c2hs/repo/BUILD.bazel @@ -5,11 +5,6 @@ package(default_testonly = 1) c2hs_library( name = "baz", srcs = ["Baz.chs"], - tags = [ - # See https://github.com/tweag/rules_haskell/issues/1486 - "dont_test_on_darwin_with_bindist", - "dont_test_on_windows", - ], visibility = ["//visibility:public"], deps = ["@rules_haskell//tests:zlib"], ) diff --git a/tests/haskell_module/repl/BUILD.bazel b/tests/haskell_module/repl/BUILD.bazel index 20fc3bc8a..23e016344 100644 --- a/tests/haskell_module/repl/BUILD.bazel +++ b/tests/haskell_module/repl/BUILD.bazel @@ -6,11 +6,6 @@ rules_haskell_integration_test( name = "haskell_module_repl_test", size = "small", srcs = ["HaskellModuleReplTest.hs"], - tags = [ - # See https://github.com/tweag/rules_haskell/issues/1486 - "dont_test_on_darwin_with_bindist", - "dont_test_on_windows", - ], workspace_path = "haskell_module_repl_test", ) @@ -18,11 +13,6 @@ rules_haskell_integration_test( name = "haskell_module_repl_cross_library_deps_test", size = "small", srcs = ["HaskellModuleReplCrossLibraryDepsTest.hs"], - tags = [ - # See https://github.com/tweag/rules_haskell/issues/1486 - "dont_test_on_darwin_with_bindist", - "dont_test_on_windows", - ], workspace_path = "haskell_module_repl_cross_library_deps_test", ) diff --git a/tests/repl-targets/BUILD.bazel b/tests/repl-targets/BUILD.bazel index 8b88498f6..bfa334d88 100644 --- a/tests/repl-targets/BUILD.bazel +++ b/tests/repl-targets/BUILD.bazel @@ -24,11 +24,6 @@ genrule( c2hs_library( name = "chs", srcs = ["Chs.chs"], - tags = [ - # See https://github.com/tweag/rules_haskell/issues/1486 - "dont_test_on_darwin_with_bindist", - "dont_test_on_windows", - ], ) haskell_library( @@ -39,11 +34,6 @@ haskell_library( ":chs", ":codegen", ], - tags = [ - # See https://github.com/tweag/rules_haskell/issues/1486 - "dont_test_on_darwin_with_bindist", - "dont_test_on_windows", - ], visibility = ["//visibility:public"], deps = [ "//tests:zlib", @@ -123,11 +113,6 @@ rules_haskell_integration_test( rules_haskell_integration_test( name = "hs_lib_repl_test", srcs = ["HsLibReplTest.hs"], - tags = [ - # See https://github.com/tweag/rules_haskell/issues/1486 - "dont_test_on_darwin_with_bindist", - "dont_test_on_windows", - ], workspace_path = "hs_lib_repl_test", ) diff --git a/tests/version-macros/BUILD.bazel b/tests/version-macros/BUILD.bazel index bd96527b8..1b86c6708 100644 --- a/tests/version-macros/BUILD.bazel +++ b/tests/version-macros/BUILD.bazel @@ -70,11 +70,6 @@ haskell_module( c2hs_library( name = "c2hs-lib", srcs = ["C2hsLib.chs"], - tags = [ - # See https://github.com/tweag/rules_haskell/issues/1486 - "dont_test_on_darwin_with_bindist", - "dont_test_on_windows", - ], version = "4.5.6.7", deps = [ ":versioned-lib", @@ -90,11 +85,6 @@ haskell_test( ":c2hs-lib", ], main_file = "MainC2hs.hs", - tags = [ - # See https://github.com/tweag/rules_haskell/issues/1486 - "dont_test_on_darwin_with_bindist", - "dont_test_on_windows", - ], version = "4.5.6.7", visibility = ["//tests/asterius/version-macros:__pkg__"], deps = [ From 0a8c9d86ae91262f9aa3917ce8e9ad195935e9e3 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 12 Jul 2022 15:42:57 +0200 Subject: [PATCH 2/2] Skip hs_lib_repl_test on darwin with bindist --- tests/repl-targets/BUILD.bazel | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/repl-targets/BUILD.bazel b/tests/repl-targets/BUILD.bazel index bfa334d88..726956d32 100644 --- a/tests/repl-targets/BUILD.bazel +++ b/tests/repl-targets/BUILD.bazel @@ -113,6 +113,10 @@ rules_haskell_integration_test( rules_haskell_integration_test( name = "hs_lib_repl_test", srcs = ["HsLibReplTest.hs"], + tags = [ + # See https://github.com/tweag/rules_haskell/issues/1779 + "dont_test_on_darwin_with_bindist", + ], workspace_path = "hs_lib_repl_test", )