diff --git a/overlay/MANIFEST b/overlay/MANIFEST index 7dd79e5..c72fff7 100644 --- a/overlay/MANIFEST +++ b/overlay/MANIFEST @@ -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 diff --git a/overlay/MODULE.bazel b/overlay/MODULE.bazel index e667ea1..bbaeed5 100644 --- a/overlay/MODULE.bazel +++ b/overlay/MODULE.bazel @@ -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") diff --git a/overlay/bazel/public-patches/llvm_windows_target_triple.patch b/overlay/bazel/public-patches/llvm_windows_target_triple.patch new file mode 100644 index 0000000..d14acfe --- /dev/null +++ b/overlay/bazel/public-patches/llvm_windows_target_triple.patch @@ -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"),