rthornton128 / goncurses

NCurses Library for Go
Other
383 stars 51 forks source link

Build fail: `lvalue required as left operand of assignment` #73

Closed zamsyt closed 2 months ago

zamsyt commented 1 year ago

I was getting invalid flag in pkg-config --libs: -Wl,--push-state,--as-needed, and that was fixed with export CGO_CFLAGS_ALLOW=".*" && export CGO_LDFLAGS_ALLOW=".*". But now I'm getting this when running go build:

# github.com/rthornton128/goncurses
goncurses.c: In function ‘goncurses_set_escdelay’:
goncurses.c:96:12: error: lvalue required as left operand of assignment
   96 |   ESCDELAY = size;
      |            ^

I'm on openSUSE (Tumbleweed), go1.20.2

zamsyt commented 1 year ago

If I try to build via make, again I get

CGO_LDFLAGS_ALLOW=-Wl,-Bsymbolic-functions go build
github.com/rthornton128/goncurses: invalid flag in pkg-config --libs: -Wl,--push-state,--as-needed
make: *** [Makefile:4: build] Error 1
servusdei2018 commented 1 year ago

@zamsyt Try again and add CGO_CFLAGS_ALLOW="-Wl,--push-state,--as-needed" to your environment.

zamsyt commented 1 year ago

Try again and add CGO_CFLAGS_ALLOW="-Wl,--push-state,--as-needed" to your environment.

@servusdei2018 Is that meant to fix something that export CGO_CFLAGS_ALLOW=".*" && export CGO_LDFLAGS_ALLOW=".*" didn't? Anyway, if this is what you meant, changes nothing:

$ go build
github.com/rthornton128/goncurses: invalid flag in pkg-config --libs: -Wl,--push-state,--as-needed
$ export CGO_CFLAGS_ALLOW="-Wl,--push-state,--as-needed"
$ go build
github.com/rthornton128/goncurses: invalid flag in pkg-config --libs: -Wl,--push-state,--as-needed

Idk what it means, but the same for LDFLAGS at least gives something slightly different:

$ export CGO_LDFLAGS_ALLOW="-Wl,--push-state,--as-needed"
$ go build
github.com/rthornton128/goncurses: invalid flag in pkg-config --libs: -Wl,--pop-state
servusdei2018 commented 1 year ago

Try again and add CGO_CFLAGS_ALLOW="-Wl,--push-state,--as-needed" to your environment.

@servusdei2018 Is that meant to fix something that export CGO_CFLAGS_ALLOW=".*" && export CGO_LDFLAGS_ALLOW=".*" didn't?

Yes, those are part of a set of environment variables that are an allowlist/blocklist for flags passed during the CGO compilation process. Generally its better to allow specific flags rather than any/all, as that may result in arbitrary code execution.

It's more of a tangent on my part, but going back to the problem I'm guessing that somehow ESCDELAY is undefined which is why it's not an lvalue. I'm not sure why that would be the case, unless pkg-config is somehow messing up with ncurses but there would probably be a lot more errors if that were the case.

rthornton128 commented 2 months ago

Closing this as a stale or resolved issue. This seems to be a very isolated issue but if it becomes more prevalent, a new issue can be opened to address it.