rust-lang / rust-lang/rust

run-make: investigate if we can make tests with linkage less error-prone

Open
#128,821 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-compiletest A-linkage A-run-make C-cleanup E-hard E-needs-design E-needs-investigation O-windows-msvc T-compiler
Dominant language
Rust
Stars
119k
Forks
16.2k
PR merge metrics
PR metrics pending

Description

In #128807 we found out that for fmt-write-bloat we needed to do (on Windows):

- #[link(name = "c")]
+ #[cfg_attr(not(target_env = "msvc"), link(name = "c"))]
+ #[cfg_attr(all(target_env = "msvc", target_feature = "crt-static"), link(name = "libcmt"))]
+ #[cfg_attr(all(target_env = "msvc", not(target_feature = "crt-static")), link(name = "msvcrt"))]
extern "C" {}

in order for the test to not be ignore-windows-msvc.

The trouble here is that libc doesn't exist on Windows. Well it kinda does but it isn't called that so we substitute a name that works.

It also can't just be #[cfg_attr(target_env = "msvc", link(name = "libcmt"))] simply, because that would fail with

warning LNK4098: defaultlib 'msvcrt' conflicts with use of other libs

We should find a way to make this less tricky / error-prone (because this is very non-obvious).

@ChrisDenton said

I do think this logic should ideally either be in run-make-support or better yet compiletest could have something like a NO_STD_EXTRA_ARGS variable that any test can use. Or at least I think that's better than individual tests needing to figure it out. But I'm not entirely sure how best to approach that.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the fmt-write-bloat test and the linkage changes from #128807, then inspect run-make-support and compiletest as possible places for shared handling. Determine how a reusable mechanism can cover the Windows MSVC CRT cases without requiring each test to spell out complex cfg attributes. Done means tests no longer need error-prone, duplicated linkage logic while avoiding the msvcrt/libcmt conflict.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, developer-experience, testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.