Skip to content

use an empty staticlib as an allocator library for cc_common.link#3864

Merged
krasimirgg merged 4 commits intobazelbuild:mainfrom
krasimirgg:alloc-staticlib
Feb 23, 2026
Merged

use an empty staticlib as an allocator library for cc_common.link#3864
krasimirgg merged 4 commits intobazelbuild:mainfrom
krasimirgg:alloc-staticlib

Conversation

@krasimirgg
Copy link
Copy Markdown
Collaborator

@krasimirgg krasimirgg commented Feb 23, 2026

No functional changes intended.

As suggested on multiple channels, using an empty staticlib is a good effective way to ensure we get the rust allocator shims generated consistently. This is simpler than what we have and also looks like it uniformly supports stable and nightly across versions.

closes #3459

@krasimirgg krasimirgg changed the title [DRAFT] use an empty staticlib as an allocator library for cc_common.link use an empty staticlib as an allocator library for cc_common.link Feb 23, 2026
@krasimirgg krasimirgg marked this pull request as ready for review February 23, 2026 14:55
Copy link
Copy Markdown
Collaborator

@UebelAndre UebelAndre left a comment

Choose a reason for hiding this comment

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

Sounds good to me, thank you!

@krasimirgg krasimirgg added this pull request to the merge queue Feb 23, 2026
Merged via the queue into bazelbuild:main with commit e7e25a9 Feb 23, 2026
3 checks passed
Comment thread rust/private/rust.bzl
providers = _rust_static_library_impl(ctx)
return providers + [_RustBuiltWithoutProcessWrapperInfo()]

rust_static_library_without_process_wrapper = rule(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this will need a change to account for #3790

@cameron-martin
Copy link
Copy Markdown
Contributor

Since this now works on stable, could it be enabled by default? It seems like doing so would allow us to remove the cc versions of the allocator libraries.

github-merge-queue Bot pushed a commit that referenced this pull request Apr 15, 2026
`rust_static_library` targets fail for wasm-style platform mappings
whose `staticlib_ext` is empty.
This became visible after
#3864 changed the allocator
shim target to use `rust_static_library`. When building that target for
the wasm platform, rules_rust computes:

```
  crate_type = "staticlib"
  staticlib_ext = ""
```

`determine_lib_name` treats the empty extension as invalid and fails
with:

```
Unknown crate_type: staticlib
```

Static library outputs for these wasm/WASI-style targets should use
archive output names, e.g. libfoo.a. Binary and dylib outputs can
continue using .wasm.

This updates the wasm-style staticlib mappings to .a for:

- threads
- unknown
- wasi
- wasip1
- wasip2

This is easily reproducible from the rules_rust repository, before this
change:

```
bazel build --platforms=//rust/platform:wasm32 //ffi/rs/allocator_library:allocator_library
```

fails during analysis with:

```
  Unknown crate_type: staticlib
```

closes #3894
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cc_common_link is broken in rust 1.87.0

4 participants