PowerDNS / lmdb-go

Bindings for the LMDB C library
BSD 3-Clause "New" or "Revised" License
13 stars 7 forks source link

many warnings on go run or go build #31

Open igor35hh opened 11 months ago

igor35hh commented 11 months ago

Hi guys, want to replace bmatsuo/lmdb-go on yours that is more fresh, but have many warnings on start or build an application.

go version go1.21.5 darwin/arm64

go get github.com/PowerDNS/lmdb-go/lmdb go: downloading github.com/PowerDNS/lmdb-go v1.9.2 go: added github.com/PowerDNS/lmdb-go v1.9.2

go build cmd/main.go           
# github.com/PowerDNS/lmdb-go/lmdb
warning: unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'? [-Wunknown-warning-option]
# github.com/PowerDNS/lmdb-go/lmdb
warning: unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'? [-Wunknown-warning-option]
# github.com/PowerDNS/lmdb-go/lmdb
warning: unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'? [-Wunknown-warning-option]
# github.com/PowerDNS/lmdb-go/lmdb
warning: unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'? [-Wunknown-warning-option]
# github.com/PowerDNS/lmdb-go/lmdb
warning: unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'? [-Wunknown-warning-option]
# github.com/PowerDNS/lmdb-go/lmdb
warning: unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'? [-Wunknown-warning-option]
# github.com/PowerDNS/lmdb-go/lmdb
warning: unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'? [-Wunknown-warning-option]
# github.com/PowerDNS/lmdb-go/lmdb
warning: unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'? [-Wunknown-warning-option]
# github.com/PowerDNS/lmdb-go/lmdb
warning: unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'? [-Wunknown-warning-option]
# github.com/PowerDNS/lmdb-go/lmdb
warning: unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'? [-Wunknown-warning-option]
# github.com/PowerDNS/lmdb-go/lmdb
warning: unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'? [-Wunknown-warning-option]
# github.com/PowerDNS/lmdb-go/lmdb
warning: unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'? [-Wunknown-warning-option]
# github.com/PowerDNS/lmdb-go/lmdb
warning: unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'? [-Wunknown-warning-option]
go run cmd/main.go -f configs/dev_copy.json 
# github.com/PowerDNS/lmdb-go/lmdb
warning: unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'? [-Wunknown-warning-option]
# github.com/PowerDNS/lmdb-go/lmdb
warning: unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'? [-Wunknown-warning-option]
# github.com/PowerDNS/lmdb-go/lmdb
warning: unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'? [-Wunknown-warning-option]
# github.com/PowerDNS/lmdb-go/lmdb
warning: unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'? [-Wunknown-warning-option]
# github.com/PowerDNS/lmdb-go/lmdb
warning: unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'? [-Wunknown-warning-option]
# github.com/PowerDNS/lmdb-go/lmdb
warning: unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'? [-Wunknown-warning-option]
# github.com/PowerDNS/lmdb-go/lmdb
warning: unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'? [-Wunknown-warning-option]
# github.com/PowerDNS/lmdb-go/lmdb
warning: unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'? [-Wunknown-warning-option]
# github.com/PowerDNS/lmdb-go/lmdb
warning: unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'? [-Wunknown-warning-option]
# github.com/PowerDNS/lmdb-go/lmdb
warning: unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'? [-Wunknown-warning-option]
# github.com/PowerDNS/lmdb-go/lmdb
warning: unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'? [-Wunknown-warning-option]
# github.com/PowerDNS/lmdb-go/lmdb
warning: unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'? [-Wunknown-warning-option]
# github.com/PowerDNS/lmdb-go/lmdb
warning: unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'? [-Wunknown-warning-option]
shane-ns1 commented 10 months ago

This is probably my fault, since I introduced the PR that disabled this warning.

It might be something that can be fixed by upgrading gcc. I'm using this version here:

$ gcc --version
gcc (GCC) 13.2.1 20231011 (Red Hat 13.2.1-4)
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

If you're not using gcc then I guess it is because clang does not (yet?) support this warning.

It may also be that the M1 CPU does not have support for this warning.

Ideally this could be fixed just by updating the compiler, but if not then we'll either need to back out the change (which is bad because that introduces warnings to other systems) or figure out how to add the -Wno-stringop-overflow option conditionally.

So... maybe you can see what gcc version you're using?

igor35hh commented 10 months ago

This is probably my fault, since I introduced the PR that disabled this warning.

It might be something that can be fixed by upgrading gcc. I'm using this version here:

$ gcc --version
gcc (GCC) 13.2.1 20231011 (Red Hat 13.2.1-4)
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

If you're not using gcc then I guess it is because clang does not (yet?) support this warning.

It may also be that the M1 CPU does not have support for this warning.

Ideally this could be fixed just by updating the compiler, but if not then we'll either need to back out the change (which is bad because that introduces warnings to other systems) or figure out how to add the -Wno-stringop-overflow option conditionally.

So... maybe you can see what gcc version you're using?

sure gcc --version Apple clang version 15.0.0 (clang-1500.0.40.1) Target: arm64-apple-darwin23.1.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin

chip: Apple M1 Pro

wojas commented 10 months ago

I can confirm that I see the same warnings. Same clang version, on macOS Ventura.

I guess the options are:

  1. Simply remove -Wno-stringop-overflow.
  2. Replace -Wno-stringop-overflow by something supported by both gcc and clang, if such an option exists.
  3. Add -Wno-unknown-warning-option to hide warnings about unknown warning options.

@shane-ns1 What do you think?

shane-ns1 commented 10 months ago

If clang supports the -Wno-unknown-warning-option then that is probably the best approach, right? That seems to be exactly what it is designed for:

When an unrecognized warning option is requested (e.g., -Wunknown-warning), GCC emits a diagnostic stating that the option is not recognized. However, if the -Wno- form is used, the behavior is slightly different: no diagnostic is produced for -Wno-unknown-warning unless other diagnostics are being produced. This allows the use of new -Wno- options with old compilers, but if something goes wrong, the compiler warns that an unrecognized option is present.

https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html