Skip to content

Any way to suppress Clang warnings? ("argument unused during compilation") #273

@vittorioromeo

Description

@vittorioromeo

Hello, I am using hedron_compile_commands in a fairly large Bazel project that uses Clang as the main compiler. While it works, it spews a lot of warnings/errors, e.g.:

clang: error: argument unused during compilation: '-c' [-Werror,-Wunused-command-line-argument]
clang: error: argument unused during compilation: '-c' [-Werror,-Wunused-command-line-argument]
clang: error: argument unused during compilation: '-c' [-Werror,-Wunused-command-line-argument]
clang: error: argument unused during compilation: '-c' [-Werror,-Wunused-command-line-argument]
clang: error: argument unused during compilation: '-c' [-Werror,-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-c' [-Wunused-command-line-argument]
clang: error: argument unused during compilation: '-c' [-Werror,-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-c' [-Wunused-command-line-argument]
clang: error: argument unused during compilation: '-c' [-Werror,-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-c' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-c' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-c' [-Wunused-command-line-argument]

This is how I set up the LLVM toolchain:

bazel_dep(name = "toolchains_llvm", version = "1.3.0")

LLVM_COMMIT = "14eb90172b3c5f35bdb2699d006fe0f70e76aa24"

archive_override(
    module_name = "toolchains_llvm",
    sha256 = "d85f78a501d6050fa0f1fb74e1c5f971549cd6d0b9c9147857935c0346c070d0",
    strip_prefix = "toolchains_llvm-{commit}".format(commit = LLVM_COMMIT),
    url = "https://github.com/bazel-contrib/toolchains_llvm/archive/{commit}.tar.gz".format(commit = LLVM_COMMIT),
)

llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")
llvm.toolchain(
    name = "llvm_toolchain",
    cxx_standard = {
        "": "c++23",
    },
    llvm_versions = {
        "": "20.1.0",
    },
)
use_repo(llvm, "llvm_toolchain", "llvm_toolchain_llvm")

register_toolchains("@llvm_toolchain//:all")

This is how I set up the extractor:

bazel_dep(name = "hedron_compile_commands")

COMPILE_COMMANDS_COMMIT = "4f28899228fb3ad0126897876f147ca15026151e"

archive_override(
    module_name = "hedron_compile_commands",
    sha256 = "658122cfb1f25be76ea212b00f5eb047d8e2adc8bcf923b918461f2b1e37cdf2",
    strip_prefix = "bazel-compile-commands-extractor-{commit}".format(commit = COMPILE_COMMANDS_COMMIT),
    url = "https://github.com/hedronvision/bazel-compile-commands-extractor/archive/{commit}.tar.gz".format(commit = COMPILE_COMMANDS_COMMIT),
)

And this is how I set up the command:

refresh_compile_commands(
    name = "refresh_compile_commands",
    targets = {
        "//modules/...": "",
    },
)

Is there any way to suppress/resolve those warnings/errors?

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