Skip to content

Remove NIX_CFLAGS_COMPILE where possible #79303

@nh2

Description

@nh2

Problem

NIX_CFLAGS_COMPILE is a low-level hack that sneaks compiler arguments past packages' build systems.

It has various drawbacks:

  • the build system cannot see the flag, thus intended upstream logic in the build system is potentially not activated
  • generated files, such as pkg-config .pc files, may lack the necessary entries, making problems for downstream packages
  • the flag does not show up in the build logs, making it unclear what's happening

Because many packages use NIX_CFLAGS_COMPILE, more packages get it added when people copy this style.

Solution

It is better to pass CFLAGS, CXXFLAGS and so on directly to the build system via the method intended to pass compiler flags, for example (feel free to edit this to add more build systems):

Delivery

I think we should run a nixpkgs-wide sprint (like #79064) to do this switch for as many packages as possible.

We should also update the documentation to recommend better alternatives to this hack (like above).

Metadata

Metadata

Assignees

No one assigned

    Labels

    2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md3.skill: sprintableA larger issue which is split into distinct actionable tasks9.needs: clean-upSomebody please clean up this mess!
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions