Skip to content

Linker failure with rules_nixpkgs on MacOS #2317

@facundominguez

Description

@facundominguez

Describe the bug

The failure first occurred in inline-java. When building with the macos-15 or macos-13 runner of github actions, the linker used by GHC or hsc2hs says:

error: ld: unknown option: -no_fixup_chains

I reduced the example to build a single module in this branch. And here are the logs of the run in inline-java's CI.

To Reproduce

In a macos-15 runner, clone the branch, then

echo common --repo_env=BAZEL_USE_CPP_ONLY_TOOLCHAIN=1 > .bazelrc.local
echo common --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 >> .bazelrc.local                                                                                                                  
echo common --incompatible_enable_cc_toolchain_resolution >> .bazelrc.local                                                                                                                   
echo common --toolchain_resolution_debug=cc >> .bazelrc.local                                                                                                                                 
echo common --crosstool_top=@nixpkgs_config_cc//:toolchain >> .bazelrc.local

then

nix-shell --run "bazel build //:inline-java"

Expected behavior

The build should succeed, the same as in the ubuntu runner.

Environment

  • OS: MacOS
  • Bazel version: 6.5.0
  • Version of rules_haskell: 1.0
  • Version of rules_nixpkgs: 0.13.0

Additional context

Apparently related issue: https://discourse.haskell.org/t/solved-trouble-building-unix-package-on-macos-ld-unknown-option-no-fixup-chains/7772/16

I'm configuring the nixpkgs cc toolchain explicitly because otherwise bazel complains about libtool not being available. But I'm finding confusing that the cc toolchain needs to be configured explicitly only in MacOS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions