Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

This executable was compiled without using Go modules #4

Closed
bakito opened this issue Nov 26, 2018 · 11 comments
Closed

This executable was compiled without using Go modules #4

bakito opened this issue Nov 26, 2018 · 11 comments

Comments

@bakito
Copy link

bakito commented Nov 26, 2018

I'm trying to get golicense to run on windows with go 1.11.2 and modules enabled.
Golicense tells me that the module was not compiled with go modules or has no dependencies.
Both is not correct.

Error Message:

golicense.exe ro.exe
⚠️  "ro.exe" ⚠️

This executable was compiled without using Go modules or has
zero dependencies. golicense considers this an error (exit code 1).

Go Modules:
GO111MODULE=on

Go Env:

set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\xxx\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\...
set GOPROXY=
set GORACE=
set GOROOT=C:\...
set GOTMPDIR=
set GOTOOLDIR=C:\...
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\...
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\...=/tmp/go-build -gno-record-gcc-switches

go.mod:

module my.corp.com/ro

require (
	cloud.google.com/go v0.32.0 // indirect
	github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf
	github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 // indirect
	github.com/coreos/prometheus-operator v0.25.0 // indirect
	github.com/emicklei/go-restful v2.8.0+incompatible // indirect
	github.com/ghodss/yaml v1.0.0 // indirect
	github.com/go-logr/logr v0.1.0 // indirect
	github.com/go-logr/zapr v0.1.0 // indirect
	github.com/go-openapi/spec v0.17.2 // indirect
	github.com/gogo/protobuf v1.1.1 // indirect
	github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect
	github.com/golang/groupcache v0.0.0-20181024230925-c65c006176ff // indirect
	github.com/golang/mock v1.1.1
	github.com/golang/protobuf v1.2.0 // indirect
	github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c // indirect
	github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf // indirect
	github.com/googleapis/gnostic v0.2.0 // indirect
	github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
	github.com/hashicorp/golang-lru v0.5.0 // indirect
	github.com/imdario/mergo v0.3.6 // indirect
	github.com/json-iterator/go v1.1.5 // indirect
	github.com/mattbaird/jsonpatch v0.0.0-20171005235357-81af80346b1a // indirect
	github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
	github.com/modern-go/reflect2 v1.0.1 // indirect

	github.com/openshift/api v3.9.0+incompatible // v3.9.0
	github.com/operator-framework/operator-sdk v0.1.0 // v0.1.0
	github.com/pborman/uuid v1.2.0 // indirect
	github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
	github.com/pkg/errors v0.8.0 // indirect
	github.com/prometheus/client_golang v0.9.1
	github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 // indirect
	github.com/prometheus/common v0.0.0-20181020173914-7e9e6cabbd39 // indirect
	github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d // indirect
	github.com/sirupsen/logrus v1.2.0
	github.com/spf13/pflag v1.0.3 // indirect
	github.com/stretchr/testify v1.2.2
	go.uber.org/atomic v1.3.2 // indirect
	go.uber.org/multierr v1.1.0 // indirect
	go.uber.org/zap v1.9.1 // indirect
	golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16 // indirect
	golang.org/x/net v0.0.0-20181102091132-c10e9556a7bc // indirect
	golang.org/x/oauth2 v0.0.0-20181105165119-ca4130e427c7 // indirect
	golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 // indirect
	gopkg.in/inf.v0 v0.9.1 // indirect
	k8s.io/api v0.0.0-20180712090710-2d6f90ab1293 // kubernetes-1.11.2
	k8s.io/apiextensions-apiserver v0.0.0-20180808065829-408db4a50408 // kubernetes-1.11.2
	k8s.io/apimachinery v0.0.0-20180621070125-103fd098999d // kubernetes-1.11.2
	k8s.io/client-go v0.0.0-20180806134042-1f13a808da65 // kubernetes-1.11.2
	k8s.io/kube-openapi v0.0.0-20181031203759-72693cb1fadd // indirect
	sigs.k8s.io/controller-runtime v0.1.4 //  v0.1.4

)
@mitchellh
Copy link
Owner

Everything looks sane so I imagine something in the binary parsing isn't quite right. I'll try to take a look. If this is an open source project could you upload the EXE file somewhere? I think I can try to analyze it from non-Windows too and at a minimum see if that works. If it does, I can try to get a windows machine to debug further.

