Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiler-rt-libc-*-dev not available in nixpkgs cc toolchain #442

Open
iphydf opened this issue Nov 8, 2023 · 2 comments
Open

compiler-rt-libc-*-dev not available in nixpkgs cc toolchain #442

iphydf opened this issue Nov 8, 2023 · 2 comments

Comments

@iphydf
Copy link

iphydf commented Nov 8, 2023

Describe the bug
#include <sanitizer/msan_interface.h> fails to compile on bazel with nixpkgs. It works with clang++.

To Reproduce
Create a C file with #include <sanitizer/msan_interface.h> in it. Observe:

myfile.c:1:10: fatal error: 'sanitizer/msan_interface.h' file not found

Expected behavior
It should compile.

Environment

  • OS name + version: NixOS 23.05
  • Version of the code: v0.10.0

Additional context
The include directory is known to clang++:

[nix-shell:/src/workspace]$ clang++ -c -xc++ - -v
...
 /nix/store/l4mfdpx5d4ybn6ki1gjhlcmz6hv5p6kh-compiler-rt-libc-16.0.1-dev/include
...
@avdv
Copy link
Member

avdv commented Nov 8, 2023

Hi.

I think you should be able to use the library like any other, e.g. with

nixpkgs_package(
    name = "compiler-rt-libc",
    attribute_path = "llvmPackages_16.compiler-rt-libc",
    nix_file_content = """import <nixpkgs> { }""",
    repository = "@nixpkgs",
)

nixpkgs_package(
    name = "compiler-rt-libc.dev",
    attribute_path = "llvmPackages_16.compiler-rt-libc.dev",
    build_file_content = """\
load("@rules_cc//cc:defs.bzl", "cc_library")
filegroup(
    name = "include",
    srcs = glob(["include/**/*.h"]),
    visibility = ["//visibility:public"],
)
cc_library(
    name = "compiler-rt-libc",
    srcs = ["@compiler-rt-libc//:lib"],
    hdrs = [":include"],
    strip_include_prefix = "include",
    visibility = ["//visibility:public"],
)
""",
    nix_file_content = """import <nixpkgs> { }""",
    repository = "@nixpkgs",
)

@iphydf
Copy link
Author

iphydf commented Nov 8, 2023

The problem is that Go stdlib uses that (when compiling with msan) but doesn't declare it, because it's assumed to be part of the toolchain. Same with absl and probably other third party dependencies.

iphydf added a commit to iphydf/c-toxcore that referenced this issue Nov 8, 2023
Better error messages than "something went wrong in type 20".

Also fix bazel-asan/tsan builds.

tweag/rules_nixpkgs#442 is blocking fuzz
tests under asan.
freylax pushed a commit to nodecum/c-toxcore that referenced this issue Jan 13, 2024
Better error messages than "something went wrong in type 20".

Also fix bazel-asan/tsan builds.

tweag/rules_nixpkgs#442 is blocking fuzz
tests under asan.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants