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

Fixed vscode debugging issue #314

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

oscar-davids
Copy link
Contributor

Sometimes, the remote debugger broken in vs code and prints error message. here is the output.

@thomshutt
Copy link
Contributor

Not sure if it's because of this change, but looks like the tests are failing on CI

@AlexKordic
Copy link
Contributor

@thomshutt The failing tests are also present here in this commit

@thomshutt
Copy link
Contributor

@AlexKordic Should we open a ticket to fix them then?

@AlexKordic
Copy link
Contributor

@AlexKordic Should we open a ticket to fix them then?

yes

@AlexKordic
Copy link
Contributor

AlexKordic commented Mar 28, 2022

i managed to reproduce error message in the terminal:

go test -c -o /home/alex/livepeer/lpms/transcoder/__debug_bin -gcflags=all="-N -l" . - compiles fine as expected

Command to break build is:

~/livepeer/lpms/transcoder$ CGO_CFLAGS=" -g3 " go test -c -o /home/alex/livepeer/lpms/transcoder/__debug_bin -gcflags=all="-N -l" .
# github.com/livepeer/lpms/ffmpeg
/usr/bin/ld: $WORK/b081/_x006.o: undefined reference to symbol 'ceil@@GLIBC_2.2.5'
/usr/bin/ld: /lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

For some reason CGO_CFLAGS set cause CGO_LDFLAGS to be different ... unknown

Found by experiment following command:

CGO_CFLAGS=" -g3 " CGO_LDFLAGS=" -l m " go test -c -o ./__debug_bin -gcflags=all="-N -l" .
This ^^^ command works as expected

So i have added those 2 flags to settings.json of vscode:

{
....
    "go.toolsEnvVars": {
        "CGO_LDFLAGS" : " -l m ",
        "CGO_CFLAGS" : " -g3 "
    }
}

Not sure why link to libm is required explicitly. This configuration works for me now.

@oscar-davids what do you think should we update development documentation only or we still need to remove the ceil() ?

@cyberj0g
Copy link
Contributor

cyberj0g commented Mar 28, 2022

I have same issue locally and have to comment out ceil function every time. It seem to be caused by incompatible combination of cgo and system glibc versions, which is problematic to resolve. Appeared after upgrading to Ubuntu 21.10 for me. Maybe just find replacement for ceil?

@AlexKordic
Copy link
Contributor

Maybe just find replacement for ceil?

But what about other math functions we want to use in future? Are there any other options to fix this?

@cyberj0g Can you use CGO_CFLAGS=" -g3 " CGO_LDFLAGS=" -l m " go test ..... command locally?

@cyberj0g
Copy link
Contributor

Can you use CGO_CFLAGS=" -g3 " CGO_LDFLAGS=" -l m " go test ..... command locally?

Yes, adding -lm explicitly works. The question is why setting CGO_FLAGS for debugging cause missing -lm after I upgraded only system glibc? All other dependencies seem to be the same, maybe I'm missing something.

@AlexKordic
Copy link
Contributor

Can we use go build flags to add -l m to our project code?

@thomshutt
Copy link
Contributor

I agree with Alex that we should probably try to solve this at a higher level rather than trying to change which functions we use. Would adding the directives in the Go code that calls this work? https://pkg.go.dev/cmd/cgo

image

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

Successfully merging this pull request may close these issues.

4 participants