On Sun, Aug 16, 2020 at 12:53 AM rotusm...@gmail.com
<rotusmail...@gmail.com> wrote:
>
> i took your suggestions, tried the '-work' option it showed me the temporary 
> directory where the build files are stored, but they didn't contain the 
> object file. After exploring that a little, i found out out that the 'go 
> build' command also makes a temporary link directory with the build directory 
> but the link directory gets deleted even with the '-work' option.

Sorry, I forgot about that.  I guess you don't need the -work flag.
Instead, add another flag to -ldflags: "-tmpdir=/my/tmp/dir".  The
go.o file will be put into that directory.  I see you figured that
out.  Sorry for the confusion.


> i watched a video of gopher-os and looked through it's github repository for 
> ways to extract the object files needed and tried his command as follows, but 
> i'm getting these errors which i can't resolve:
>
> GOARCH=386 GOOS=linux go build -n 2>&1 | sed -e "1s|^|set -e\n|" -e 
> "1s|^|export GOOS=linux\n|" -e "1s|^|export GOARCH=386\n|" -e "1s|^|export 
> CGO_ENABLED=0\n|" -e "1s|^|WORK='./build'\n|" -e "1s|^|alias pack='go tool 
> pack'\n|" -e "/^mv/d" -e "s|-extld|-tmpdir='./build' -linkmode=external 
> -extldflags='-nostdlib' -extld|g" | sh 2>&1 | sed -e "s/^/ | /g"
>
> Errors/Warnings:
>
>  | loadinternal: cannot find runtime/cgo
>  | /usr/bin/ld: warning: cannot find entry symbol _start; defaulting to 
> 0000000008049000
>
> The above command is able to produce an object file in the ./build directory 
> i specified, i can link it without any errors, but when i try to run the 
> executable it doesn't work.
>
> i know there is nothing wrong with the linker script because i have created 
> object files using the gccgo cross-compiler, and they work.
> i wish to use the extra set of features the 'go build' cross-compiler is able 
> to provide that gccgo cross-compiler cannot.

I'm not sure what's going on here.  There are many possibilities.  In
particular note that Go makes direct system calls; it does not use
libc.  So your system has to provide a compatible system call
interface.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcU%3DmTj4BWRp1ZnKSh7jr8OF%3D%3DDc-F4%3DYTQqtbHXSDPhKg%40mail.gmail.com.

Reply via email to