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

Use the new singlejar on Windows #2241

Closed
cushon opened this issue Dec 14, 2016 · 36 comments
Closed

Use the new singlejar on Windows #2241

cushon opened this issue Dec 14, 2016 · 36 comments
Assignees
Labels
area-Windows Windows-specific issues and feature requests P2 We'll consider working on this in future. (Assignee optional) platform: windows team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website
Milestone

Comments

@cushon
Copy link
Contributor

cushon commented Dec 14, 2016

The Java implementation of singlejar has been replaced by a faster c++ implementation everywhere except Bazel on Windows.

We should use the c++ implementation on Windows, and remove support for the Java singlejar:

@katre katre added category: rules > java P2 We'll consider working on this in future. (Assignee optional) labels Dec 14, 2016
@dslomov dslomov added this to the 0.6 milestone Dec 15, 2016
@xingao267
Copy link
Member

The cc implementation of singlejar actually hasn't been enabled yet. I'm enabling it except on Windows in https://bazel-review.googlesource.com/#/c/11530.

I tried to enable it on Windows in patch set 3 https://bazel-review.googlesource.com/#/c/11530/3. The CI failed on Windows, and here is the error message:

ERROR: C:/jenkins/workspace/gerrit-bazel-tests/bazel_version/latest/platform_name/windows-x86_64/src/tools/singlejar/BUILD:263:1: C++ compilation of rule '//src/tools/singlejar:input_jar' failed: msvc_cl.bat failed: error executing command
cd C:/bazel_ci/temp/_bazel_system/rvhmt5ue/execroot/windows-x86_64
SET INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE;C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um;C:\Program Files (x86)\Windows Kits\8.1\include\shared;C:\Program Files (x86)\Windows Kits\8.1\include\um;C:\Program Files (x86)\Windows Kits\8.1\include\winrt;C:/python_27_amd64/files/include
SET LIB=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\LIB\amd64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x64;C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64;C:/python_27_amd64/files/libs
SET PATH=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\MSBuild\14.0\bin\amd64;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64;C:\windows\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\VCPackages;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools;C:\Program Files (x86)\HTML Help Workshop;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Performance Tools\x64;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Performance Tools;C:\Program Files (x86)\Windows Kits\8.1\bin\x64;C:\Program Files (x86)\Windows Kits\8.1\bin\x86;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64;c:\tools\msys64\usr\bin;c:\windows\system32;c:\windows;c:\windows\system32\wbem;c:\windows\system32\windowspowershell\v1.0;c:\program files (x86)\google\cloud sdk\google-cloud-sdk\bin;c:\program files\google\compute engine\sysprep;c:\program files\google\compute engine\metadata_scripts;c:\program files (x86)\windows kits\8.1\windows performance toolkit;c:\programdata\chocolatey\bin;c:\programdata\chocolatey\bin;c:\python_27_amd64\files;c:\program files\java\jdk1.8.0_121\bin;C:\windows\system32
SET PWD=/proc/self/cwd
SET TMP=c:\windows\temp
SET TMPDIR=c:\bazel_ci\temp
external/local_config_cc/wrapper/bin/msvc_cl.bat /DOS_WINDOWS=OS_WINDOWS /DCOMPILER_MSVC /DNOGDI /DNOMINMAX /DPRAGMA_SUPPORTED /D_WIN32_WINNT=0x0600 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS /D_USE_MATH_DEFINES /bigobj /Zm500 /J /Gy /GF /W3 /EHsc /wd4351 /wd4291 /wd4250 /wd4996 -Xcompilation-mode=fastbuild -w /nologo /I. /Ibazel-out/msvc_x64-fastbuild/genfiles /Iexternal/bazel_tools /Ibazel-out/msvc_x64-fastbuild/genfiles/external/bazel_tools /Iexternal/bazel_tools/tools/cpp/gcc3 /showIncludes /MT /Od /Z7 /c src/tools/singlejar/input_jar.cc /Fobazel-out/msvc_x64-fastbuild/bin/src/tools/singlejar/_objs/input_jar/src/tools/singlejar/input_jar.o: com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 2.
C:\bazel_ci\temp_bazel_system\rvhmt5ue\execroot\windows-x86_64\src/tools/singlejar/diag.h(29): fatal error C1189: #error: Unknown platformC:\bazel_ci\temp_bazel_system\rvhmt5ue\execroot\windows-x86_64\src/tools/singlejar/diag.h(29): fatal error C1189: #error: Unknown platform
Target //src:bazel failed to build

