Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions overlay/MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ new - bazel/public-patches/curl_private_lib_includes.patch
new - bazel/public-patches/google_benchmark_gnu_driver_flags.patch
new - bazel/public-patches/llvm_windows_absolute_symlinks.patch
new - bazel/public-patches/llvm_windows_stack_flag.patch
new - bazel/public-patches/llvm_windows_target_triple.patch
new - bazel/public-patches/mimalloc.BUILD
new - bazel/public-patches/protobuf_windows_link_libs.patch
new - bazel/public-patches/rules_cc_copy_dynamic_libraries_same_package.patch
Expand Down
1 change: 1 addition & 0 deletions overlay/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ llvm_source = use_extension("//bazel/public-patches:llvm_source.bzl", "llvm_sour
llvm_source.configure(extra_patches = [
"//bazel/public-patches:llvm_windows_stack_flag.patch",
"//bazel/public-patches:llvm_windows_absolute_symlinks.patch",
"//bazel/public-patches:llvm_windows_target_triple.patch",
])

use_repo(llvm_source, "llvm-raw")
Expand Down
26 changes: 26 additions & 0 deletions overlay/bazel/public-patches/llvm_windows_target_triple.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--- a/utils/bazel/llvm-project-overlay/llvm/config.bzl
+++ b/utils/bazel/llvm-project-overlay/llvm/config.bzl
@@ -144,7 +144,22 @@
Label("//llvm:is_aarch64_windows_clang_mingw"): native_arch_defines("AArch64", "aarch64-w64-windows-gnu"),
Label("//llvm:is_aarch64_windows_clang_cl"): native_arch_defines("AArch64", "aarch64-pc-windows-msvc"),
Label("//llvm:is_aarch64_windows_msvc"): native_arch_defines("AArch64", "aarch64-pc-windows-msvc"),
- Label("//llvm:is_x86_64_windows_clang_mingw"): native_arch_defines("X86", "x86_64-w64-windows-gnu"),
+ # The name of this arm says mingw, but the condition underneath it is just
+ # "Windows, and the compiler is clang", which is us. We are clang driving
+ # lld-link with --target=x86_64-pc-windows-msvc against a Microsoft sysroot,
+ # and the pair of triples this bakes in is the only thing in the whole build
+ # that says GNU.
+ #
+ # They are what the compiler falls back on when nothing on the command line
+ # names a target, which is the case for mojo run. The code it generates then
+ # asks for ___chkstk_ms and __main, which are libgcc and mingw entry points,
+ # and the JIT cannot resolve them because a Windows machine has no reason to
+ # have either one.
+ #
+ # Only the x86_64 arm is touched. The aarch64 one above has the same problem,
+ # but nothing here builds for that target, so there is no way to find out
+ # whether it is the only thing wrong with it.
+ Label("//llvm:is_x86_64_windows_clang_mingw"): native_arch_defines("X86", "x86_64-pc-windows-msvc"),
Label("//llvm:darwin_arm64"): native_arch_defines("AArch64", "arm64-apple-darwin"),
Label("//llvm:darwin_x86_64"): native_arch_defines("X86", "x86_64-unknown-darwin"),
Label("//llvm:linux_aarch64"): native_arch_defines("AArch64", "aarch64-unknown-linux-gnu"),