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

No debug info when building Kubernetes source code with make all GOGCFLAGS="-N -l" #77527

Closed
qianzhangxa opened this issue May 7, 2019 · 8 comments · Fixed by #77596
Closed
Labels
kind/bug Categorizes issue or PR as related to a bug. sig/release Categorizes an issue or PR as relevant to SIG Release.

Comments

@qianzhangxa
Copy link

What happened:
I ran make all GOGCFLAGS="-N -l" to build latest Kubernetes source code, and then I see the binaries are still stripped:

$ file _output/bin/kubelet 
_output/bin/kubelet: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=715f57807e652488c5e086b82f5daf4063a74b04, stripped

And I can not use dlv to debug the binary:

$ dlv exec _output/bin/kubelet                          
could not launch process: could not open debug info

In Makefile, I see the following comments:

#   make all GOGCFLAGS="-N -l"
#     Note: Use the -N -l options to disable compiler optimizations an inlining.
#           Using these build options allows you to subsequently use source
#           debugging tools like delve.

But that seems not correct in my build.

What you expected to happen:
I expected Kubernetes binaries with debug info.

How to reproduce it (as minimally and precisely as possible):
make all GOGCFLAGS="-N -l"

Anything else we need to know?:

Environment:

  • Kubernetes version (use kubectl version): Latest Kubernetes source code.
  • Cloud provider or hardware configuration: A virtual machine with 2 cores and 8GB RAM.
  • OS (e.g: cat /etc/os-release): 18.04 LTS (Bionic Beaver)
  • Kernel (e.g. uname -a): Linux workstation 4.15.0-23-generic Change 'this' varable to more sensible abbreviation #25-Ubuntu SMP Wed May 23 18:02:16 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
  • Install tools:
  • Network plugin and version (if this is a network-related bug):
  • Others:
@qianzhangxa qianzhangxa added the kind/bug Categorizes issue or PR as related to a bug. label May 7, 2019
@k8s-ci-robot k8s-ci-robot added the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label May 7, 2019
@qianzhangxa
Copy link
Author

/sig release

@k8s-ci-robot k8s-ci-robot added sig/release Categorizes an issue or PR as relevant to SIG Release. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels May 7, 2019
@YoubingLi
Copy link

It is the problem of "-ldflags -s -w" and I will provide a PR ASAP.

/cc @YoubingLi

@dims
Copy link
Member

dims commented May 7, 2019

@YoubingLi @qianzhangxa please set GOLDFLAGS to an empty string and see if that helps

7e01702

@YoubingLi
Copy link

@dims
Yes, this is my fix solution (Remove '-s -w' from goldflags).
Meanwhile, I had verified that it works.

@qianzhangxa
Copy link
Author

qianzhangxa commented May 8, 2019

@dims @YoubingLi I tried make all GOGCFLAGS="-N -l" GOLDFLAGS="" and it works! So I think the comments in the Makefile need to be updated a bit since only GOGCFLAGS="-N -l" is not enough for debugger to debug Kubernetes binaries.

@YoubingLi
Copy link

@qianzhangxa

It should work after you explicitly specify GOLDFLAGS="" in command line.

If GOLDFLAGS is not specified, the default value is "-w -s". It turns out all binaries are built as stripped.

@dims
Copy link
Member

dims commented May 8, 2019

@qianzhangxa @YoubingLi yes, please update comments in the Makefile to make all GOGCFLAGS="-N -l" GOLDFLAGS=""

@Davidrjx
Copy link

in my case for kubernetes1.13.5, removing '-s -w' from goldflags is enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. sig/release Categorizes an issue or PR as relevant to SIG Release.
Projects
None yet
5 participants