@bakito
Copy link
Author

bakito commented Nov 26, 2018

Unfortunately it is a closed src project. But I can try with an opensource one and upload that.

@mitchellh
Copy link
Owner

That'd be helpful, thanks!

@bakito
Copy link
Author

bakito commented Nov 26, 2018

You could also reproduce it with your binary golicense_0.1.1_windows_x86_64. With this one I'll get the same error.

@mitchellh
Copy link
Owner

Oh of course. I'll give that a shot. Thanks

@bakito
Copy link
Author

bakito commented Nov 26, 2018

here would be the binary of one of my public projects: https://gist.github.com/bakito/26a7be21e592a648c518ace32083a8a8

From : https://github.com/bakito/request-logger

@brimstone
Copy link

For my ELF executable with this symptom, I was able to track it down to the executable having multiple rodata sections, only the first of which rsc's version detected. Modifying version to search multiple sections for module information fixed it. I'm happy to help fix this, let me know how you'd like me to proceed.

@mitchellh
Copy link
Owner

Hey @brimstone, awesome find. I haven't verified that this is the same issue happening here but regardless that's a great thing to find. I see your PR on rsc/goversion. Let's see if we get a merge and if not I can temporarily fork as well.

@rfay
Copy link

rfay commented Dec 4, 2018

We have the same problem with open-source https://github.com/drud/ddev, it's open-source, just make does the job. golicense v0.1.1 demonstrates it. Artifacts at https://circleci.com/gh/drud/ddev/6870#artifacts/containers/0

The normal way of building this (go 1.11) is just make. It can be built with make BUILD_IMAGE=drud/golang-build-container:v1.11.2 to use our latest container with golang v1.11.2.

Edit:

  • I notice that if I just build this with go install ./... the resulting binary can be analyzed by golicense;
  • the full recipe used by our build system and build container is go install -installsuffix static -ldflags ' -extldflags -static -X "github.com/drud/ddev/pkg/version.DdevVersion=v1.4.1-26-g8dc7910c-dirty" -X "github.com/drud/ddev/pkg/version.VERSION=v1.4.1-26-g8dc7910c-dirty" -X "github.com/drud/ddev/pkg/version.COMMIT=v1.4.1-26-g8dc7910c-dirty" -X "github.com/drud/ddev/pkg/version.BUILDINFO=Built Tue Dec 4 07:48:05 MST 2018 rfay@rfay-mbp-2017 drud/golang-build-container:v1.11.2" ' ./cmd/... ./pkg/...
  • If I use just go install -installsuffix static -ldflags ' -extldflags -static -X "github.com/drud/ddev/pkg/version.DdevVersion=v1.4.1-26-g8dc7910c-dirty" -X "github.com/drud/ddev/pkg/version.VERSION=v1.4.1-26-g8dc7910c-dirty" -X "github.com/drud/ddev/pkg/version.COMMIT=v1.4.1-26-g8dc7910c-dirty" -X "github.com/drud/ddev/pkg/version.BUILDINFO=Built Tue Dec 4 07:48:05 MST 2018 rfay@rfay-mbp-2017 drud/golang-build-container:v1.11.2" ' ./cmd/... ./pkg/... on the host (instead of using container) I also get a query-able binary.

So something about how we mount the source and objects into the container is affecting this.

@mtenberge
Copy link

I have the same problem with one of my binaries (while licenses in another comparable binary are detected fine).

The problematic binary uses CGo (i.e. some loose C functions and an external static C library are linked into the final executable), the other does not. Seeing that @bakito also has CGO-environment variables set, I suspect that CGo has something to do with it.

@majodev
Copy link

majodev commented Oct 8, 2020

We were also bitten by this. As far as I understand it, you are currently constrained by what rsc/goversion's ReadExe() will report in it's ModuleInfo.

A potential workaround to that may be to use the output of go version -m -v <binary> to get the embedded modules there, as it should be more accurate (and also officially maintained) going forward. I'm not sure however if it's possible to directly include this handling in the golicense binary (without having to install the whole go toolchain)...

@bakito bakito closed this as not planned Won't fix, can't repro, duplicate, stale Dec 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants