Skip to content

is_flag_supported only works for C sources #359

@nagisa

Description

@nagisa

is_flag_supported is implemented by attempting to compile a C file. This will obviously fail to correctly work when check is done in a non-C context.

For example:

    let mut cfg = cc::Build::new();
    cfg.flag_if_supported("-xassembler-with-cpp");
    cfg.file(asm);
    cfg.compile("libanan.a");

will fail to correctly identify that the flag is supported, because -xassembler-with-cpp will try to compile the C file as assembly, which will obviously fail.

This failure condition is not documented.

For at least gcc and clang the file compiled does not need to have any contents within it at all. For example:

echo "" | $CC $TESTED_FLAG -c - -o /tmp/test.o

will correctly test the $TESTED_FLAG.

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