diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index fd2a944c73..e21de6449b 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -70,81 +70,11 @@ jobs: run: | bazel_targets=( //... - # Keep V8 out of the ordinary Bazel CI path. Only the dedicated - # canary and release workflows should build `third_party/v8`. + # Keep standalone V8 library targets out of the ordinary Bazel CI + # path. V8 consumers under `//codex-rs/...` still participate + # transitively through `//...`. -//third_party/v8:all ) - if [[ "${RUNNER_OS:-}" == "Windows" ]]; then - # This is intentionally a foothold rather than the final Windows - # Bazel suite. Keep a stable set of targets that are known not to - # pull in the unresolved V8 dependency so we can land meaningful CI - # coverage now and expand it once the V8 situation is understood. - bazel_targets=( - //codex-rs/analytics:analytics-unit-tests - //codex-rs/ansi-escape:ansi-escape-unit-tests - //codex-rs/app-server-protocol:app-server-protocol-schema_fixtures-test - //codex-rs/app-server-protocol:app-server-protocol-unit-tests - //codex-rs/apply-patch:apply-patch-all-test - //codex-rs/apply-patch:apply-patch-unit-tests - //codex-rs/async-utils:async-utils-unit-tests - //codex-rs/codex-api:codex-api-unit-tests - //codex-rs/codex-backend-openapi-models:codex-backend-openapi-models-unit-tests - //codex-rs/codex-client:codex-client-unit-tests - //codex-rs/codex-experimental-api-macros:codex-experimental-api-macros-unit-tests - //codex-rs/config:config-unit-tests - //codex-rs/connectors:connectors-unit-tests - //codex-rs/core-skills:core-skills-unit-tests - //codex-rs/exec-server:exec-server-unit-tests - //codex-rs/execpolicy-legacy:execpolicy-legacy-all-test - //codex-rs/execpolicy-legacy:execpolicy-legacy-unit-tests - //codex-rs/execpolicy:execpolicy-unit-tests - //codex-rs/features:features-unit-tests - //codex-rs/feedback:feedback-unit-tests - //codex-rs/file-search:file-search-unit-tests - //codex-rs/git-utils:git-utils-unit-tests - //codex-rs/hooks:hooks-unit-tests - //codex-rs/instructions:instructions-unit-tests - //codex-rs/keyring-store:keyring-store-unit-tests - //codex-rs/network-proxy:network-proxy-unit-tests - //codex-rs/otel:otel-unit-tests - //codex-rs/plugin:plugin-unit-tests - //codex-rs/process-hardening:process-hardening-unit-tests - //codex-rs/protocol:protocol-unit-tests - //codex-rs/responses-api-proxy:responses-api-proxy-unit-tests - //codex-rs/rmcp-client:rmcp-client-unit-tests - //codex-rs/rollout:rollout-unit-tests - //codex-rs/sandboxing:sandboxing-unit-tests - //codex-rs/secrets:secrets-unit-tests - //codex-rs/shell-escalation:shell-escalation-unit-tests - //codex-rs/skills:skills-unit-tests - //codex-rs/state:state-unit-tests - //codex-rs/stdio-to-uds:stdio-to-uds-unit-tests - //codex-rs/terminal-detection:terminal-detection-unit-tests - //codex-rs/tools:tools-unit-tests - //codex-rs/utils/absolute-path:absolute-path-unit-tests - //codex-rs/utils/approval-presets:approval-presets-unit-tests - //codex-rs/utils/cache:cache-unit-tests - //codex-rs/utils/cargo-bin:cargo-bin-unit-tests - //codex-rs/utils/cli:cli-unit-tests - //codex-rs/utils/elapsed:elapsed-unit-tests - //codex-rs/utils/fuzzy-match:fuzzy-match-unit-tests - //codex-rs/utils/home-dir:home-dir-unit-tests - //codex-rs/utils/image:image-unit-tests - //codex-rs/utils/json-to-toml:json-to-toml-unit-tests - //codex-rs/utils/output-truncation:output-truncation-unit-tests - //codex-rs/utils/path-utils:path-utils-unit-tests - //codex-rs/utils/plugins:plugins-unit-tests - //codex-rs/utils/pty:pty-unit-tests - //codex-rs/utils/readiness:readiness-unit-tests - //codex-rs/utils/rustls-provider:rustls-provider-unit-tests - //codex-rs/utils/sleep-inhibitor:sleep-inhibitor-unit-tests - //codex-rs/utils/stream-parser:stream-parser-unit-tests - //codex-rs/utils/string:string-unit-tests - //codex-rs/utils/template:template-unit-tests - //codex-rs/windows-sandbox-rs:windows-sandbox-rs-unit-tests - ) - echo "Windows smoke target count: ${#bazel_targets[@]}" - fi ./.github/scripts/run-bazel-ci.sh \ --print-failed-test-logs \ diff --git a/MODULE.bazel b/MODULE.bazel index 9402254d89..63a86bf830 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -3,6 +3,25 @@ module(name = "codex") bazel_dep(name = "bazel_skylib", version = "1.8.2") bazel_dep(name = "platforms", version = "1.0.0") bazel_dep(name = "llvm", version = "0.6.8") +# The upstream LLVM archive contains a few unix-only symlink entries and is +# missing a couple of MinGW compatibility archives that windows-gnullvm needs +# during extraction and linking, so patch it until upstream grows native support. +single_version_override( + module_name = "llvm", + patch_strip = 1, + patches = [ + "//patches:llvm_windows_symlink_extract.patch", + ], +) +# Abseil picks a MinGW pthread TLS path that does not match our hermetic +# windows-gnullvm toolchain; force it onto the portable C++11 thread-local path. +single_version_override( + module_name = "abseil-cpp", + patch_strip = 1, + patches = [ + "//patches:abseil_windows_gnullvm_thread_identity.patch", + ], +) register_toolchains("@llvm//toolchain:all") @@ -44,8 +63,9 @@ bazel_dep(name = "apple_support", version = "2.1.0") bazel_dep(name = "rules_cc", version = "0.2.16") bazel_dep(name = "rules_platform", version = "0.1.0") bazel_dep(name = "rules_rs", version = "0.0.43") -# `rules_rs` 0.0.43 does not model `x86_64-pc-windows-gnullvm` as a distinct -# Windows exec platform, so patch it until upstream grows that support. +# `rules_rs` 0.0.43 does not model `windows-gnullvm` as a distinct Windows exec +# platform, so patch it until upstream grows that support for both x86_64 and +# aarch64. single_version_override( module_name = "rules_rs", patch_strip = 1, @@ -84,10 +104,15 @@ crate.from_cargo( "aarch64-unknown-linux-gnu", "aarch64-unknown-linux-musl", "aarch64-apple-darwin", + # Keep both Windows ABIs in the generated Cargo metadata: the V8 + # experiment still consumes release assets that only exist under the + # MSVC names while targeting the GNU toolchain. + "aarch64-pc-windows-msvc", "aarch64-pc-windows-gnullvm", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-apple-darwin", + "x86_64-pc-windows-msvc", "x86_64-pc-windows-gnullvm", ], use_experimental_platforms = True, diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index e9a1c2a99e..9e7ff69455 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -1576,6 +1576,7 @@ }, "@@rules_rs+//rs/experimental/toolchains:module_extension.bzl%toolchains": { "cargo-1.93.0-aarch64-apple-darwin.tar.xz": "6443909350322ad07f09bb5edfd9ff29268e6fe88c7d78bfba7a5e254248dc25", + "cargo-1.93.0-aarch64-pc-windows-gnullvm.tar.xz": "387832b989c8eb96c9ebd66402a87962167633bc6d91a49ffb8c7903c45f3476", "cargo-1.93.0-aarch64-pc-windows-msvc.tar.xz": "155bff7a16aa7054e7ed7c3a82e362d4b302b3882d751b823e06ff63ae3f103d", "cargo-1.93.0-aarch64-unknown-linux-gnu.tar.xz": "5998940b8b97286bb67facb1a85535eeb3d4d7a61e36a85e386e5c0c5cfe5266", "cargo-1.93.0-x86_64-apple-darwin.tar.xz": "95a47c5ed797c35419908f04188d8b7de09946e71073c4b72632b16f5b10dfae", @@ -1583,6 +1584,7 @@ "cargo-1.93.0-x86_64-pc-windows-msvc.tar.xz": "e59c5e2baa9ec17261f2cda6676ebf7b68b21a860e3f7451c4d964728951da75", "cargo-1.93.0-x86_64-unknown-linux-gnu.tar.xz": "c23de3ae709ff33eed5e4ae59d1f9bcd75fa4dbaa9fb92f7b06bfb534b8db880", "clippy-1.93.0-aarch64-apple-darwin.tar.xz": "0b6e943a8d12be0e68575acf59c9ea102daf795055fcbbf862b0bfd35ec40039", + "clippy-1.93.0-aarch64-pc-windows-gnullvm.tar.xz": "296949f49be2de77ce9d1c5023a5f0a58e28e329eec03642a3da0e175a67beeb", "clippy-1.93.0-aarch64-pc-windows-msvc.tar.xz": "07bcf2edb88cdf5ead2f02e4a8493e9b0ef935a31253fac6f9f3378d8023f113", "clippy-1.93.0-aarch64-unknown-linux-gnu.tar.xz": "872ae6d68d625946d281b91d928332e6b74f6ab269b6af842338df4338805a60", "clippy-1.93.0-x86_64-apple-darwin.tar.xz": "e6d0b1afb9607c14a1172d09ee194a032bbb3e48af913d55c5a473e0559eddde", @@ -1655,6 +1657,7 @@ "rust-std-1.93.0-x86_64-unknown-none.tar.xz": "01dcca7ae4b7e82fbfa399adb5e160afaa13143e5a17e1e0737c38cf07365fb3", "rust-std-1.93.0-x86_64-unknown-uefi.tar.xz": "ec4e439d9485ce752b56999e8e41ed82373fc833a005cf2531c6f7ef7e785392", "rustc-1.93.0-aarch64-apple-darwin.tar.xz": "092be03c02b44c405dab1232541c84f32b2d9e8295747568c3d531dd137221dc", + "rustc-1.93.0-aarch64-pc-windows-gnullvm.tar.xz": "d3bc0cdaf157e20b1f23e510b5e3c4c6e9117d08f5284c04dee60aecff1bc851", "rustc-1.93.0-aarch64-pc-windows-msvc.tar.xz": "a3ac1a8e411de8470f71b366f89d187718c431526912b181692ed0a18c56c7ad", "rustc-1.93.0-aarch64-unknown-linux-gnu.tar.xz": "1a9045695892ec08d8e9751bf7cf7db71fe27a6202dd12ce13aca48d0602dbde", "rustc-1.93.0-x86_64-apple-darwin.tar.xz": "594bb293f0a4f444656cf8dec2149fcb979c606260efee9e09bcf8c9c6ed6ae7", @@ -1662,6 +1665,7 @@ "rustc-1.93.0-x86_64-pc-windows-msvc.tar.xz": "fa17677eee0d83eb055b309953184bf87ba634923d8897f860cda65d55c6e350", "rustc-1.93.0-x86_64-unknown-linux-gnu.tar.xz": "00c6e6740ea6a795e33568cd7514855d58408a1180cd820284a7bbf7c46af715", "rustfmt-1.93.0-aarch64-apple-darwin.tar.xz": "0dd1faedf0768ef362f4aae4424b34e8266f2b9cf5e76ea4fcaf780220b363a0", + "rustfmt-1.93.0-aarch64-pc-windows-gnullvm.tar.xz": "5888827e7fbd7d59930870b4856fce8d6d8fca5e02f6535f8ae3d7ad0ccf2d4a", "rustfmt-1.93.0-aarch64-pc-windows-msvc.tar.xz": "24eed108489567133bbfe40c8eacda1567be55fae4c526911b39eb33eb27a6cb", "rustfmt-1.93.0-aarch64-unknown-linux-gnu.tar.xz": "92e1acb45ae642136258b4dabb39302af2d53c83e56ebd5858bc969f9e5c141a", "rustfmt-1.93.0-x86_64-apple-darwin.tar.xz": "c8453b4c5758eb39423042ffa9c23ed6128cbed2b15b581e5e1192c9cc0b1d4e", diff --git a/codex-rs/shell-command/src/command_safety/windows_safe_commands.rs b/codex-rs/shell-command/src/command_safety/windows_safe_commands.rs index aa7ff96818..e574be6a0e 100644 --- a/codex-rs/shell-command/src/command_safety/windows_safe_commands.rs +++ b/codex-rs/shell-command/src/command_safety/windows_safe_commands.rs @@ -340,6 +340,13 @@ mod tests { args.iter().map(ToString::to_string).collect() } + fn assert_unsafe_parsed_command(words: &[&str]) { + assert!( + !is_safe_powershell_command(&vec_str(words)), + "expected parsed command {words:?} to require approval", + ); + } + #[test] fn recognizes_safe_powershell_wrappers() { assert!(is_safe_command_windows(&vec_str(&[ @@ -441,136 +448,69 @@ mod tests { #[test] fn rejects_git_global_override_options() { - let Some(pwsh) = try_find_pwsh_executable_blocking() else { - return; - }; - - let pwsh: String = pwsh.as_path().to_str().unwrap().into(); - for script in [ - "git -c core.pager=cat show HEAD:foo.rs", - "git --config-env core.pager=PAGER show HEAD:foo.rs", - "git --config-env=core.pager=PAGER show HEAD:foo.rs", - "git --git-dir .evil-git diff HEAD~1..HEAD", - "git --git-dir=.evil-git diff HEAD~1..HEAD", - "git --work-tree . status", - "git --work-tree=. status", - "git --exec-path .git/helpers show HEAD:foo.rs", - "git --exec-path=.git/helpers show HEAD:foo.rs", - "git --namespace attacker show HEAD:foo.rs", - "git --namespace=attacker show HEAD:foo.rs", - "git --super-prefix attacker/ show HEAD:foo.rs", - "git --super-prefix=attacker/ show HEAD:foo.rs", + for words in [ + &["git", "-c", "core.pager=cat", "show", "HEAD:foo.rs"][..], + &[ + "git", + "--config-env", + "core.pager=PAGER", + "show", + "HEAD:foo.rs", + ][..], + &[ + "git", + "--config-env=core.pager=PAGER", + "show", + "HEAD:foo.rs", + ][..], + &["git", "--git-dir", ".evil-git", "diff", "HEAD~1..HEAD"][..], + &["git", "--git-dir=.evil-git", "diff", "HEAD~1..HEAD"][..], + &["git", "--work-tree", ".", "status"][..], + &["git", "--work-tree=.", "status"][..], + &["git", "--exec-path", ".git/helpers", "show", "HEAD:foo.rs"][..], + &["git", "--exec-path=.git/helpers", "show", "HEAD:foo.rs"][..], + &["git", "--namespace", "attacker", "show", "HEAD:foo.rs"][..], + &["git", "--namespace=attacker", "show", "HEAD:foo.rs"][..], + &["git", "--super-prefix", "attacker/", "show", "HEAD:foo.rs"][..], + &["git", "--super-prefix=attacker/", "show", "HEAD:foo.rs"][..], ] { - assert!( - !is_safe_command_windows(&[ - pwsh.clone(), - "-NoLogo".to_string(), - "-NoProfile".to_string(), - "-Command".to_string(), - script.to_string(), - ]), - "expected {script:?} to require approval due to unsafe git global option", - ); + assert_unsafe_parsed_command(words); } } #[test] - fn rejects_powershell_commands_with_side_effects() { - assert!(!is_safe_command_windows(&vec_str(&[ - "powershell.exe", - "-NoLogo", - "-Command", - "Remove-Item foo.txt", - ]))); + fn rejects_parsed_powershell_commands_with_side_effects() { + for words in [ + &["Remove-Item", "foo.txt"][..], + &["rg", "--pre", "cat"][..], + &["Set-Content", "foo.txt", "hello"][..], + &["Out-File", "y"][..], + &["Write-Output", "(Set-Content", "foo6.txt", "abc)"][..], + &["Write-Host", "(Remove-Item", "foo.txt)"][..], + &["Get-Content", "(New-Item", "bar.txt)"][..], + ] { + assert_unsafe_parsed_command(words); + } + } - assert!(!is_safe_command_windows(&vec_str(&[ - "powershell.exe", - "-NoProfile", - "-Command", - "rg --pre cat", - ]))); - - assert!(!is_safe_command_windows(&vec_str(&[ - "powershell.exe", - "-Command", - "Set-Content foo.txt 'hello'", - ]))); - - // Redirections are blocked - assert!(!is_safe_command_windows(&vec_str(&[ - "powershell.exe", - "-Command", + #[test] + fn rejects_parser_only_powershell_side_effect_patterns() { + for script in [ "echo hi > out.txt", - ]))); - assert!(!is_safe_command_windows(&vec_str(&[ - "powershell.exe", - "-Command", "Get-Content x | Out-File y", - ]))); - assert!(!is_safe_command_windows(&vec_str(&[ - "powershell.exe", - "-Command", "Write-Output foo 2> err.txt", - ]))); - - // Call operator is blocked - assert!(!is_safe_command_windows(&vec_str(&[ - "powershell.exe", - "-Command", "& Remove-Item foo", - ]))); - - // Chained safe + unsafe must fail - assert!(!is_safe_command_windows(&vec_str(&[ - "powershell.exe", - "-Command", "Get-ChildItem; Remove-Item foo", - ]))); - // Nested unsafe cmdlet inside safe command must fail - assert!(!is_safe_command_windows(&vec_str(&[ - "powershell.exe", - "-Command", - "Write-Output (Set-Content foo6.txt 'abc')", - ]))); - // Additional nested unsafe cmdlet examples must fail - assert!(!is_safe_command_windows(&vec_str(&[ - "powershell.exe", - "-Command", - "Write-Host (Remove-Item foo.txt)", - ]))); - assert!(!is_safe_command_windows(&vec_str(&[ - "powershell.exe", - "-Command", - "Get-Content (New-Item bar.txt)", - ]))); - - // Unsafe @ expansion. - assert!(!is_safe_command_windows(&vec_str(&[ - "powershell.exe", - "-Command", - "ls @(calc.exe)" - ]))); - - // Unsupported constructs that the AST parser refuses (no fallback to manual splitting). - assert!(!is_safe_command_windows(&vec_str(&[ - "powershell.exe", - "-Command", - "ls && pwd" - ]))); - - // Sub-expressions are rejected even if they contain otherwise safe commands. - assert!(!is_safe_command_windows(&vec_str(&[ - "powershell.exe", - "-Command", - "Write-Output $(Get-Content foo)" - ]))); - - // Empty words from the parser (e.g. '') are rejected. - assert!(!is_safe_command_windows(&vec_str(&[ - "powershell.exe", - "-Command", - "''" - ]))); + "ls @(calc.exe)", + "ls && pwd", + "Write-Output $(Get-Content foo)", + "''", + ] { + assert!( + !is_safe_command_windows(&vec_str(&["powershell.exe", "-Command", script,])), + "expected {script:?} to require approval", + ); + } } #[test] diff --git a/defs.bzl b/defs.bzl index 058c1906a8..fee01a151a 100644 --- a/defs.bzl +++ b/defs.bzl @@ -13,6 +13,18 @@ PLATFORMS = [ "windows_arm64", ] +# The Bazel-built windows-gnullvm binaries that pull in V8 need a larger PE +# stack reserve than the default linker setting. Thread the flag through the +# executable and test entry points so the final linked artifacts behave the same +# in normal builds and under `bazel test`. +WINDOWS_GNULLVM_RUSTC_STACK_FLAGS = select({ + "@rules_rs//rs/experimental/platforms/constraints:windows_gnullvm": [ + "-C", + "link-arg=-Wl,--stack,8388608", + ], + "//conditions:default": [], +}) + def multiplatform_binaries(name, platforms = PLATFORMS): for platform in platforms: platform_data( @@ -224,7 +236,7 @@ def codex_rust_crate( crate_root = main, deps = all_crate_deps() + maybe_deps + deps_extra, edition = crate_edition, - rustc_flags = rustc_flags_extra, + rustc_flags = rustc_flags_extra + WINDOWS_GNULLVM_RUSTC_STACK_FLAGS, srcs = native.glob(["src/**/*.rs"]), visibility = ["//visibility:public"], ) @@ -252,7 +264,7 @@ def codex_rust_crate( # Bazel has emitted both `codex-rs//...` and # `../codex-rs//...` paths for `file!()`. Strip either # prefix so Insta records Cargo-like metadata such as `core/tests/...`. - rustc_flags = rustc_flags_extra + [ + rustc_flags = rustc_flags_extra + WINDOWS_GNULLVM_RUSTC_STACK_FLAGS + [ "--remap-path-prefix=../codex-rs=", "--remap-path-prefix=codex-rs=", ], diff --git a/patches/BUILD.bazel b/patches/BUILD.bazel index f7b2aaffe9..8d4acbbb91 100644 --- a/patches/BUILD.bazel +++ b/patches/BUILD.bazel @@ -1,5 +1,7 @@ exports_files([ + "abseil_windows_gnullvm_thread_identity.patch", "aws-lc-sys_memcmp_check.patch", + "llvm_windows_symlink_extract.patch", "rules_rust_windows_gnullvm_build_script.patch", "rules_rs_windows_gnullvm_exec.patch", "rusty_v8_prebuilt_out_dir.patch", diff --git a/patches/abseil_windows_gnullvm_thread_identity.patch b/patches/abseil_windows_gnullvm_thread_identity.patch new file mode 100644 index 0000000000..27c4ecf71f --- /dev/null +++ b/patches/abseil_windows_gnullvm_thread_identity.patch @@ -0,0 +1,16 @@ +# What: avoid MinGW pthread TLS linkage in Abseil thread identity selection. +# Scope: one MinGW-specific preprocessor branch in Abseil's internal +# thread-identity mode selection; no other Abseil behavior changes. + +diff --git a/absl/base/internal/thread_identity.h b/absl/base/internal/thread_identity.h +--- a/absl/base/internal/thread_identity.h ++++ b/absl/base/internal/thread_identity.h +@@ -217,6 +217,8 @@ + #error ABSL_THREAD_IDENTITY_MODE cannot be directly set + #elif defined(ABSL_FORCE_THREAD_IDENTITY_MODE) + #define ABSL_THREAD_IDENTITY_MODE ABSL_FORCE_THREAD_IDENTITY_MODE ++#elif defined(__MINGW32__) ++#define ABSL_THREAD_IDENTITY_MODE ABSL_THREAD_IDENTITY_MODE_USE_CPP11 + #elif defined(_WIN32) && !defined(__MINGW32__) + #define ABSL_THREAD_IDENTITY_MODE ABSL_THREAD_IDENTITY_MODE_USE_CPP11 + #elif defined(__APPLE__) && defined(ABSL_HAVE_THREAD_LOCAL) diff --git a/patches/llvm_windows_symlink_extract.patch b/patches/llvm_windows_symlink_extract.patch new file mode 100644 index 0000000000..9f548636b2 --- /dev/null +++ b/patches/llvm_windows_symlink_extract.patch @@ -0,0 +1,64 @@ +diff --git a/extensions/llvm_source.bzl b/extensions/llvm_source.bzl +index 89dcf81..cf27c92 100644 +--- a/extensions/llvm_source.bzl ++++ b/extensions/llvm_source.bzl +@@ -83,6 +83,13 @@ def _llvm_source_archive_excludes(): + "offload", + "libc/docs", + "libc/utils/gn", ++ # These entries are unix symlinks in the upstream source tarball. ++ # Windows tar.exe cannot materialize them during repository extraction, ++ # but nothing in our Bazel usage needs the symlink entrypoints. ++ "llvm/utils/mlgo-utils/extract_ir.py", ++ "llvm/utils/mlgo-utils/make_corpus.py", ++ "llvm/utils/mlgo-utils/combine_training_corpus.py", ++ "llvm/docs/_themes/llvm-theme", + ] + + test_docs_subprojects = [ +diff --git a/runtimes/mingw/BUILD.bazel b/runtimes/mingw/BUILD.bazel +index ebd99db..9eb5d5b 100644 +--- a/runtimes/mingw/BUILD.bazel ++++ b/runtimes/mingw/BUILD.bazel +@@ -334,6 +334,30 @@ stub_library( + name = "stdc++", + ) + ++# Clang may inject -lssp and -lssp_nonshared for windows-gnu links. ++# Provide compatibility archives in the MinGW runtime search directory. ++stub_library( ++ name = "ssp", ++) ++ ++stub_library( ++ name = "ssp_nonshared", ++) ++ ++# Prebuilt MSVC archives can carry /DEFAULTLIB:libcmt.lib and ++# /DEFAULTLIB:oldnames.lib directives. Provide MinGW-compatible stand-ins so ++# lld can satisfy the lookup under windows-gnullvm. ++stub_library( ++ name = "libcmt", ++) ++ ++copy_file( ++ name = "oldnames", ++ src = ":moldname", ++ out = "liboldnames.a", ++ visibility = ["//visibility:public"], ++) ++ + copy_to_directory( + name = "mingw_crt_library_search_directory", + srcs = [ +@@ -344,6 +364,10 @@ copy_to_directory( + ":moldname", ++ ":oldnames", + ":pthread", + ":stdc++", ++ ":ssp", ++ ":ssp_nonshared", ++ ":libcmt", + ":ucrt", + ":ucrtbase", + ":ucrtbased", diff --git a/patches/rules_rs_windows_gnullvm_exec.patch b/patches/rules_rs_windows_gnullvm_exec.patch index 8842c3c717..9a49523b78 100644 --- a/patches/rules_rs_windows_gnullvm_exec.patch +++ b/patches/rules_rs_windows_gnullvm_exec.patch @@ -1,18 +1,25 @@ +# What: teach `rules_rs` that `windows-gnullvm` is a distinct Windows exec ABI. +# Scope: experimental platform/toolchain naming only; no Cargo target changes. + diff --git a/rs/experimental/platforms/triples.bzl b/rs/experimental/platforms/triples.bzl +index 3ca3bb1..dd15656 100644 --- a/rs/experimental/platforms/triples.bzl +++ b/rs/experimental/platforms/triples.bzl -@@ -30,6 +30,7 @@ +@@ -30,7 +30,9 @@ SUPPORTED_EXEC_TRIPLES = [ "x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu", "x86_64-pc-windows-msvc", + "x86_64-pc-windows-gnullvm", "aarch64-pc-windows-msvc", ++ "aarch64-pc-windows-gnullvm", "x86_64-apple-darwin", "aarch64-apple-darwin", + ] diff --git a/rs/experimental/toolchains/declare_rustc_toolchains.bzl b/rs/experimental/toolchains/declare_rustc_toolchains.bzl +index b9a0ce1..67e491c 100644 --- a/rs/experimental/toolchains/declare_rustc_toolchains.bzl +++ b/rs/experimental/toolchains/declare_rustc_toolchains.bzl -@@ -10,6 +10,11 @@ +@@ -10,6 +10,11 @@ def _channel(version): return "beta" return "stable" @@ -24,7 +31,7 @@ diff --git a/rs/experimental/toolchains/declare_rustc_toolchains.bzl b/rs/experi def declare_rustc_toolchains( *, version, -@@ -23,15 +28,14 @@ +@@ -23,15 +28,14 @@ def declare_rustc_toolchains( for triple in execs: exec_triple = _parse_triple(triple) @@ -43,7 +50,7 @@ diff --git a/rs/experimental/toolchains/declare_rustc_toolchains.bzl b/rs/experi version_key, ) -@@ -90,11 +94,8 @@ +@@ -90,11 +94,8 @@ def declare_rustc_toolchains( target_key = sanitize_triple(target_triple) native.toolchain( @@ -58,29 +65,25 @@ diff --git a/rs/experimental/toolchains/declare_rustc_toolchains.bzl b/rs/experi target_settings = [ "@rules_rust//rust/toolchain/channel:" + channel, diff --git a/rs/experimental/toolchains/declare_rustfmt_toolchains.bzl b/rs/experimental/toolchains/declare_rustfmt_toolchains.bzl +index a219209..ecb6b05 100644 --- a/rs/experimental/toolchains/declare_rustfmt_toolchains.bzl +++ b/rs/experimental/toolchains/declare_rustfmt_toolchains.bzl -@@ -1,6 +1,6 @@ +@@ -1,8 +1,13 @@ load("@rules_rust//rust:toolchain.bzl", "rustfmt_toolchain") load("@rules_rust//rust/platform:triple.bzl", _parse_triple = "triple") -load("//rs/experimental/platforms:triples.bzl", "SUPPORTED_EXEC_TRIPLES") +load("//rs/experimental/platforms:triples.bzl", "SUPPORTED_EXEC_TRIPLES", "triple_to_constraint_set") load("//rs/experimental/toolchains:toolchain_utils.bzl", "sanitize_version") - def _channel(version): -@@ -10,6 +10,11 @@ - return "beta" - return "stable" - +def _exec_triple_suffix(exec_triple): + if exec_triple.system == "windows": + return "{}_{}_{}".format(exec_triple.system, exec_triple.arch, exec_triple.abi) + return "{}_{}".format(exec_triple.system, exec_triple.arch) + - def declare_rustfmt_toolchains( - *, - version, -@@ -22,14 +27,13 @@ + def _channel(version): + if version.startswith("nightly"): + return "nightly" +@@ -22,14 +27,13 @@ def declare_rustfmt_toolchains( for triple in execs: exec_triple = _parse_triple(triple) @@ -98,7 +101,7 @@ diff --git a/rs/experimental/toolchains/declare_rustfmt_toolchains.bzl b/rs/expe version_key, ) -@@ -43,11 +47,8 @@ +@@ -43,11 +47,8 @@ def declare_rustfmt_toolchains( ) native.toolchain( @@ -113,9 +116,10 @@ diff --git a/rs/experimental/toolchains/declare_rustfmt_toolchains.bzl b/rs/expe target_settings = [ "@rules_rust//rust/toolchain/channel:" + channel, diff --git a/rs/experimental/toolchains/module_extension.bzl b/rs/experimental/toolchains/module_extension.bzl +index 7bb0205..ace556b 100644 --- a/rs/experimental/toolchains/module_extension.bzl +++ b/rs/experimental/toolchains/module_extension.bzl -@@ -37,6 +37,11 @@ +@@ -37,6 +37,11 @@ def _normalize_arch_name(arch): return "aarch64" return arch @@ -127,7 +131,7 @@ diff --git a/rs/experimental/toolchains/module_extension.bzl b/rs/experimental/t def _sanitize_path_fragment(path): return path.replace("/", "_").replace(":", "_") -@@ -181,7 +186,7 @@ +@@ -181,7 +186,7 @@ def _toolchains_impl(mctx): for triple in SUPPORTED_EXEC_TRIPLES: exec_triple = _parse_triple(triple) @@ -136,7 +140,7 @@ diff --git a/rs/experimental/toolchains/module_extension.bzl b/rs/experimental/t rustc_name = "rustc_{}_{}".format(triple_suffix, version_key) rustc_repository( -@@ -230,7 +235,7 @@ +@@ -230,7 +235,7 @@ def _toolchains_impl(mctx): for triple in SUPPORTED_EXEC_TRIPLES: exec_triple = _parse_triple(triple) diff --git a/patches/rusty_v8_prebuilt_out_dir.patch b/patches/rusty_v8_prebuilt_out_dir.patch index e5132d664f..4242a29beb 100644 --- a/patches/rusty_v8_prebuilt_out_dir.patch +++ b/patches/rusty_v8_prebuilt_out_dir.patch @@ -1,5 +1,27 @@ +# What: make `rusty_v8` accept Bazel-provided archives and bindings for the +# windows-gnullvm experiment. +# Scope: `rusty_v8` build.rs only; no V8 source or Bazel rule changes. + --- a/build.rs +++ b/build.rs +@@ -543,10 +543,15 @@ + } + + fn static_lib_name(suffix: &str) -> String { +- let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap(); +- if target_os == "windows" { ++ let target = env::var("TARGET").unwrap(); ++ let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap(); ++ if target.contains("windows-gnullvm") { ++ // rustc looks for GNU-style archive names when bundling `-lstatic` on the ++ // gnullvm targets, even though the prebuilt release is a COFF `.lib`. ++ format!("librusty_v8{suffix}.a") ++ } else if target_os == "windows" { + format!("rusty_v8{suffix}.lib") + } else { + format!("librusty_v8{suffix}.a") + } + } @@ -577,7 +577,23 @@ path } diff --git a/patches/v8_bazel_rules.patch b/patches/v8_bazel_rules.patch index 66aff5e4d2..5457e3b854 100644 --- a/patches/v8_bazel_rules.patch +++ b/patches/v8_bazel_rules.patch @@ -29,11 +29,17 @@ index 9648e4a..88efd41 100644 "@v8//bazel/config:is_gcc": [ "-Wno-extra", "-Wno-array-bounds", -@@ -155,7 +149,12 @@ def _default_args(): - "@v8//bazel/config:is_windows": [ - "/std:c++20", - ], +@@ -155,7 +149,15 @@ def _default_args(): +- "@v8//bazel/config:is_windows": [ +- "/std:c++20", +- ], - "//conditions:default": [], ++ "@v8//bazel/config:is_windows": [ ++ "-Wno-invalid-offsetof", ++ "-Wno-deprecated-this-capture", ++ "-Wno-deprecated-declarations", ++ "-std=c++20", ++ ], + "//conditions:default": [ + "-Wno-invalid-offsetof", + "-Wno-deprecated-this-capture", @@ -43,8 +49,14 @@ index 9648e4a..88efd41 100644 }) + select({ "@v8//bazel/config:is_gcc_fastbuild": [ # Non-debug builds without optimizations fail because -@@ -184,7 +183,7 @@ def _default_args(): - "Advapi32.lib", +@@ -180,10 +179,10 @@ def _default_args(): + "@v8//bazel/config:is_windows": [ +- "Winmm.lib", +- "DbgHelp.lib", +- "Advapi32.lib", ++ "-lwinmm", ++ "-ldbghelp", ++ "-ladvapi32", ], "@v8//bazel/config:is_macos": ["-pthread"], - "//conditions:default": ["-Wl,--no-as-needed -ldl -latomic -pthread"], @@ -225,3 +237,39 @@ index 5fda2f4..381386c 100644 # Copyright 2021 the V8 project authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +@@ -16,10 +18,7 @@ cc_library( + ]), + copts = select({ + "@platforms//os:windows": [ +- "/wd4005", # Macro redefinition. +- "/wd4068", # Unknown pragmas. +- "/wd4267", # Conversion from size_t on 64-bits. +- "/utf-8", # ICU source files are in UTF-8. ++ "-Wno-deprecated-declarations", + ], + "//conditions:default": [ + "-Wno-deprecated-declarations", +@@ -65,10 +64,7 @@ cc_library( + ]), + copts = select({ + "@platforms//os:windows": [ +- "/wd4005", # Macro redefinition. +- "/wd4068", # Unknown pragmas. +- "/wd4267", # Conversion from size_t on 64-bits. +- "/utf-8", # ICU source files are in UTF-8. ++ "-Wno-deprecated-declarations", + ], + "//conditions:default": [ + "-Wno-deprecated-declarations", +@@ -93,10 +89,7 @@ cc_library( + ]), + copts = select({ + "@platforms//os:windows": [ +- "/wd4005", # Macro redefinition. +- "/wd4068", # Unknown pragmas. +- "/wd4267", # Conversion from size_t on 64-bits. +- "/utf-8", # ICU source files are in UTF-8. ++ "-Wno-deprecated-declarations", + ], + "//conditions:default": [], + }), diff --git a/patches/v8_module_deps.patch b/patches/v8_module_deps.patch index ec4c8afb29..6c35dbacd4 100644 --- a/patches/v8_module_deps.patch +++ b/patches/v8_module_deps.patch @@ -62,7 +62,7 @@ diff --git a/orig/v8-14.6.202.11/MODULE.bazel b/mod/v8-14.6.202.11/MODULE.bazel + commit = "3d2de1816307bac63c16a297e8c4dc501b4076df", + remote = "https://chromium.googlesource.com/external/github.com/Maratyszcza/FP16.git", +) - + pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip") pip.parse( @@ -22,171 +72,3 @@ @@ -241,16 +241,29 @@ diff --git a/orig/v8-14.6.202.11/bazel/highway.patch b/mod/v8-14.6.202.11/bazel/ new file mode 100644 --- /dev/null +++ b/mod/v8-14.6.202.11/bazel/highway.patch -@@ -0,0 +1,12 @@ +@@ -0,0 +1,25 @@ +diff --git a/BUILD b/BUILD +--- a/BUILD ++++ b/BUILD +@@ -2,7 +2,7 @@ + load("@bazel_skylib//lib:selects.bzl", "selects") + load("@rules_license//rules:license.bzl", "license") -+ ++ +-load("@rules_cc//cc:defs.bzl", "cc_test") ++load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") + # Placeholder#2 for Guitar, do not remove -+ ++ + package( ++@@ -134,11 +134,7 @@ COPTS = select({ ++ ], ++ }) ++ ++-DEFINES = select({ ++- ":compiler_msvc": ["HWY_SHARED_DEFINE"], ++- ":compiler_clangcl": ["HWY_SHARED_DEFINE"], ++- "//conditions:default": [], ++-}) +++DEFINES = [] ++ ++ # Unused on Bazel builds, where this is not defined/known; Copybara replaces ++ # usages with an empty list. diff --git a/patches/v8_source_portability.patch b/patches/v8_source_portability.patch index 81433cae62..4f5f46005f 100644 --- a/patches/v8_source_portability.patch +++ b/patches/v8_source_portability.patch @@ -2,7 +2,28 @@ # Scope: minimal source-level portability fixes only, such as libexecinfo guards, # weak glibc symbol handling, and warning annotations; no dependency # include-path rewrites or intentional V8 feature changes. - +diff --git a/orig/v8-14.6.202.11/src/base/bits.h b/mod/v8-14.6.202.11/src/base/bits.h +index 179a10f..4791e96 100644 +--- a/orig/v8-14.6.202.11/src/base/bits.h ++++ b/mod/v8-14.6.202.11/src/base/bits.h +@@ -270,11 +270,17 @@ inline constexpr uint32_t RoundDownToPowerOfTwo32(uint32_t value) { + } + + // Precondition: 0 <= shift < 32 ++#ifdef RotateRight32 ++#undef RotateRight32 ++#endif + inline constexpr uint32_t RotateRight32(uint32_t value, uint32_t shift) { + return (value >> shift) | (value << ((32 - shift) & 31)); + } + + // Precondition: 0 <= shift < 32 ++#ifdef RotateLeft32 ++#undef RotateLeft32 ++#endif + inline constexpr uint32_t RotateLeft32(uint32_t value, uint32_t shift) { + return (value << shift) | (value >> ((32 - shift) & 31)); + } diff --git a/orig/v8-14.6.202.11/src/base/debug/stack_trace_posix.cc b/mod/v8-14.6.202.11/src/base/debug/stack_trace_posix.cc index 6176ed4..a02043d 100644 --- a/orig/v8-14.6.202.11/src/base/debug/stack_trace_posix.cc @@ -23,36 +44,35 @@ index 6176ed4..a02043d 100644 // Demangles C++ symbols in the given text. Example: // // "out/Debug/base_unittests(_ZN10StackTraceC1Ev+0x20) [0x817778c]" - +diff --git a/orig/v8-14.6.202.11/src/base/export-template.h b/mod/v8-14.6.202.11/src/base/export-template.h +index 861cfe4..1e73954 100644 +--- a/orig/v8-14.6.202.11/src/base/export-template.h ++++ b/mod/v8-14.6.202.11/src/base/export-template.h +@@ -153,8 +153,10 @@ + + EXPORT_TEMPLATE_TEST(DEFAULT, ); + EXPORT_TEMPLATE_TEST(DEFAULT, __attribute__((visibility("default")))); ++#if defined(_MSC_VER) + EXPORT_TEMPLATE_TEST(MSVC_HACK, __declspec(dllexport)); + EXPORT_TEMPLATE_TEST(DEFAULT, __declspec(dllimport)); ++#endif + + #undef EXPORT_TEMPLATE_TEST + #undef EXPORT_TEMPLATE_TEST_DEFAULT_DEFAULT diff --git a/orig/v8-14.6.202.11/src/base/platform/platform-posix.cc b/mod/v8-14.6.202.11/src/base/platform/platform-posix.cc -index 4c7d878..0e45eb3 100644 +index 420df0b..6f47969 100644 --- a/orig/v8-14.6.202.11/src/base/platform/platform-posix.cc +++ b/mod/v8-14.6.202.11/src/base/platform/platform-posix.cc -@@ -95,7 +95,7 @@ +@@ -95,7 +95,7 @@ extern int madvise(caddr_t, size_t, int); #endif - + #if defined(V8_LIBC_GLIBC) -extern "C" void* __libc_stack_end; +extern "C" void* __libc_stack_end V8_WEAK; #endif - + namespace v8 { -@@ -1461,10 +1461,13 @@ - // pthread_getattr_np can fail for the main thread. - // For the main thread we prefer using __libc_stack_end (if it exists) since - // it generally provides a tighter limit for CSS. -- return __libc_stack_end; -+ if (__libc_stack_end != nullptr) { -+ return __libc_stack_end; -+ } - #else - return nullptr; - #endif // !defined(V8_LIBC_GLIBC) -+ return nullptr; - } - void* base; - size_t size; -@@ -1476,7 +1479,8 @@ +@@ -1476,7 +1476,8 @@ Stack::StackSlot Stack::ObtainCurrentThreadStackStart() { // __libc_stack_end is process global and thus is only valid for // the main thread. Check whether this is the main thread by checking // __libc_stack_end is within the thread's stack. @@ -62,7 +82,213 @@ index 4c7d878..0e45eb3 100644 DCHECK(MainThreadIsCurrentThread()); return __libc_stack_end; } - +diff --git a/orig/v8-14.6.202.11/src/base/platform/platform-win32.cc b/mod/v8-14.6.202.11/src/base/platform/platform-win32.cc +index f5d9ddc..542ea1a 100644 +--- a/orig/v8-14.6.202.11/src/base/platform/platform-win32.cc ++++ b/mod/v8-14.6.202.11/src/base/platform/platform-win32.cc +@@ -69,9 +69,7 @@ static_assert(offsetof(V8_CRITICAL_SECTION, SpinCount) == + // Extra functions for MinGW. Most of these are the _s functions which are in + // the Microsoft Visual Studio C++ CRT. + #ifdef __MINGW32__ +- +- +-#ifndef __MINGW64_VERSION_MAJOR ++#if !defined(__MINGW64_VERSION_MAJOR) + + #define _TRUNCATE 0 + #define STRUNCATE 80 +@@ -81,9 +79,6 @@ inline void MemoryFence() { + __asm__ __volatile__("xchgl %%eax,%0 ":"=r" (barrier)); + } + +-#endif // __MINGW64_VERSION_MAJOR +- +- + int localtime_s(tm* out_tm, const time_t* time) { + tm* posix_local_time_struct = localtime_r(time, out_tm); + if (posix_local_time_struct == nullptr) return 1; +@@ -134,6 +129,8 @@ int strncpy_s(char* dest, size_t dest_size, const char* source, size_t count) { + return 0; + } + ++#endif // !defined(__MINGW64_VERSION_MAJOR) ++ + #endif // __MINGW32__ + + namespace v8 { +@@ -743,8 +740,10 @@ void OS::StrNCpy(char* dest, int length, const char* src, size_t n) { + } + + ++#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) + #undef _TRUNCATE + #undef STRUNCATE ++#endif + + DEFINE_LAZY_LEAKY_OBJECT_GETTER(RandomNumberGenerator, + GetPlatformRandomNumberGenerator) +@@ -1894,3 +1893,4 @@ Stack::StackSlot Stack::GetCurrentStackPosition() { + + } // namespace base + } // namespace v8 ++ +diff --git a/orig/v8-14.6.202.11/src/base/platform/time.cc b/mod/v8-14.6.202.11/src/base/platform/time.cc +index 8390288..cba6cd5 100644 +--- a/orig/v8-14.6.202.11/src/base/platform/time.cc ++++ b/mod/v8-14.6.202.11/src/base/platform/time.cc +@@ -782,12 +782,12 @@ bool ThreadTicks::IsSupported() { + #elif defined(__PASE__) + // Thread CPU time accounting is unavailable in PASE + return false; ++#elif defined(V8_OS_WIN) ++ return IsSupportedWin(); + #elif (defined(_POSIX_THREAD_CPUTIME) && (_POSIX_THREAD_CPUTIME >= 0)) || \ + defined(V8_OS_DARWIN) || defined(V8_OS_ANDROID) || \ + defined(V8_OS_SOLARIS) || defined(V8_OS_ZOS) + return true; +-#elif defined(V8_OS_WIN) +- return IsSupportedWin(); + #else + return false; + #endif +@@ -804,13 +804,13 @@ ThreadTicks ThreadTicks::Now() { + return ThreadTicks(ComputeThreadTicks()); + #elif V8_OS_FUCHSIA + return ThreadTicks(GetFuchsiaThreadTicks()); ++#elif V8_OS_WIN ++ return ThreadTicks::GetForThread(::GetCurrentThread()); + #elif (defined(_POSIX_THREAD_CPUTIME) && (_POSIX_THREAD_CPUTIME >= 0)) || \ + defined(V8_OS_ANDROID) || defined(V8_OS_ZOS) + return ThreadTicks(ClockNow(CLOCK_THREAD_CPUTIME_ID)); + #elif V8_OS_SOLARIS + return ThreadTicks(gethrvtime() / Time::kNanosecondsPerMicrosecond); +-#elif V8_OS_WIN +- return ThreadTicks::GetForThread(::GetCurrentThread()); + #else + UNREACHABLE(); + #endif +diff --git a/orig/v8-14.6.202.11/src/heap/base/asm/x64/push_registers_masm.asm b/mod/v8-14.6.202.11/src/heap/base/asm/x64/push_registers_masm.asm +index d0d0563..72e230b 100644 +--- a/orig/v8-14.6.202.11/src/heap/base/asm/x64/push_registers_masm.asm ++++ b/mod/v8-14.6.202.11/src/heap/base/asm/x64/push_registers_masm.asm +@@ -1,70 +1,30 @@ +-;; Copyright 2020 the V8 project authors. All rights reserved. +-;; Use of this source code is governed by a BSD-style license that can be +-;; found in the LICENSE file. +- +-;; MASM syntax +-;; https://docs.microsoft.com/en-us/cpp/assembler/masm/microsoft-macro-assembler-reference?view=vs-2019 +- +-public PushAllRegistersAndIterateStack +- +-.code +-PushAllRegistersAndIterateStack proc frame +- ;; Push all callee-saved registers to get them on the stack for conservative +- ;; stack scanning. +- ;; +- ;; We maintain 16-byte alignment at calls. There is an 8-byte return address +- ;; on the stack and we push 232 bytes which maintains 16-byte stack +- ;; alignment at the call. +- ;; Source: https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention +- ;; +- ;; rbp is callee-saved. Maintain proper frame pointer for debugging. +- push rbp +- .pushreg rbp +- mov rbp, rsp +- .setframe rbp, 0 +- push 0CDCDCDh ;; Dummy for alignment. +- .allocstack 8 +- push rsi +- .pushreg rsi +- push rdi +- .pushreg rdi +- push rbx +- .pushreg rbx +- push r12 +- .pushreg r12 +- push r13 +- .pushreg r13 +- push r14 +- .pushreg r14 +- push r15 +- .pushreg r15 +- sub rsp, 160 +- .allocstack 160 +- .endprolog +- ;; Use aligned instrs as we are certain that the stack is properly aligned. +- movdqa xmmword ptr [rsp + 144], xmm6 +- movdqa xmmword ptr [rsp + 128], xmm7 +- movdqa xmmword ptr [rsp + 112], xmm8 +- movdqa xmmword ptr [rsp + 96], xmm9 +- movdqa xmmword ptr [rsp + 80], xmm10 +- movdqa xmmword ptr [rsp + 64], xmm11 +- movdqa xmmword ptr [rsp + 48], xmm12 +- movdqa xmmword ptr [rsp + 32], xmm13 +- movdqa xmmword ptr [rsp + 16], xmm14 +- movdqa xmmword ptr [rsp], xmm15 +- ;; Pass 1st parameter (rcx) unchanged (Stack*). +- ;; Pass 2nd parameter (rdx) unchanged (StackVisitor*). +- ;; Save 3rd parameter (r8; IterateStackCallback) +- mov r9, r8 +- ;; Pass 3rd parameter as rsp (stack pointer). +- mov r8, rsp +- ;; Call the callback. +- call r9 +- ;; Pop the callee-saved registers. +- add rsp, 224 +- ;; Restore rbp as it was used as frame pointer. +- pop rbp +- ret +- PushAllRegistersAndIterateStack endp +- +-end ++.text ++.globl PushAllRegistersAndIterateStack ++.seh_proc PushAllRegistersAndIterateStack ++PushAllRegistersAndIterateStack: ++ push %rbp ++ .seh_pushreg %rbp ++ mov %rsp, %rbp ++ .seh_setframe %rbp, 0 ++ push $0xCDCDCD ++ .seh_stackalloc 8 ++ push %rsi ++ .seh_pushreg %rsi ++ push %rdi ++ .seh_pushreg %rdi ++ push %rbx ++ .seh_pushreg %rbx ++ push %r12 ++ .seh_pushreg %r12 ++ push %r13 ++ .seh_pushreg %r13 ++ push %r14 ++ .seh_pushreg %r14 ++ push %r15 ++ .seh_pushreg %r15 ++ sub $160, %rsp ++ .seh_stackalloc 160 ++ # Preserve Windows unwind metadata even though this is now GNU syntax. ++ # Without the .seh_* directives, SEH and stack walking can mis-handle ++ # unwinding across this callback frame. ++ .seh_endprologue ++ movdqa %xmm6, 144(%rsp) ++ movdqa %xmm7, 128(%rsp) ++ movdqa %xmm8, 112(%rsp) ++ movdqa %xmm9, 96(%rsp) ++ movdqa %xmm10, 80(%rsp) ++ movdqa %xmm11, 64(%rsp) ++ movdqa %xmm12, 48(%rsp) ++ movdqa %xmm13, 32(%rsp) ++ movdqa %xmm14, 16(%rsp) ++ movdqa %xmm15, 0(%rsp) ++ mov %r8, %r9 ++ mov %rsp, %r8 ++ call *%r9 ++ add $224, %rsp ++ pop %rbp ++ ret ++.seh_endproc diff --git a/orig/v8-14.6.202.11/src/libplatform/default-thread-isolated-allocator.cc b/mod/v8-14.6.202.11/src/libplatform/default-thread-isolated-allocator.cc index bda0e43..b44f1d9 100644 --- a/orig/v8-14.6.202.11/src/libplatform/default-thread-isolated-allocator.cc @@ -76,3 +302,26 @@ index bda0e43..b44f1d9 100644 // PKU was broken on Linux kernels before 5.13 (see // https://lore.kernel.org/all/20210623121456.399107624@linutronix.de/). // A fix is also included in the 5.4.182 and 5.10.103 versions ("x86/fpu: +diff --git a/orig/v8-14.6.202.11/src/profiler/heap-snapshot-generator.cc b/mod/v8-14.6.202.11/src/profiler/heap-snapshot-generator.cc +index 27e748f..cbf886c 100644 +--- a/orig/v8-14.6.202.11/src/profiler/heap-snapshot-generator.cc ++++ b/mod/v8-14.6.202.11/src/profiler/heap-snapshot-generator.cc +@@ -429,11 +429,11 @@ HeapSnapshot::HeapSnapshot(HeapProfiler* profiler, + static_assert(kSystemPointerSize != 4 || sizeof(HeapGraphEdge) == 12); + static_assert(kSystemPointerSize != 8 || sizeof(HeapGraphEdge) == 24); + static_assert(kSystemPointerSize != 4 || sizeof(HeapEntry) == 32); +-#if V8_CC_MSVC ++#if V8_CC_MSVC || V8_OS_WIN + static_assert(kSystemPointerSize != 8 || sizeof(HeapEntry) == 48); + #else // !V8_CC_MSVC + static_assert(kSystemPointerSize != 8 || sizeof(HeapEntry) == 40); +-#endif // !V8_CC_MSVC ++#endif // !V8_CC_MSVC || V8_OS_WIN + memset(&gc_subroot_entries_, 0, sizeof(gc_subroot_entries_)); + } + +@@ -3878,3 +3878,4 @@ void HeapSnapshotJSONSerializer::SerializeLocations() { + } + + } // namespace v8::internal ++ diff --git a/third_party/v8/BUILD.bazel b/third_party/v8/BUILD.bazel index b32bc2f495..27e9fa3ffe 100644 --- a/third_party/v8/BUILD.bazel +++ b/third_party/v8/BUILD.bazel @@ -64,12 +64,15 @@ alias( alias( name = "v8_146_4_0_aarch64_pc_windows_gnullvm", - actual = ":v8_146_4_0_aarch64_pc_windows_msvc", + # `rusty_v8` only ships prebuilt Windows archives for MSVC. Build the + # GNU-flavored archive in-tree so windows-gnullvm consumers can link + # against a matching ABI instead of trying to reuse the MSVC release. + actual = ":v8_146_4_0_aarch64_pc_windows_gnullvm_bazel", ) alias( name = "v8_146_4_0_x86_64_pc_windows_gnullvm", - actual = ":v8_146_4_0_x86_64_pc_windows_msvc", + actual = ":v8_146_4_0_x86_64_pc_windows_gnullvm_bazel", ) filegroup( @@ -114,12 +117,16 @@ filegroup( alias( name = "src_binding_release_x86_64_pc_windows_gnullvm", - actual = ":src_binding_release_x86_64_pc_windows_msvc", + # `rusty_v8` does not publish a Windows GNU binding file. The generated + # binding only describes this V8 release's C++ API surface, so reuse the + # Linux release binding while the windows-gnullvm archive build is still + # experimental. + actual = ":src_binding_release_x86_64_unknown_linux_gnu", ) alias( name = "src_binding_release_aarch64_pc_windows_gnullvm", - actual = ":src_binding_release_aarch64_pc_windows_msvc", + actual = ":src_binding_release_aarch64_unknown_linux_gnu", ) alias( @@ -167,6 +174,8 @@ genrule( name = "binding_cc", srcs = ["@v8_crate_146_4_0//:binding_cc"], outs = ["binding.cc"], + # Keep this as a literal shell snippet. The string-concatenated form looked + # cleaner in Starlark but produced a broken `sed` invocation in CI. cmd = """ sed \ -e '/#include "v8\\/src\\/flags\\/flags.h"/d' \ @@ -208,12 +217,24 @@ cc_static_library( features = V8_STATIC_LIBRARY_FEATURES, ) +cc_static_library( + name = "v8_146_4_0_aarch64_pc_windows_gnullvm_bazel", + deps = [":v8_146_4_0_binding"], + features = V8_STATIC_LIBRARY_FEATURES, +) + cc_static_library( name = "v8_146_4_0_x86_64_apple_darwin_bazel", deps = [":v8_146_4_0_binding"], features = V8_STATIC_LIBRARY_FEATURES, ) +cc_static_library( + name = "v8_146_4_0_x86_64_pc_windows_gnullvm_bazel", + deps = [":v8_146_4_0_binding"], + features = V8_STATIC_LIBRARY_FEATURES, +) + cc_static_library( name = "v8_146_4_0_x86_64_unknown_linux_gnu_bazel", deps = [":v8_146_4_0_binding"],