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

<undefined reference> problem while compiling a binary for Arm from Linux #1906

Closed
cheer-Yuan opened this issue May 26, 2021 · 4 comments
Closed

Comments

@cheer-Yuan
Copy link

cheer-Yuan commented May 26, 2021

Hello,

I am trying to compile a program of ARM with tinygo from Linux, when I enter the following command :

GOARCH=arm tinygo build -o <OutputName> ./main.go

I got :

/usr/lib/gcc-cross/arm-linux-gnueabihf/9/../../../../arm-linux-gnueabihf/bin/ld: /tmp/tinygo859602615/main.o: in function `syscall.Seek':
/usr/local/go/src/syscall/syscall_linux_arm.go:60: undefined reference to `syscall.seek'

The relevant codes indicated here above are :

// Underlying system call writes to newoffset via pointer.
// Implemented in assembly to avoid allocation.
func seek(fd int, offset int64, whence int) (newoffset int64, err Errno)

func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
	newoffset, errno := seek(fd, offset, whence)
	if errno != 0 {
		return 0, errno
	}
	return newoffset, nil
}

I have just use

sudo apt-get install arm-linux-gnueabihf

to install this package.

However,

GOARCH=arm go build -o <OutputName> ./main.go

works without any problem.
Using CGO_ENABLED="0" flag doesn't change anything.
I have searched on the Internet and found no similar issues. Thank you for any possible information.

Environment :

Linux 5.4.0-73-generic #82-Ubuntu SMP Wed Apr 14 17:39:42 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
go version go1.16.3 linux/amd64
CGO_ENABLED="1"
GOROOT="/usr/local/go"
TINYGOROOT="/usr/local/lib/tinygo"
@dkegel-fastly
Copy link
Contributor

Also seems to affect i386. See log
https://github.com/tinygo-org/tinygo/runs/4687146838?check_suite_focus=true
from #2457

@aykevl
Copy link
Member

aykevl commented Jan 3, 2022

I have a local branch to implement Go assembly. It's not complete (only works on amd64 and arm64 now) but once finished that branch should fix this issue.

@dkegel-fastly dkegel-fastly modified the milestones: v0.22.0, v0.23.0 Jan 17, 2022
dkegel-fastly added a commit to dkegel-fastly/tinygo that referenced this issue Jan 18, 2022
dkegel-fastly added a commit to dkegel-fastly/tinygo that referenced this issue Jan 18, 2022
dkegel-fastly added a commit to dkegel-fastly/tinygo that referenced this issue Jan 18, 2022
dkegel-fastly added a commit to dkegel-fastly/tinygo that referenced this issue Jan 19, 2022
dkegel-fastly added a commit to dkegel-fastly/tinygo that referenced this issue Jan 19, 2022
dkegel-fastly added a commit to dkegel-fastly/tinygo that referenced this issue Jan 19, 2022
deadprogram pushed a commit that referenced this issue Jan 20, 2022
Revert this once syscall.seek is implemented
cf. #1906
dkegel-fastly added a commit to dkegel-fastly/tinygo that referenced this issue Jan 22, 2022
Lets 'GOARCH=386 tinygo test os' compile.

Also skip tests that depend on seek so "GOARCH=386 tinygo test os" passes.

This should have been part of "Kludge: work around lack of syscall.seek on 386 and arm, tinygo-org#1906"
dkegel-fastly added a commit to dkegel-fastly/tinygo that referenced this issue Jan 22, 2022
dkegel-fastly added a commit to dkegel-fastly/tinygo that referenced this issue Jan 22, 2022
This replaces an earlier kludge which was at the wrong level
and caused "GOARCH=386 tinygo test os" to fail to compile on linux.

Stubbing just the one missing function, syscall.seek, lets
os tests compile on linux 386, and skipping tests of seek and Fstat
(which has a cryptic dependency on syscall.Seek via time)
lets os tests pass on linux 386.

The stub can be removed once tinygo implements go assembly and picks up the real definition.
dkegel-fastly added a commit to dkegel-fastly/tinygo that referenced this issue Jan 23, 2022
dkegel-fastly added a commit to dkegel-fastly/tinygo that referenced this issue Jan 23, 2022
This replaces an earlier kludge which was at the wrong level
and caused "GOARCH=386 tinygo test os" to fail to compile on linux.

