Skip to content

Properly handle the NixOS compiler wrapper #1448

@Rua

Description

@Rua

A followup to discussion at #1341. Pinging people who have recently made Nix-related PRs: @Chobbes @RossSmyth

Compilers (gcc, clang at least) are actually implemented on NixOS as a wrapper shell script that then invokes the real compiler binary. One of the things this wrapper does is add a variety of command line arguments that let the compiler find its libraries and header files. Without those, pretty much nothing builds. The problem with c2rust is that it links directly to clang/LLVM as a library, so it's invoking the compiler without these additional arguments, and so transpilation fails. This problem extends also to the c2rust tests.

There are three possible ways around this that I can think of:

  1. The user ensures that the compile_commands.json contains these additional arguments, so that they are passed to the LLVM library by c2rust. This places the burden on the user to fiddle with these Nix-internal details.
  2. c2rust adds the additional arguments itself, so that things "just work" on NixOS from the user's point of view. Better for the user, but then c2rust has to deal with it instead, and most of the devs don't use or know NixOS stuff.
  3. NixOS provides a wrapper for the LLVM library in addition to the binary. This needs cooperation from the NixOS side, unless there already is such a wrapper?

The changes made in #1341 go with the first method, but it's incomplete. While c2rust itself builds and runs, and the Python tests run correctly, cargo test does not work, which includes the snapshot tests.

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