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

Cannot run the debugger in NixOS #3085

Closed
namnd opened this issue Jul 30, 2022 · 5 comments
Closed

Cannot run the debugger in NixOS #3085

namnd opened this issue Jul 30, 2022 · 5 comments

Comments

@namnd
Copy link

namnd commented Jul 30, 2022

  1. What version of Delve are you using (dlv version)?

Delve Debugger
Version: 1.9.0
Build: $Id: 69310c2f438e492f892d6af22e8e62c8ea1e9d8d

  1. What version of Go are you using? (go version)?

go version go1.18.2 linux/arm64

  1. What operating system and processor architecture are you using?

Linux devbox 5.15.55 #1-NixOS SMP Fri Jul 15 08:13:00 UTC 2022 aarch64 GNU/Linux

  1. What did you do?

Start debugging test

  1. What did you expect to see?

  2. What did you see instead?

Build Error: go test -c -o /home/../../__debug_bin -gcflags all=-N -l /home/../../**_test.go

runtime/cgo

In file included from /nix/store/y7g7iskbmzpy7wxc4v4sxqg0p3z5w5b4-glibc-2.34-210-dev/include/bits/libc-header-start.h:33,
from /nix/store/y7g7iskbmzpy7wxc4v4sxqg0p3z5w5b4-glibc-2.34-210-dev/include/stdlib.h:25,
from _cgo_export.c:3:
/nix/store/y7g7iskbmzpy7wxc4v4sxqg0p3z5w5b4-glibc-2.34-210-dev/include/features.h:412:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp]
412 | # warning _FORTIFY_SOURCE requires compiling with optimization (-O)
| ^~~~~~~
cc1: all warnings being treated as errors (exit status 2)

@aarzilli
Copy link
Member

See NixOS/nixpkgs#18995. You can probably work around this by setting CGO_CFLAGS to something (it doesn't matter what).

@namnd
Copy link
Author

namnd commented Jul 30, 2022

Thanks @aarzilli i was able to work around by adding hardeningDisable = [ "all" ]; to the shell.nix

@W1M0R
Copy link

W1M0R commented Feb 6, 2023

The NixOS Wiki also suggest adding the following line to shell.nix:

hardeningDisable = [ "fortify" ];

Related:

  1. https://nixos.wiki/wiki/C#Hardening_flags
  2. https://nixos.org/manual/nixpkgs/stable/#sec-hardening-in-nixpkgs
  3. The hardeningDisable environment variable does nothing NixOS/nixpkgs#101979

@adamcstephens
Copy link

the official NixOS wiki is now here: https://wiki.nixos.org/wiki/Go#Using_cgo_on_NixOS

@kelvincesar
Copy link

I can confirm that I was having this problem when debuging a golang program with delve on vscode.

Added the hardeningDisable into my shell.nix and now it is working. Thanks!

pkgs.mkShell {
  hardeningDisable = [ "fortify" ]; 
  ....
}

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

5 participants