Stubbing just the one missing function, syscall.seek, lets
os tests compile on linux 386, and skipping tests of seek and Fstat
(which has a cryptic dependency on syscall.Seek via time)
lets os tests pass on linux 386.

The stub can be removed once tinygo implements go assembly and picks up the real definition.
dkegel-fastly added a commit to dkegel-fastly/tinygo that referenced this issue Jan 23, 2022
dkegel-fastly added a commit to dkegel-fastly/tinygo that referenced this issue Jan 23, 2022
This replaces an earlier kludge which was at the wrong level
and caused "GOARCH=386 tinygo test os" to fail to compile on linux.

Stubbing just the one missing function, syscall.seek, lets
os tests compile on linux 386, and skipping tests of seek and Fstat
(which has a cryptic dependency on syscall.Seek via time)
lets os tests pass on linux 386.

The stub can be removed once tinygo implements go assembly and picks up the real definition.
deadprogram pushed a commit that referenced this issue Jan 24, 2022
This replaces an earlier kludge which was at the wrong level
and caused "GOARCH=386 tinygo test os" to fail to compile on linux.

Stubbing just the one missing function, syscall.seek, lets
os tests compile on linux 386, and skipping tests of seek and Fstat
(which has a cryptic dependency on syscall.Seek via time)
lets os tests pass on linux 386.

The stub can be removed once tinygo implements go assembly and picks up the real definition.
bgould pushed a commit to bgould/tinygo that referenced this issue Feb 7, 2022
bgould pushed a commit to bgould/tinygo that referenced this issue Feb 7, 2022
bgould pushed a commit to bgould/tinygo that referenced this issue Feb 7, 2022
This replaces an earlier kludge which was at the wrong level
and caused "GOARCH=386 tinygo test os" to fail to compile on linux.

Stubbing just the one missing function, syscall.seek, lets
os tests compile on linux 386, and skipping tests of seek and Fstat
(which has a cryptic dependency on syscall.Seek via time)
lets os tests pass on linux 386.

The stub can be removed once tinygo implements go assembly and picks up the real definition.
@dkegel-fastly
Copy link
Contributor

May be fixed already by #2571 in 0.22?

Please try 0.22 or dev and see if that works better.

@dkegel-fastly dkegel-fastly removed this from the v0.23.0 milestone Mar 22, 2022
deadprogram pushed a commit that referenced this issue Apr 7, 2022
Revert this once syscall.seek is implemented
cf. #1906
deadprogram pushed a commit that referenced this issue Apr 7, 2022
This replaces an earlier kludge which was at the wrong level
and caused "GOARCH=386 tinygo test os" to fail to compile on linux.

Stubbing just the one missing function, syscall.seek, lets
os tests compile on linux 386, and skipping tests of seek and Fstat
(which has a cryptic dependency on syscall.Seek via time)
lets os tests pass on linux 386.

The stub can be removed once tinygo implements go assembly and picks up the real definition.
deadprogram pushed a commit that referenced this issue Apr 11, 2022
This replaces an earlier kludge which was at the wrong level
and caused "GOARCH=386 tinygo test os" to fail to compile on linux.

Stubbing just the one missing function, syscall.seek, lets
os tests compile on linux 386, and skipping tests of seek and Fstat
(which has a cryptic dependency on syscall.Seek via time)
lets os tests pass on linux 386.

The stub can be removed once tinygo implements go assembly and picks up the real definition.
ardnew pushed a commit to ardnew/tinygo that referenced this issue Jun 21, 2022
ardnew pushed a commit to ardnew/tinygo that referenced this issue Jun 21, 2022
ardnew pushed a commit to ardnew/tinygo that referenced this issue Jun 21, 2022
This replaces an earlier kludge which was at the wrong level
and caused "GOARCH=386 tinygo test os" to fail to compile on linux.

Stubbing just the one missing function, syscall.seek, lets
os tests compile on linux 386, and skipping tests of seek and Fstat
(which has a cryptic dependency on syscall.Seek via time)
lets os tests pass on linux 386.

The stub can be removed once tinygo implements go assembly and picks up the real definition.
@aykevl
Copy link
Member

aykevl commented Aug 28, 2022

This is fixed now, see #2571.

@aykevl aykevl closed this as completed Aug 28, 2022
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