diff --git a/.gitattributes b/.gitattributes index ea7e5f3822..a34647be4e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15,5 +15,6 @@ examples/sys/complex/3rdparty/crates/** linguist-generated extensions/bindgen/3rdparty/crates/** linguist-generated extensions/prost/private/3rdparty/crates/** linguist-generated extensions/wasm_bindgen/3rdparty/crates/** linguist-generated +test/unpretty/*.unpretty.expanded.rs text eol=lf tools/rust_analyzer/3rdparty/crates/** linguist-generated util/import/3rdparty/crates/** linguist-generated diff --git a/.github/workflows/bazel_test.yaml b/.github/workflows/bazel_test.yaml index d513ce6a04..0b887f110e 100644 --- a/.github/workflows/bazel_test.yaml +++ b/.github/workflows/bazel_test.yaml @@ -55,7 +55,7 @@ jobs: if: runner.os == 'Windows' shell: pwsh run: | - 'startup --output_user_root=C:/tmp/bazel' | Out-File -FilePath user.bazelrc -Encoding utf8 + 'startup --output_base=C:/b' | Out-File -FilePath user.bazelrc -Encoding utf8 'startup --windows_enable_symlinks' | Out-File -FilePath user.bazelrc -Append -Encoding utf8 - name: bazel test //... @@ -71,9 +71,22 @@ jobs: echo "BUILDBUDDY_API_KEY is not set; using BuildBuddy remote cache without an auth header." fi + PLATFORM_ARGS=() + if [[ "${RUNNER_OS}" == "macOS" ]]; then + case "${RUNNER_ARCH}" in + ARM64) MACOS_PLATFORM="@llvm//platforms:macos_aarch64" ;; + X64) MACOS_PLATFORM="@llvm//platforms:macos_x86_64" ;; + *) echo "Unsupported macOS runner architecture: ${RUNNER_ARCH}"; exit 1 ;; + esac + PLATFORM_ARGS+=("--extra_toolchains=@llvm//toolchain:all") + PLATFORM_ARGS+=("--platforms=${MACOS_PLATFORM}") + PLATFORM_ARGS+=("--@rules_cc//cc/toolchains/args/archiver_flags:use_libtool_on_macos=False") + fi + bazel \ --bazelrc="$GITHUB_WORKSPACE/.github/github.bazelrc" \ test \ --config=remote \ "${REMOTE_ARGS[@]}" \ + "${PLATFORM_ARGS[@]}" \ //... diff --git a/MODULE.bazel b/MODULE.bazel index a13172def4..651d2dfd9c 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -47,10 +47,11 @@ register_toolchains( rules_rs_toolchains = use_extension("@rules_rs//rs/toolchains:module_extension.bzl", "toolchains", dev_dependency = True) rules_rs_toolchains.toolchain(name = "default_rust_toolchains") -use_repo(rules_rs_toolchains, "default_rust_toolchains") +rules_rs_toolchains.toolchain(name = "r") +use_repo(rules_rs_toolchains, "default_rust_toolchains", "r") register_toolchains( - "@default_rust_toolchains//:all", + "@r//:all", dev_dependency = True, ) diff --git a/cargo/private/cargo_build_script_runner/lib.rs b/cargo/private/cargo_build_script_runner/lib.rs index c327e568b8..42a369a34a 100644 --- a/cargo/private/cargo_build_script_runner/lib.rs +++ b/cargo/private/cargo_build_script_runner/lib.rs @@ -92,32 +92,34 @@ impl BuildScriptOutput { } fn contains_absolute_path(value: &str) -> bool { - let path_is_absolute = |candidate: &str| { + let path_is_rooted = |candidate: &str| { let candidate = candidate.trim_matches(|character: char| { character.is_ascii_whitespace() || matches!(character, '\'' | '"' | ',' | '(' | ')' | '[' | ']') }); - Path::new(candidate).is_absolute() + Path::new(candidate).has_root() }; - if path_is_absolute(value) { + if path_is_rooted(value) { return true; } value .split(|character: char| character.is_ascii_whitespace() || character == ';') .any(|token| { - if path_is_absolute(token) { + if path_is_rooted(token) { return true; } if token.contains("://") { return false; } - token.find(std::path::MAIN_SEPARATOR).is_some_and(|index| { - let prefix = &token[..index]; - (prefix.starts_with('-') || prefix.ends_with('=')) - && path_is_absolute(&token[index..]) - }) + token + .find(|character| matches!(character, '/' | '\\')) + .is_some_and(|index| { + let prefix = &token[..index]; + (prefix.starts_with('-') || prefix.ends_with('=')) + && path_is_rooted(&token[index..]) + }) }) } diff --git a/test/determinism/3rdparty/crates/BUILD.serde-1.0.228.bazel b/test/determinism/3rdparty/crates/BUILD.serde-1.0.228.bazel index 7029c5ffea..f646d089d6 100644 --- a/test/determinism/3rdparty/crates/BUILD.serde-1.0.228.bazel +++ b/test/determinism/3rdparty/crates/BUILD.serde-1.0.228.bazel @@ -123,6 +123,9 @@ cargo_build_script( include = ["**/*.rs"], allow_empty = True, ), + build_script_env = { + "CARGO_PKG_VERSION_PATCH": "228", + }, compile_data = glob( include = ["**"], allow_empty = True, diff --git a/test/determinism/3rdparty/crates/BUILD.serde_core-1.0.228.bazel b/test/determinism/3rdparty/crates/BUILD.serde_core-1.0.228.bazel index b145e2c3c4..3f923f5efb 100644 --- a/test/determinism/3rdparty/crates/BUILD.serde_core-1.0.228.bazel +++ b/test/determinism/3rdparty/crates/BUILD.serde_core-1.0.228.bazel @@ -117,6 +117,9 @@ cargo_build_script( include = ["**/*.rs"], allow_empty = True, ), + build_script_env = { + "CARGO_PKG_VERSION_PATCH": "228", + }, compile_data = glob( include = ["**"], allow_empty = True, diff --git a/test/determinism/3rdparty/crates/BUILD.serde_derive-1.0.228.bazel b/test/determinism/3rdparty/crates/BUILD.serde_derive-1.0.228.bazel index a754ee8892..75f69e510c 100644 --- a/test/determinism/3rdparty/crates/BUILD.serde_derive-1.0.228.bazel +++ b/test/determinism/3rdparty/crates/BUILD.serde_derive-1.0.228.bazel @@ -33,6 +33,9 @@ rust_proc_macro( ], crate_root = "src/lib.rs", edition = "2021", + rustc_env = { + "CARGO_PKG_VERSION_PATCH": "228", + }, rustc_flags = [ "--cap-lints=allow", ], diff --git a/test/rust_analyzer/3rdparty/crates/BUILD.serde-1.0.228.bazel b/test/rust_analyzer/3rdparty/crates/BUILD.serde-1.0.228.bazel index 32462c1988..ce7e5641fc 100644 --- a/test/rust_analyzer/3rdparty/crates/BUILD.serde-1.0.228.bazel +++ b/test/rust_analyzer/3rdparty/crates/BUILD.serde-1.0.228.bazel @@ -123,6 +123,9 @@ cargo_build_script( include = ["**/*.rs"], allow_empty = True, ), + build_script_env = { + "CARGO_PKG_VERSION_PATCH": "228", + }, compile_data = glob( include = ["**"], allow_empty = True, diff --git a/test/rust_analyzer/3rdparty/crates/BUILD.serde_core-1.0.228.bazel b/test/rust_analyzer/3rdparty/crates/BUILD.serde_core-1.0.228.bazel index 1f1f946dd2..57c9d378b2 100644 --- a/test/rust_analyzer/3rdparty/crates/BUILD.serde_core-1.0.228.bazel +++ b/test/rust_analyzer/3rdparty/crates/BUILD.serde_core-1.0.228.bazel @@ -117,6 +117,9 @@ cargo_build_script( include = ["**/*.rs"], allow_empty = True, ), + build_script_env = { + "CARGO_PKG_VERSION_PATCH": "228", + }, compile_data = glob( include = ["**"], allow_empty = True, diff --git a/test/rust_analyzer/3rdparty/crates/BUILD.serde_derive-1.0.228.bazel b/test/rust_analyzer/3rdparty/crates/BUILD.serde_derive-1.0.228.bazel index 47818c669f..8199008b8f 100644 --- a/test/rust_analyzer/3rdparty/crates/BUILD.serde_derive-1.0.228.bazel +++ b/test/rust_analyzer/3rdparty/crates/BUILD.serde_derive-1.0.228.bazel @@ -33,6 +33,9 @@ rust_proc_macro( ], crate_root = "src/lib.rs", edition = "2021", + rustc_env = { + "CARGO_PKG_VERSION_PATCH": "228", + }, rustc_flags = [ "--cap-lints=allow", ], diff --git a/test/unit/lto/lto_test_suite.bzl b/test/unit/lto/lto_test_suite.bzl index de30381bd1..eb01584a6e 100644 --- a/test/unit/lto/lto_test_suite.bzl +++ b/test/unit/lto/lto_test_suite.bzl @@ -373,18 +373,21 @@ def lto_test_suite(name): name = "lib", srcs = [":lib.rs"], edition = "2021", + tags = ["manual"], ) rust_proc_macro( name = "proc_macro", srcs = [":lib.rs"], edition = "2021", + tags = ["manual"], ) rust_library( name = "distributed_lib", srcs = [":lib.rs"], edition = "2021", + tags = ["manual"], ) rust_library( @@ -393,6 +396,7 @@ def lto_test_suite(name): crate_name = "distributed_lib", edition = "2021", features = ["thin_lto"], + tags = ["manual"], ) rust_library( @@ -401,11 +405,13 @@ def lto_test_suite(name): crate_name = "distributed_lib", edition = "2021", features = ["-thin_lto"], + tags = ["manual"], ) rust_library_group( name = "distributed_lib_group", deps = [":distributed_lib"], + tags = ["manual"], ) rust_binary( @@ -413,6 +419,7 @@ def lto_test_suite(name): srcs = [":main.rs"], deps = [":distributed_lib_group"], edition = "2021", + tags = ["manual"], ) rust_binary( @@ -420,6 +427,7 @@ def lto_test_suite(name): srcs = [":global_allocator_bin"], deps = [":distributed_lib_group"], edition = "2021", + tags = ["manual"], ) rust_binary( @@ -428,6 +436,7 @@ def lto_test_suite(name): deps = [":distributed_lib_disabled_feature"], edition = "2021", features = ["-thin_lto"], + tags = ["manual"], ) cc_binary( @@ -435,11 +444,13 @@ def lto_test_suite(name): srcs = [":main.cc"], deps = [":distributed_lib_rule_feature"], features = ["thin_lto"], + tags = ["manual"], ) _with_exec_cfg( name = "distributed_bin_exec", target = ":distributed_bin", + tags = ["manual"], ) _lto_level_default_test( diff --git a/test/unit/pipelined_compilation/pipelined_compilation_test.bzl b/test/unit/pipelined_compilation/pipelined_compilation_test.bzl index 36e2a4d32b..51f91f88ae 100644 --- a/test/unit/pipelined_compilation/pipelined_compilation_test.bzl +++ b/test/unit/pipelined_compilation/pipelined_compilation_test.bzl @@ -178,6 +178,7 @@ def _pipelined_compilation_test(): edition = "2021", srcs = ["bin.rs"], deps = [":second"], + tags = ["manual"], ) second_lib_test( diff --git a/test/unit/remap_path_prefix/debug_transition.bzl b/test/unit/remap_path_prefix/debug_transition.bzl index eff4540e59..bacad84d92 100644 --- a/test/unit/remap_path_prefix/debug_transition.bzl +++ b/test/unit/remap_path_prefix/debug_transition.bzl @@ -42,8 +42,26 @@ def _dbg_rust_binary_impl(ctx): is_executable = True, ) + pdb_files = [] + dsym_folders = [] + if OutputGroupInfo in binary: + for pdb_file in getattr(binary[OutputGroupInfo], "pdb_file", depset()).to_list(): + new_pdb = ctx.actions.declare_file(paths.join(ctx.label.name, pdb_file.basename)) + ctx.actions.symlink( + output = new_pdb, + target_file = pdb_file, + ) + pdb_files.append(new_pdb) + for dsym_folder in getattr(binary[OutputGroupInfo], "dsym_folder", depset()).to_list(): + new_dsym_folder = ctx.actions.declare_directory(paths.join(ctx.label.name, dsym_folder.basename)) + ctx.actions.symlink( + output = new_dsym_folder, + target_file = dsym_folder, + ) + dsym_folders.append(new_dsym_folder) + files = depset(direct = [new_executable]) - runfiles = ctx.runfiles([new_executable]) + runfiles = ctx.runfiles([new_executable] + pdb_files + dsym_folders) result.append( DefaultInfo( diff --git a/test/unit/remap_path_prefix/integration_test.rs b/test/unit/remap_path_prefix/integration_test.rs index 8a4a56e991..7696292641 100644 --- a/test/unit/remap_path_prefix/integration_test.rs +++ b/test/unit/remap_path_prefix/integration_test.rs @@ -19,8 +19,12 @@ fn test_backtrace() { let mut check_next = false; for line in stderr.split('\n') { if check_next { - if !line.contains("test/unit/remap_path_prefix/panic_bin.rs:6:5") { - panic!("Expected line to contain test/unit/remap_path_prefix/panic_bin.rs:6:5 but was {}", line); + let normalized_line = line.replace('\\', "/"); + if !normalized_line.contains("test/unit/remap_path_prefix/panic_bin.rs:6") { + panic!( + "Expected line to contain test/unit/remap_path_prefix/panic_bin.rs:6 but was {}", + line + ); } return; } diff --git a/test/vscode/3rdparty/crates/BUILD.serde-1.0.228.bazel b/test/vscode/3rdparty/crates/BUILD.serde-1.0.228.bazel index 07f238c860..9cffd83579 100644 --- a/test/vscode/3rdparty/crates/BUILD.serde-1.0.228.bazel +++ b/test/vscode/3rdparty/crates/BUILD.serde-1.0.228.bazel @@ -123,6 +123,9 @@ cargo_build_script( include = ["**/*.rs"], allow_empty = True, ), + build_script_env = { + "CARGO_PKG_VERSION_PATCH": "228", + }, compile_data = glob( include = ["**"], allow_empty = True, diff --git a/test/vscode/3rdparty/crates/BUILD.serde_core-1.0.228.bazel b/test/vscode/3rdparty/crates/BUILD.serde_core-1.0.228.bazel index aaf64727ba..68ca9cb1ef 100644 --- a/test/vscode/3rdparty/crates/BUILD.serde_core-1.0.228.bazel +++ b/test/vscode/3rdparty/crates/BUILD.serde_core-1.0.228.bazel @@ -117,6 +117,9 @@ cargo_build_script( include = ["**/*.rs"], allow_empty = True, ), + build_script_env = { + "CARGO_PKG_VERSION_PATCH": "228", + }, compile_data = glob( include = ["**"], allow_empty = True, diff --git a/test/vscode/3rdparty/crates/BUILD.serde_derive-1.0.228.bazel b/test/vscode/3rdparty/crates/BUILD.serde_derive-1.0.228.bazel index 545cd7479f..0cbf67d412 100644 --- a/test/vscode/3rdparty/crates/BUILD.serde_derive-1.0.228.bazel +++ b/test/vscode/3rdparty/crates/BUILD.serde_derive-1.0.228.bazel @@ -33,6 +33,9 @@ rust_proc_macro( ], crate_root = "src/lib.rs", edition = "2021", + rustc_env = { + "CARGO_PKG_VERSION_PATCH": "228", + }, rustc_flags = [ "--cap-lints=allow", ], diff --git a/test/vscode/vscode_test_runner.sh b/test/vscode/vscode_test_runner.sh index 1ba4ed29a9..44868e1d8c 100755 --- a/test/vscode/vscode_test_runner.sh +++ b/test/vscode/vscode_test_runner.sh @@ -62,9 +62,10 @@ register_toolchains("@rust_toolchains//:all") rules_rs_toolchains = use_extension("@rules_rs//rs/toolchains:module_extension.bzl", "toolchains", dev_dependency = True) rules_rs_toolchains.toolchain(name = "default_rust_toolchains") -use_repo(rules_rs_toolchains, "default_rust_toolchains") +rules_rs_toolchains.toolchain(name = "r") +use_repo(rules_rs_toolchains, "default_rust_toolchains", "r") register_toolchains( - "@default_rust_toolchains//:all", + "@r//:all", dev_dependency = True, )