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

Better workaround for warning with nix #2372

Closed
Luflosi opened this issue Feb 17, 2020 · 2 comments
Closed

Better workaround for warning with nix #2372

Luflosi opened this issue Feb 17, 2020 · 2 comments

Comments

@Luflosi
Copy link
Contributor

Luflosi commented Feb 17, 2020

When building kitty for nix, the compilation would fail:

building
CC: clang (4, 2)
[4/55] Compiling kitty/fonts.c ... done ...
Compiling kitty/screen.c ...
clang -MMD -DNDEBUG -DPRIMARY_VERSION=4000 -DSECONDARY_VERSION=16 -Wextra -Wno-missing-field-initializers -Wall -Wstrict-prototypes -std=c11 -pedantic-errors -Werror -O3 -fwrapv -fstack-protector-strong -pipe -march=native -fvisibility=hidden -D_FORTIFY_SOURCE=2 -pthread -I/nix/store/r66qbg89vfk21rilhx62ylviq982zf70-libpng-apng-1.6.37-dev/include/libpng16 -I/nix/store/wnp6bg1d6xf557200sc2hbkks2vkj3ll-zlib-1.2.11-dev/include -I/nix/store/5m21j8vqa45hr7dc99r8kxkqa7rpm4fh-harfbuzz-2.6.4-dev/include/harfbuzz -I/nix/store/9dswjy6wfc5qrmrpwp1pl986anc36bcn-python3-3.7.6/include/python3.7m -c kitty/screen.c -o build/fast_data_types-screen.c.o
clang-7: error: argument unused during compilation: '-fno-strict-overflow' [-Werror,-Wunused-command-line-argument]
builder for '/nix/store/r04zplcjdfc1rmswmrgg22mw1shh4bys-kitty.drv' failed with exit code 1
error: build of '/nix/store/r04zplcjdfc1rmswmrgg22mw1shh4bys-kitty.drv' failed

To work around this problem, the compiler command line options-pedantic-errors and -Werror are patched out of setup.py. I don't think that's a very good solution, so I wanted to change that. A slightly better workaround would be to add -Wno-unused-command-line-argument, which suppresses the warning but ideally we would just not pass the option in the first place. But I am puzzled why the warning is there. It warns, that the option -fno-strict-overflow was not used. But it is not even passed to clang and also doesn't occur anywhere in kitty's source code.
I also don't really know why this doesn't happen when I compile kitty outside of nix, maybe there is a difference between clang from Xcode and clang from nix.

@kovidgoyal
Copy link
Owner

This will be because nix's build system is adding flags to compiler
invocations behind the back. Presumably the clang that is invoked on nix
is a wrapper that calls the actual clang with added flags. There's
nothing that can be done about that in kitty, since we have no way
to detect modified clang implementations.

If I am correct nix needs to stop messing with compiler flags. If they
feel a flag should be present they need to work with upstream to get it
added.

NixOS/nixpkgs#18995
NixOS/nixpkgs#39687

I am certainly not going to add flags to kitty's build system to
accommodate this buggy behavior of nix.

@Luflosi
Copy link
Contributor Author

Luflosi commented Feb 18, 2020

Thank you, your tip was very helpful. I agree, this is not a problem that should be fixed in kitty. I found a way to disable that particular compiler flag in the build environment.

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