Skip to content

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

Open
@jieyouxu

Description

@jieyouxu

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-compiletestArea: The compiletest test runnerA-linkageArea: linking into static, shared libraries and binariesA-run-makeArea: port run-make Makefiles to rmake.rsC-cleanupCategory: PRs that clean code up or issues documenting cleanup.E-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.E-needs-designThis issue needs exploration and design to see how and if we can fix/implement itE-needs-investigationCall for partcipation: This issues needs some investigation to determine current statusO-windows-msvcToolchain: MSVC, Operating system: WindowsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions