Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails in patching on Windows #24

Open
kschzt opened this issue Nov 30, 2023 · 5 comments
Open

Build fails in patching on Windows #24

kschzt opened this issue Nov 30, 2023 · 5 comments

Comments

@kschzt
Copy link

kschzt commented Nov 30, 2023

Building with bazelisk on Windows 11 in git bash. This is after installing GNU patch and hardcoding the Python3 path:

kschzt@laptop MINGW64 /c/src/reclient (main)
$ bazelisk build --config=clangscandeps //cmd/...
Starting local Bazel server and connecting to it...
INFO: Repository io_opencensus_go_contrib_exporter_stackdriver instantiated at:
  C:/src/reclient/WORKSPACE:336:14: in <toplevel>
Repository rule go_repository defined at:
  C:/users/kschz/_bazel_kschzt/sd2lufjt/external/bazel_gazelle/internal/go_repository.bzl:313:32: in <toplevel>
ERROR: An error occurred during the fetch of repository 'io_opencensus_go_contrib_exporter_stackdriver':
   Traceback (most recent call last):
        File "C:/users/kschz/_bazel_kschzt/sd2lufjt/external/bazel_gazelle/internal/go_repository.bzl", line 311, column 10, in _go_repository_impl
                patch(ctx)
        File "C:/users/kschz/_bazel_kschzt/sd2lufjt/external/bazel_gazelle/internal/go_repository.bzl", line 563, column 17, in patch
                fail("Error applying patch %s:\n%s%s" %
Error in fail: Error applying patch //third_party/patches/opencensus-go-exporter-stackdriver:opencensus-stackdriver-interval.patch:
Assertion failed: hunk, file ../patch-2.5.9-src/patch.c, line 354
patching file metrics.go
ERROR: C:/src/reclient/WORKSPACE:336:14: fetching go_repository rule //external:io_opencensus_go_contrib_exporter_stackdriver: Traceback (most recent call last):
        File "C:/users/kschz/_bazel_kschzt/sd2lufjt/external/bazel_gazelle/internal/go_repository.bzl", line 311, column 10, in _go_repository_impl
                patch(ctx)
        File "C:/users/kschz/_bazel_kschzt/sd2lufjt/external/bazel_gazelle/internal/go_repository.bzl", line 563, column 17, in patch
                fail("Error applying patch %s:\n%s%s" %
Error in fail: Error applying patch //third_party/patches/opencensus-go-exporter-stackdriver:opencensus-stackdriver-interval.patch:
Assertion failed: hunk, file ../patch-2.5.9-src/patch.c, line 354
patching file metrics.go
ERROR: C:/src/reclient/internal/pkg/monitoring/BUILD.bazel:3:11: //internal/pkg/monitoring:monitoring depends on @io_opencensus_go_contrib_exporter_stackdriver//:stackdriver in repository @io_opencensus_go_contrib_exporter_stackdriver which failed to fetch. no such package '@io_opencensus_go_contrib_exporter_stackdriver//': Error applying patch //third_party/patches/opencensus-go-exporter-stackdriver:opencensus-stackdriver-interval.patch:
Assertion failed: hunk, file ../patch-2.5.9-src/patch.c, line 354
patching file metrics.go
ERROR: Analysis of target '//cmd/bootstrap:bootstrap' failed; build aborted:
INFO: Elapsed time: 11.807s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (335 packages loaded, 12042 targets configured)
    Fetching @go_googleapis; fetching 4s
    Fetching @com_github_vardius_progress_go; fetching
    Fetching @io_opencensus_go; fetching
    Fetching @com_github_google_pprof; fetching
    Fetching @org_golang_google_api; fetching
    Fetching C:/users/kschz/_bazel_kschzt/sd2lufjt/external/go_googleapis; Extracting C:/users/kschz/_bazel_kschzt/sd2lufjt/external/go_googleapis/temp8849367375833790046/53377c165584e84c410a0905d9effb3fe5df2806.zip
    Fetching @com_github_karrick_godirwalk; fetching
    Fetching @llvm-project; fetching
@kschzt
Copy link
Author

kschzt commented Dec 6, 2023

Maybe got a bit further, but still failling

kschzt@LAPTOP-7EEIPMUM UCRT64 /c/src/reclient
$ bazel.exe build -s --verbose_failures //cmd/...
INFO: Repository io_opencensus_go_contrib_exporter_stackdriver instantiated at:
  C:/src/reclient/WORKSPACE:336:14: in <toplevel>
Repository rule go_repository defined at:
  C:/msys64/home/kschzt/_bazel_kschzt/sd2lufjt/external/bazel_gazelle/internal/go_repository.bzl:313:32: in <toplevel>
ERROR: An error occurred during the fetch of repository 'io_opencensus_go_contrib_exporter_stackdriver':
   Traceback (most recent call last):
        File "C:/msys64/home/kschzt/_bazel_kschzt/sd2lufjt/external/bazel_gazelle/internal/go_repository.bzl", line 311, column 10, in _go_repository_impl
                patch(ctx)
        File "C:/msys64/home/kschzt/_bazel_kschzt/sd2lufjt/external/bazel_gazelle/internal/go_repository.bzl", line 563, column 17, in patch
                fail("Error applying patch %s:\n%s%s" %
Error in fail: Error applying patch @//third_party/patches/opencensus-go-exporter-stackdriver:opencensus-stackdriver-interval.patch:
ERROR: C:/src/reclient/WORKSPACE:336:14: fetching go_repository rule //external:io_opencensus_go_contrib_exporter_stackdriver: Traceback (most recent call last):
        File "C:/msys64/home/kschzt/_bazel_kschzt/sd2lufjt/external/bazel_gazelle/internal/go_repository.bzl", line 311, column 10, in _go_repository_impl
                patch(ctx)
        File "C:/msys64/home/kschzt/_bazel_kschzt/sd2lufjt/external/bazel_gazelle/internal/go_repository.bzl", line 563, column 17, in patch
                fail("Error applying patch %s:\n%s%s" %
Error in fail: Error applying patch @//third_party/patches/opencensus-go-exporter-stackdriver:opencensus-stackdriver-interval.patch:
INFO: Repository go_googleapis instantiated at:
  C:/src/reclient/WORKSPACE:166:22: in <toplevel>
  C:/msys64/home/kschzt/_bazel_kschzt/sd2lufjt/external/io_bazel_rules_go/go/private/repositories.bzl:247:12: in go_rules_dependencies
  C:/msys64/home/kschzt/_bazel_kschzt/sd2lufjt/external/io_bazel_rules_go/go/private/repositories.bzl:297:18: in _maybe
Repository rule http_archive defined at:
  C:/msys64/home/kschzt/_bazel_kschzt/sd2lufjt/external/bazel_tools/tools/build_defs/repo/http.bzl:372:31: in <toplevel>
INFO: repository @go_googleapis' used the following cache hits instead of downloading the corresponding file.
 * Hash '73831cbb41f2750f3181d126bbabcd3e58b5188e131ecbc309793fa54d5439c9' for https://mirror.bazel.build/github.com/googleapis/googleapis/archive/53377c165584e84c410a0905d9effb3fe5df2806.zip
If the definition of 'repository @go_googleapis' was updated, verify that the hashes were also updated.
ERROR: C:/src/reclient/internal/pkg/monitoring/BUILD.bazel:3:11: //internal/pkg/monitoring:monitoring depends on @io_opencensus_go_contrib_exporter_stackdriver//:stackdriver in repository @io_opencensus_go_contrib_exporter_stackdriver which failed to fetch. no such package '@io_opencensus_go_contrib_exporter_stackdriver//': Error applying patch @//third_party/patches/opencensus-go-exporter-stackdriver:opencensus-stackdriver-interval.patch:
ERROR: Analysis of target '//cmd/metricsuploader:metricsuploader_lib' failed; build aborted:
INFO: Elapsed time: 2.602s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (13 packages loaded, 192 targets configured)
    Fetching C:/msys64/home/kschzt/_bazel_kschzt/sd2lufjt/external/go_googleapis; Extracting 53377c165584e84c410a0905d9effb3fe5df2806.zip
    Fetching repository @com_github_google_pprof; running Gazelle
    Fetching repository @org_golang_google_api; starting
    Fetching repository @llvm-project; starting
    Fetching repository @com_github_karrick_godirwalk; running Gazelle

@kschzt kschzt changed the title Compilation fails in patching on Windows Build fails in patching on Windows Dec 6, 2023
@gkousik
Copy link
Collaborator

gkousik commented Jan 12, 2024

I tried to reproduce this on my machine, but I've so far not been able to hit an error in applying the patch.

Also, I just wanted to comment on:

This is after installing GNU patch and hardcoding the Python3 path:

The .bazelrc file is setup to work with msys2 / mingw64 version of tools (and this is also what I tested with). This is a remote possibility, but do you refer to https://packages.msys2.org/package/patch when you say GNU patch tool? https://packages.msys2.org/package/patch is what we use in our setup for applying the patches.

@daniel-sudz
Copy link
Contributor

I have reproduced the patch crash building with mysys2/mingw64. Pasting Dockerfile for reference:

FROM mcr.microsoft.com/windows/servercore:ltsc2022

RUN reg add HKLM\SYSTEM\CurrentControlSet\Control\FileSystem /v LongPathsEnabled /t REG_DWORD /d 1 /f

RUN powershell `
    Set-ExecutionPolicy Bypass -Scope Process -Force; `
    [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; `
    iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

# Required for building the Goma client.
RUN choco install -y visualstudio2019buildtools `
    && choco install -y visualstudio2019-workload-vctools --params "--no-includeRecommended --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows10SDK.20348" `
    && "C:\ProgramData\Package Cache\{63ca8fb0-603f-4442-aa8b-48659a9338f5}\winsdksetup.exe" /features OptionId.WindowsDesktopDebuggers /q /norestart

RUN choco install -y git `
    && "C:\Program Files\Git\cmd\git.exe" config --system core.autocrlf false `
    && "C:\Program Files\Git\cmd\git.exe" config --system core.longpaths true

RUN choco install -y bazelisk
RUN choco install -y python3

RUN choco install -y msys2 && del /f /s /q "C:\$Recycle.Bin" `
    && C:\tools\msys64\usr\bin\bash.exe -lc "pacman -S --noconfirm base-devel mingw-w64-x86_64-gcc" `
    && setx /M PATH "C:\tools\msys64\usr\bin;%PATH%;C:\tools\msys64\mingw64\bin"

# HACK: Copy the MINGW64 DLLs to the Windows system directory. This is required
# for the Protobuf compiler to work, since it uses the MINGW64 toolchain.
RUN cd /d C:\tools\msys64\mingw64\bin `
    && copy libwinpthread-1.dll C:\Windows\System32\ `
    && copy "libstdc++-6.dll" C:\Windows\System32\ `
    && copy libgcc_s_seh-1.dll C:\Windows\System32\

looking into it. @gkousik is there a reference windows build that you would be willing to share?

@daniel-sudz
Copy link
Contributor

full traceback:

ERROR: An error occurred during the fetch of repository 'io_opencensus_go_contrib_exporter_stackdriver':
   Traceback (most recent call last):
        File "C:/users/t-danielsu/_bazel_t-danielsu/sd2lufjt/external/bazel_gazelle/internal/go_repository.bzl", line 311, column 10, in _go_repository_impl
                patch(ctx)
        File "C:/users/t-danielsu/_bazel_t-danielsu/sd2lufjt/external/bazel_gazelle/internal/go_repository.bzl", line 563, column 17, in patch
                fail("Error applying patch %s:\n%s%s" %
Error in fail: Error applying patch @//third_party/patches/opencensus-go-exporter-stackdriver:opencensus-stackdriver-interval.patch:
<3>WSL (549) ERROR: CreateProcessEntryCommon:505: execvpe /bin/bash failed 2
<3>WSL (549) ERROR: CreateProcessEntryCommon:508: Create process not expected to return
ERROR: C:/src/reclient/WORKSPACE:372:14: fetching go_repository rule //external:io_opencensus_go_contrib_exporter_stackdriver: Traceback (most recent call last):
        File "C:/users/t-danielsu/_bazel_t-danielsu/sd2lufjt/external/bazel_gazelle/internal/go_repository.bzl", line 311, column 10, in _go_repository_impl
                patch(ctx)
        File "C:/users/t-danielsu/_bazel_t-danielsu/sd2lufjt/external/bazel_gazelle/internal/go_repository.bzl", line 563, column 17, in patch
                fail("Error applying patch %s:\n%s%s" %
Error in fail: Error applying patch @//third_party/patches/opencensus-go-exporter-stackdriver:opencensus-stackdriver-interval.patch:
<3>WSL (549) ERROR: CreateProcessEntryCommon:505: execvpe /bin/bash failed 2
<3>WSL (549) ERROR: CreateProcessEntryCommon:508: Create process not expected to return
ERROR: C:/src/reclient/internal/pkg/monitoring/BUILD.bazel:3:11: //internal/pkg/monitoring:monitoring depends on @io_opencensus_go_contrib_exporter_stackdriver//:stackdriver in repository @io_opencensus_go_contrib_exporter_stackdriver which failed to fetch. no such package '@io_opencensus_go_contrib_exporter_stackdriver//': Error applying patch @//third_party/patches/opencensus-go-exporter-stackdriver:opencensus-stackdriver-interval.patch:
<3>WSL (549) ERROR: CreateProcessEntryCommon:505: execvpe /bin/bash failed 2
<3>WSL (549) ERROR: CreateProcessEntryCommon:508: Create process not expected to return

@daniel-sudz
Copy link
Contributor

@kschzt did you ever find a resolution?

@daniel-sudz daniel-sudz mentioned this issue May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants