Skip to content

Automatically pass /guard:cf to MSVC compiler when Control Flow Guard is enabled in rustc flags #557

Open
@roblabla

Description

@roblabla

This is a bit of a longshot, and I'm not sure if it makes sense. When compiling with -C control-flow-guard=yes, it'd be really cool if C code build with cc-rs was automatically built with the equivalent flag (e.g. /guard:cf). This would allow projects to get an almost complete protection just by setting a variable in their .cargo/config file, instead of having to manually set the appropriate environment variable (which requires some kind of build orchestration tool on top of cargo to automatically set the variable, as I don't think cargo has any way to set environment variables on its own for the whole build?).

I'm not sure if this can be achieved in a practical way though. For one, I'm not entirely sure if build scripts have a reliable way of getting the target RUSTFLAGS, or otherwise knowing whether control-flow-guard is enabled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions