Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 621928 - dev-lang/go - compilation fails (e.g docker) with "C source files not allowed when not using cgo or SWIG"
Summary: dev-lang/go - compilation fails (e.g docker) with "C source files not allowed...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: William Hubbs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-16 18:25 UTC by Håvard Wall
Modified: 2020-02-02 20:28 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
strace go build cgotest.go (strace.out,355.22 KB, text/plain)
2017-10-25 13:33 UTC, Håvard Wall
Details
ltrace go build cgotest.go (ltrace.out,386.15 KB, text/plain)
2017-10-25 13:42 UTC, Håvard Wall
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Håvard Wall 2017-06-16 18:25:18 UTC
Packages that doesn't compile includes e.g app-emulation/docker-proxy and app-emulation/docker. They all fail with:

        imports runtime: C source files not allowed when not using cgo or SWIG: atomic_amd64x.c defs.c float.c heapdump.c lfstack.c malloc.c mcache.c mcentral.c mem_linux.c mfixalloc.c mgc0.c mheap.c msize.c os_linux.c panic.c parfor.c proc.c runtime.c signal.c signal_amd64x.c signal_unix.c stack.c string.c sys_x86.c vdso_linux_amd64.c

I'm able to reproduce the issue with this minimal program:

# cat <<EOF > cgotest.go
package cgotest

// #include <stdio.h>
// #include <errno.h>
import "C"
EOF

go build cgotest.go


I'm currently using go version go1.8.3 linux/amd64, but this has been an issue since at least 1.8.

I'm able to work around the issue by installing a prebuild go package from golang.org and setting GOROOT to point to that, but would be nice if the package provided by gentoo would work too.
Comment 1 William Hubbs gentoo-dev 2017-08-25 17:43:42 UTC
Hi,

I just unsuccessfully attempted to reproduce this on two machines with
go 1.8.3 and go 1.9 using your minimal program.

"go build cgotest.go" works without errors.

Do you have any more information about why this may not be working for
you?

Thanks,

William
Comment 2 Håvard Wall 2017-10-25 13:23:29 UTC
(In reply to William Hubbs from comment #1)
> Hi,
> 
> I just unsuccessfully attempted to reproduce this on two machines with
> go 1.8.3 and go 1.9 using your minimal program.
> 
> "go build cgotest.go" works without errors.
> 
> Do you have any more information about why this may not be working for
> you?
> 
> Thanks,
> 
> William

Nor sure what info I can provide that would be helpful. I still have this issue with go-1.9.1. On two different machines. This is emerge --info:

Portage 2.3.12 (python 3.6.3-final-0, default/linux/amd64/13.0/systemd, gcc-6.4.0, glibc-2.25-r8, 4.13.8-gentoo x86_64)
=================================================================
System uname: Linux-4.13.8-gentoo-x86_64-Intel-R-_Core-TM-2_Duo_CPU_P8600_@_2.40GHz-with-gentoo-2.4.1
KiB Mem:     3973476 total,    105448 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Wed, 25 Oct 2017 13:00:01 +0000
Head commit of repository gentoo: 9ad31fe3b88753f72a49809a34ec3933bedb5f37
sh bash 4.4_p12
ld GNU ld (Gentoo 2.28.1 p1.0) 2.28.1
app-shells/bash:          4.4_p12::<unknown repository>
dev-lang/perl:            5.26.1::<unknown repository>
dev-lang/python:          2.7.14::<unknown repository>, 3.6.3::<unknown repository>
dev-util/cmake:           3.9.4::<unknown repository>
dev-util/pkgconfig:       0.29.2::<unknown repository>
sys-apps/baselayout:      2.4.1-r2::<unknown repository>
sys-apps/openrc:          0.34.1::<unknown repository>
sys-apps/sandbox:         2.12::<unknown repository>
sys-devel/autoconf:       2.13::<unknown repository>, 2.69-r4::<unknown repository>
sys-devel/automake:       1.11.6-r2::<unknown repository>, 1.12.6-r1::<unknown repository>, 1.13.4-r1::<unknown repository>, 1.14.1-r1::<unknown repository>, 1.15.1-r1::<unknown repository>
sys-devel/binutils:       2.28.1::<unknown repository>, 2.29.1-r1::<unknown repository>
sys-devel/gcc:            5.4.0-r3::<unknown repository>, 6.4.0::<unknown repository>
sys-devel/gcc-config:     1.9.0::<unknown repository>
sys-devel/libtool:        2.4.6-r4::<unknown repository>
sys-devel/make:           4.2.1-r1::<unknown repository>
sys-kernel/linux-headers: 4.13::<unknown repository> (virtual/os-headers)
sys-libs/glibc:           2.25-r8::<unknown repository>
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    sync-rsync-extra-opts: 

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=native -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync multilib-strict news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="acl amd64 berkdb bzip2 cli cracklib crypt cxx dri fortran gdbm iconv ipv6 mmx modules multilib ncurses nls nptl openmp pam pcre readline seccomp session sse sse2 ssl systemd tcpd threads udev unicode xattr zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6" POSTGRES_TARGETS="postgres9_5" PYTHON_SINGLE_TARGET="python3_4" PYTHON_TARGETS="python2_7 python3_4" RUBY_TARGETS="ruby22" USERLAND="GNU" VIDEO_CARDS="amdgpu fbdev intel nouveau radeon radeonsi vesa dummy v4l" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 3 Håvard Wall 2017-10-25 13:33:36 UTC
Created attachment 500052 [details]
strace go build cgotest.go
Comment 4 Håvard Wall 2017-10-25 13:42:19 UTC
Created attachment 500054 [details]
ltrace go build cgotest.go
Comment 5 Håvard Wall 2017-10-25 13:45:51 UTC
(In reply to William Hubbs from comment #1)

# go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/go"
GORACE=""
GOROOT="/usr/lib64/go"
GOTOOLDIR="/usr/lib64/go/pkg/tool/linux_amd64"
GCCGO="/usr/x86_64-pc-linux-gnu/gcc-bin/6.4.0/gccgo"
CC="x86_64-pc-linux-gnu-gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build817888977=/tmp/go-build -gno-record-gcc-switches"
CXX="x86_64-pc-linux-gnu-g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
Comment 6 Håvard Wall 2017-10-25 14:58:33 UTC
An observation: When inspecting the go compiler after the build stage (which works) I see these files:

/var/tmp/paludis/dev-lang-go-1.9.1/work/go # ls src/runtime/atomic_*
atomic_arm64.s     atomic_mipsx.s     atomic_ppc64x.s    
atomic_mips64x.s   atomic_pointer.go 

But looking at the installation directory I see this:

# ls /usr/lib/go/src/runtime/atomic_*
atomic_386.c     atomic_mips64x.s
atomic_amd64x.c  atomic_mipsx.s
atomic_arm64.s   atomic_pointer.go
atomic_arm.go    atomic_ppc64x.s

Note the extra c-files. Is this leftovers from a previous installation? Could this be due to the use of `cp -R` in the ebuild?

When doing rm -rf /usr/lib/go/ and reinstalling it now seems to work.
Comment 7 Hendrik v. Raven 2018-10-17 19:02:09 UTC
Had the same issue and cleaning /usr/lib/go and reinstalling helped. Thanks for the helpful notice.
I switched/had to switch from paludis recently, maybe something got leftover in this process.
Comment 8 William Hubbs gentoo-dev 2020-02-02 20:28:14 UTC
I am going to go ahead and close this since it sounds like you solved
it.

I don't think using cp -r had anything to do with it. You may be right
though that this had to do with switching from paludis some how.

Please feel free to re-open this if you think there is more that I can
do.

Thanks,

William