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

CGO failed processing error #49

Open
tongfuu opened this issue Feb 24, 2023 · 3 comments
Open

CGO failed processing error #49

tongfuu opened this issue Feb 24, 2023 · 3 comments

Comments

@tongfuu
Copy link

tongfuu commented Feb 24, 2023

Hi, I have encountered this error: "go list failed to return CompiledGoFiles. This may indicate failure to perform cgo processing; try building at the command line. See https://golang.org/issue/38990." after I installed the package locally.

  • This is the relevant go env
      set GO111MODULE=on
      set GOENV=C:\Users\USERNAME\AppData\Roaming\go\env
      set GOPATH=C:\Users\USERNAME\go
      set GOPROXY=https://proxy.golang.org,direct
      set GOROOT=C:\Program Files\Go
      set GOVERSION=go1.19.2
      set GCCGO=gccgo
      set CC=gcc
      set CXX=g++
      set CGO_ENABLED=1
      set GOMOD=C:\Users\USERNAME\go\pkg\mod\github.com\microsoft\[email protected]\go.mod  
      set CGO_CFLAGS=-g -O2
      set CGO_CPPFLAGS=
      set CGO_CXXFLAGS=-g -O2
      set CGO_FFLAGS=-g -O2
      set CGO_LDFLAGS=-g -O2
      set PKG_CONFIG=pkg-config
      set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-
  • When I run go list -json -compiled -e
    {
            "Dir": "C:\\Users\\USERNAME\\go\\pkg\\mod\\github.com\\microsoft\\[email protected]\\openssl",
            "ImportPath": "github.com/microsoft/go-crypto-openssl/openssl",
            "Name": "openssl",
            "Root": "C:\\Users\\USERNAME\\go\\pkg\\mod\\github.com\\microsoft\\[email protected]",
            "Module": {
                    "Path": "github.com/microsoft/go-crypto-openssl",
                    "Main": true,
                    "Dir": "C:\\Users\\USERNAME\\go\\pkg\\mod\\github.com\\microsoft\\[email protected]",
                    "GoMod": "C:\\Users\\USERNAME\\go\\pkg\\mod\\github.com\\microsoft\\[email protected]\\go.mod",        
                    "GoVersion": "1.16"
            },
            "Match": [
                    "."
            ],
            "Stale": true,
            "StaleReason": "not installed but available in build cache",
            "GoFiles": [
                    "big.go"
            ],
            "CompiledGoFiles": [
                    "big.go"
            ],
            "IgnoredGoFiles": [
                    "aes.go",
                    "aes_test.go",
                    "ecdh.go",
                    "ecdh_test.go",
                    "ecdsa.go",
                    "ecdsa_test.go",
                    "evpkey.go",
                    "openssl_funcs.h"
            ]
    }
  • My gopls settings
    {
      // "go.buildFlags": ["-tags=linux,!android"],
      "gopls": {
          "build.experimentalWorkspaceModule": true,
          "build.allowModfileModifications": true
      }
   }

It seems to ignore those files with C imported, so basically the only file that is successfully compiled is big.go, and this made my code that uses this package not able to recognize functions/identifiers in those cgo files. For example, it can only understand openssl.BigInt because this is the only thing that is compiled. All other requests, such as openssl.NewAESCipher, will have error similar to this shown: "undefined: openssl.NewAESCipher" with yellow squiggly lines "NewAESCipher not declared by package openssl (compile)"

Is there something wrong with my gopls settings, or is it an issue with go version (go.mod indicates 1.16 yet go version is 1.19)? Thanks!

@dagood
Copy link
Member

dagood commented Feb 27, 2023

set GOPATH=C:\Users\USERNAME\go

The path shows that you're on Windows, however this module is only supported on Linux: https://github.com/microsoft/go-crypto-openssl#limitations. (@qmuntal, is this meant to be smoother when the platform doesn't match? Or would that be bad to maintain vs. the stuff we already detect in microsoft/go?)

(For Windows CNG crypto, we have https://github.com/microsoft/go-crypto-winnative.)

Why are you looking at this library in particular? For most scenarios (particularly inside Microsoft), these libraries will automatically be used when you use FIPS mode with our fork of the Go Toolset:
https://github.com/microsoft/go/tree/microsoft/main/eng/doc/fips
https://github.com/microsoft/go#readme

@rleighton
Copy link

rleighton commented Feb 29, 2024

@dagood I stumbled on this ticket but I'm struggling with a different issue. Do you have an example of a build command for a shared executable that properly links to openssl.?

I keep getting: "openssl: can't load libcrypto.so.3: Dynamic loading not supported"

@rleighton
Copy link

@dagood I stumbled on this ticket but I'm struggling with a different issue. Do you have an example of a build command for a shared executable that properly links to openssl.?

I keep getting: "openssl: can't load libcrypto.so.3: Dynamic loading not supported"

Sported this . Was using zig with musl. Needed to switch to gnu

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

3 participants