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

windows launcher: Make the launcher compile under mingw #24752

Closed
wants to merge 1 commit into from

Conversation

BoleynSu
Copy link
Contributor

TEST: bazel build --platforms=//:windows_x86_64 --extra_toolchains=@llvm_mingw_linux_x86_64//:cc-toolchain-linux_x86_64-windows_x86_64 //src/tools/launcher:launcher

@github-actions github-actions bot added the awaiting-review PR is awaiting review from an assigned reviewer label Dec 18, 2024
# TODO(#8303): Mac crosstool should also declare every feature.
if is_linux:
# Linux artifact name patterns are the default.
artifact_name_patterns = [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is forked from rules_cc with only diff being adding .exe extension for binaries.

@BoleynSu
Copy link
Contributor Author

@fmeum @meteorcloudy sorry for not properly testing my last PR #24725. I only check https://godbolt.org/z/f35j3M4x9 compile but std::wofstream jar_manifest_file(std::filesystem::path(jar_manifest_file_path)); does not really declare jar_manifest_file as wofstream but a function.
This is a more complete PR that I have verified to work by adding a mingw toolchain.

int wmain(int argc, wchar_t* argv[]) {
#else
int main() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mingw requires linkopt -municode to use wmain.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add this comment in the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will do it later. I am on a train currently.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments added. PTAL.

@@ -250,7 +250,7 @@ wstring JavaBinaryLauncher::CreateClasspathJar(const wstring& classpath) {
binary_base_path + rand_id + L".jar_manifest";
blaze_util::AddUncPrefixMaybe(&jar_manifest_file_path);
#if (__cplusplus >= 201703L)
wofstream jar_manifest_file(std::filesystem::path(jar_manifest_file_path));
wofstream jar_manifest_file{std::filesystem::path(jar_manifest_file_path)};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to use curly brackets here to declare a variable.

@BoleynSu BoleynSu changed the title windows launcher: Make the launcer compile under mingw windows launcher: Make the launcher compile under mingw Dec 19, 2024
@BoleynSu BoleynSu force-pushed the patch-4 branch 2 times, most recently from e4d7f2f to f0401ef Compare December 19, 2024 01:37
@sgowroji sgowroji added the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Dec 19, 2024
@meteorcloudy
Copy link
Member

third_party/llvm_mingw/cc_toolchain_config.bzl

I'm fine with tweaking the launcher code to allow it build with mingw, but it's not ideal to check in more toolchain config files in Bazel code base. Can you put it your own repo and reference it as needed?

@BoleynSu BoleynSu force-pushed the patch-4 branch 2 times, most recently from bf26bcc to d660e51 Compare December 19, 2024 11:45
@BoleynSu
Copy link
Contributor Author

Removed the changes to add a mingw cc toolchain

@fmeum
Copy link
Collaborator

fmeum commented Dec 19, 2024

@bazel-io fork 8.0.1

@fmeum
Copy link
Collaborator

fmeum commented Dec 19, 2024

@bazel-io fork 7.5.0

@fmeum
Copy link
Collaborator

fmeum commented Dec 19, 2024

@bazel-io fork 8.1.0

@meteorcloudy meteorcloudy added awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally and removed awaiting-review PR is awaiting review from an assigned reviewer labels Dec 20, 2024
@copybara-service copybara-service bot closed this in a4bb254 Jan 2, 2025
@github-actions github-actions bot removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Jan 2, 2025
bazel-io pushed a commit to bazel-io/bazel that referenced this pull request Jan 2, 2025
TEST: bazel build --platforms=//:windows_x86_64  --extra_toolchains=@llvm_mingw_linux_x86_64//:cc-toolchain-linux_x86_64-windows_x86_64 //src/tools/launcher:launcher

Closes bazelbuild#24752.

PiperOrigin-RevId: 711358608
Change-Id: Iedacad9b959427ed5d4598e0ea594cb25b8845c8
github-merge-queue bot pushed a commit that referenced this pull request Jan 2, 2025
TEST: bazel build --platforms=//:windows_x86_64
--extra_toolchains=@llvm_mingw_linux_x86_64//:cc-toolchain-linux_x86_64-windows_x86_64
//src/tools/launcher:launcher

Closes #24752.

PiperOrigin-RevId: 711358608
Change-Id: Iedacad9b959427ed5d4598e0ea594cb25b8845c8

Commit
a4bb254

Co-authored-by: Boleyn Su <boleyn.su@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants