bazel-contrib / bazel-contrib/rules_foreign_cc

BootstrapGNUMake fails to run `make` on Windows

Open
#1,094 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Starlark
Stars
737
Forks
270
PR merge metrics
No merged PRs in 30d

Description

```
INFO: Found 1 target...
ERROR: C:/users/ammy/_bazel_ammy/ibushhct/external/rules_foreign_cc/toolchains/BUILD.bazel:130:10: BootstrapGNUMake external/rules_foreign_cc/toolchains/make [for tool] failed: (Exit 2): bash.exe failed: error executing command (from target @rules_foreign_cc//toolchains:make_tool) C:\MinGW\msys\1.0\bin\bash.exe -c bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/rules_foreign_cc/toolchains/make_tool_foreign_cc/wrapper_build_script.sh
rules_foreign_cc: Build failed!
rules_foreign_cc: Keeping temp build directory and dependencies directory for debug.
rules_foreign_cc: Please note that the directories inside a sandbox are still cleaned unless you specify --sandbox_debug Bazel command line flag.
rules_foreign_cc: Printing build logs:
_____ BEGIN BUILD LOGS _____
+ ./build_w32.bat --without-guile
./build_w32.bat: line 1: @echo: command not found
./build_w32.bat: line 2: syntax error near unexpected token `('
./build_w32.bat: line 2: `:: Copyright (C) 1996-2020 Free Software Foundation, Inc.'
_____ END BUILD LOGS _____
rules_foreign_cc: Build wrapper script location: bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/rules_foreign_cc/toolchains/make_tool_foreign_cc/wrapper_build_script.sh
rules_foreign_cc: Build script location: bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/rules_foreign_cc/toolchains/make_tool_foreign_cc/build_script.sh
rules_foreign_cc: Build log location: bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/rules_foreign_cc/toolchains/make_tool_foreign_cc/BootstrapGNUMake.log
```

This seems to be doing something pretty normal (as [these lines are in make itself](https://github.com/compuphase/Make-plus/blob/master/build_w32.bat#L1-L3)) but failing *very* early; this seems to be before any of my code is attempting to build, since it's still bootstrapping. I'm using MinGW make and bash, because as outlined in [this issue](https://github.com/bazelbuild/rules_foreign_cc/issues/791), WSL does not have `pwd -W`, so rules_foreign_cc dies even earlier.

This builds just fine when running *either* in WSL or on an actual Ubuntu distribution, just not in Windows.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Windows failure through @rules_foreign_cc//toolchains:make_tool and inspect toolchains/BUILD.bazel around line 130, the generated wrapper/build scripts, and BootstrapGNUMake.log. Compare the handling of build_w32.bat with the WSL and Ubuntu runs; done means BootstrapGNUMake can invoke make successfully on Windows without treating the batch file as a Bash script.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.