It complains that windows is an unknown platform at this line. https://github.com/bazelbuild/bazel/blob/master/src/tools/singlejar/diag.h#L29

@laszlocsomor
Copy link
Contributor

For the record, 3 reasons why SingleJar doesn't work on Windows:

@ddwolf
Copy link

ddwolf commented Oct 31, 2017

is there updates about this?

@laszlocsomor
Copy link
Contributor

Hey, no updates.

@dslomov: we need to set a priority for this bug and put it on our OKRs. Without having looked at the actual state of the code and just speaking from experience, I guess the migration would take me one or two weeks.

@cushon: is there any deadline for Bazel-on-Windows to move away from the Java implementation?

@cushon
Copy link
Contributor Author

cushon commented Nov 8, 2017

@laszlocsomor from my perspective it would be nice to have a single implementation when we're doing maintenance or adding new features, but I don't know of a particular deadline.

@laszlocsomor
Copy link
Contributor

laszlocsomor commented Nov 15, 2017

I found out today that the Android rules in Bazel use a new feature of the C++ SingleJar that the Java SingleJar doesn't support. We'll need to reconsider the priority of this issue. /cc @dslomov

@aj-michael
Copy link
Contributor

Regarding the Android feature, we could add that to the java singlejar (and in fact I believe there is an internal pending CL to do so). However, that feature is only enabled internally for now for some reasons dealing with remote execution.

So I don’t think that should impact the priority of this work

@xingao267
Copy link
Member

Yea the feature is only enabled internally because it breaks remote execution. It won't be added to Bazel until recursive workspaces become supported.

bazel-io pushed a commit that referenced this issue Feb 14, 2018
We can now compile
//src/tools/singlejar:token_stream on Windows.

See #2241

Change-Id: I98f86e608e5ebaf685e4de26b2dabe75fcca78d2
PiperOrigin-RevId: 185655986
@laszlocsomor
Copy link
Contributor

laszlocsomor commented May 16, 2018

Status update: I'm not actively working on this, even though it's blocking #4148. I'm currently focused on #4460, #4292, and #4319, which all seem to be more important. I'm waiting for replies to #4148 (comment) in determining whether to try and focus on this issue again.

@rongjiecomputer
Copy link
Contributor

@laszlocsomor I currently have some patches locally that allows singlejar.exe to build, I cannot verify if it works at all yet since I don't know what it does, so I will be trying to port the tests too after I upstreamed some patches.

Porting the tests seems more challenging than porting singlejar itself. The tests are sprinkled with some bash commands inside C++ code (like running unzip). If the tests are to work on Windows, C++ code needs to know where bash is located to wrap those commands. I am not sure if borrowing code from //src/tools/launcher just to figure out where is bash is the right thing to do. Is there any other option?

Is singlejar only used for Android development?

@laszlocsomor
Copy link
Contributor

laszlocsomor commented Jul 2, 2018

@laszlocsomor I currently have some patches locally that allows singlejar.exe to build, I cannot verify if it works at all yet since I don't know what it does, so I will be trying to port the tests too after I upstreamed some patches.

Thanks!

Porting the tests seems more challenging than porting singlejar itself. The tests are sprinkled with some bash commands inside C++ code (like running unzip). If the tests are to work on Windows, C++ code needs to know where bash is located to wrap those commands. I am not sure if borrowing code from //src/tools/launcher just to figure out where is bash is the right thing to do. Is there any other option?

Yes, there's a better option:

  • wrap unzip in a sh_binary:

    sh_binary(
        name = "unzip",
        srcs = ["unzip.sh"],
    )
    

    unzip.sh:

    unzip $*
    
  • make that sh_binary a data-dependency of the C++ test

  • use the C++ runfiles library to look up this sh_binary's path at runtime, run that instead of naked unzip (which just hopes "unzip.exe" is on the path)

Is singlejar only used for Android development?

Hm, I don't know. Why do you ask?

@rongjiecomputer
Copy link
Contributor

Thanks for solution about C++ runfiles library!

Is singlejar only used for Android development?

Hm, I don't know. Why do you ask?

I was thinking about testing singlejar.exe directly. But then again, I don't normally code in Java, so this question does not matter anymore.

@laszlocsomor
Copy link
Contributor

laszlocsomor commented Jul 2, 2018

Thanks for solution about C++ runfiles library!

You're welcome! Keep in mind that this isn't a perfect solution, it just encapsulates the problem.
sh_binary is non-hermetic as it assumes unzip being on the PATH, but we are at least aware of it (#5265) and with this encapsulation you can make progress on porting the test.

bazel-io pushed a commit that referenced this issue Jul 3, 2018
`setbuffer` is not available on MSVC, use C-standard `setvbuf` from `stdio.h` instead.

`setbuffer` was introduced in b4cf5e3.

#2241 /cc @laszlocsomor

Closes #5500.

PiperOrigin-RevId: 203083781
bazel-io pushed a commit that referenced this issue Oct 9, 2018
bazel-io pushed a commit that referenced this issue Oct 15, 2018
- Port various functions in `test_util` to Windows.
- Change `@local_jdk//:jdk-default` (target does not seem to exist) to `@local_jdk//:jdk`.

See #2241

Closes #6248.

PiperOrigin-RevId: 217138180
laszlocsomor added a commit to laszlocsomor/bazel that referenced this issue Oct 16, 2018
I introduced these problems while editing the
Google-internal copy of bazelbuild#6248
that was later pushed as bazelbuild@68611b3.

See bazelbuild#2241

Change-Id: Icd981a0fcdcd451a00cbb2babd107f7abb4d5170
bazel-io pushed a commit that referenced this issue Oct 16, 2018
I introduced these problems while editing the
Google-internal copy of #6248
that was later pushed as 68611b3.

See #2241

Change-Id: Icd981a0fcdcd451a00cbb2babd107f7abb4d5170

Closes #6404.

Change-Id: I33cc9c5890ec5236e7964846c158628c947c715d
PiperOrigin-RevId: 217304415
laszlocsomor added a commit to laszlocsomor/bazel that referenced this issue Oct 25, 2018
See bazelbuild#2241

Change-Id: Ic41645497e1feeb42eb726ada3417900ef239bb6
@laszlocsomor
Copy link
Contributor

@rongjiecomputer : thanks for you awesome contributions! What's the status of the porting? IIUC SingleJar itself is fully ported, and most of the tests too, right? Btw, I just found #6512, and just sent out #6513

@rongjiecomputer
Copy link
Contributor

rongjiecomputer commented Oct 25, 2018

SingleJar itself is indeed fully ported. desugar_checking (depended by singlejar_local) can only be built with Bazel that includes 914b4ce (see #6292).

I will need to rebase #6251 and fix a few stuffs before saying that all singlejar tests pass (since my previous PR was changed quite a bit). Should I wait for #6513 to be imported first?

@laszlocsomor
Copy link
Contributor

Thanks for the update! If you can wait for #6513, that won't hurt, though you can also do it without I guess. But it'll be merged in 1-2 hours anyway.

bazel-io pushed a commit that referenced this issue Oct 26, 2018
See #2241

Change-Id: Ic41645497e1feeb42eb726ada3417900ef239bb6

Closes #6513.

Change-Id: Ic41645497e1feeb42eb726ada3417900ef239bb6
PiperOrigin-RevId: 218839870
bazel-io pushed a commit that referenced this issue Nov 2, 2018
bazel-io pushed a commit that referenced this issue Nov 6, 2018
See #2241

Closes #6608.

PiperOrigin-RevId: 220267534
@rongjiecomputer
Copy link
Contributor

Native SingleJar is enabled for Windows in master branch. For people who are currently being blocked by this issue, please build Bazel at HEAD and test things out!

@laszlocsomor
Copy link
Contributor

This is fantastic news. Thank you for all your efforts @rongjiecomputer , I'm really pleased to see this getting resolved! By using the native SingleJar on Windows we can finally drop the old Java implementation and bring the Android rule support on Windows up to par with Linux and macOS.

Thank you so much!

@laszlocsomor
Copy link
Contributor

I think c557399 resolves this issue.

@philwo philwo added the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Jun 15, 2020
bazel-io pushed a commit that referenced this issue Nov 6, 2021
Removal is now possible since the following issues are resolved:
#2241
#7365

PiperOrigin-RevId: 408004890
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Windows Windows-specific issues and feature requests P2 We'll consider working on this in future. (Assignee optional) platform: windows team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website
Projects
None yet
Development

No branches or pull requests