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

FS#1498 - Building gccgo failes #5869

Closed
openwrt-bot opened this issue Apr 16, 2018 · 3 comments
Closed

FS#1498 - Building gccgo failes #5869

openwrt-bot opened this issue Apr 16, 2018 · 3 comments
Labels

Comments

@openwrt-bot
Copy link

dmke:

Hi,

I'm currently trying to cross-compile Go binaries for MIPS/soft-float.
My target system is an Ubiquiti EdgeRouterX (mt7621 Soc), you can find
my .config here:

https://gist.github.com/dmke/a4f673eb89862ef9dc2724c238480bb9#file-config

I don't need to compile go code on the ERX hardware, I only need the
gccgo compiler from the toolchain for cross-compiling. However,
building the toolchain (toolchain/gcc/final) breaks with some unsupported
processor opcodes:

$LEDE_ROOT/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/libffi/src/mips/o32.S: Assembler messages:
.../o32.S:94: Error: opcode not supported on this processor: mips32r2 (mips32r2) l.d $f12,0*4($sp)' .../o32.S:101: Error: opcode not supported on this processor: mips32r2 (mips32r2) l.s $f12,04($sp)'
.../o32.S:109: Error: opcode not supported on this processor: mips32r2 (mips32r2) l.d $f12,0*4($sp)' .../o32.S:110: Error: opcode not supported on this processor: mips32r2 (mips32r2) l.d $f14,2
4($sp)'
.../o32.S:115: Error: opcode not supported on this processor: mips32r2 (mips32r2) l.s $f12,0*4($sp)' .../o32.S:116: Error: opcode not supported on this processor: mips32r2 (mips32r2) l.s $f14,14($sp)'
.../o32.S:123: Error: opcode not supported on this processor: mips32r2 (mips32r2) l.d $f12,0*4($sp)' .../o32.S:124: Error: opcode not supported on this processor: mips32r2 (mips32r2) l.s $f14,2
4($sp)'
.../o32.S:131: Error: opcode not supported on this processor: mips32r2 (mips32r2) l.s $f12,0*4($sp)' .../o32.S:132: Error: opcode not supported on this processor: mips32r2 (mips32r2) l.d $f14,24($sp)'
.../o32.S:161: Error: opcode not supported on this processor: mips32r2 (mips32r2) s.s $f0,0($8)' .../o32.S:168: Error: opcode not supported on this processor: mips32r2 (mips32r2) s.d $f0,0($8)'
.../o32.S:265: Error: opcode not supported on this processor: mips32r2 (mips32r2) s.d $f12,((14*4)-10*4)($fp)' .../o32.S:266: Error: opcode not supported on this processor: mips32r2 (mips32r2) s.d $f14,((14
4)-84)($fp)'
.../o32.S:285: Error: opcode not supported on this processor: mips32r2 (mips32r2) l.s $f0,((14*4)-6*4)($fp)' .../o32.S:289: Error: opcode not supported on this processor: mips32r2 (mips32r2) l.d $f0,((14
4)-6*4)($fp)'

(the aforementioned gist contains repro code in form of a pseudo shell
script with more output, in case this gets unreadably formatted :-))

I've come accross this a commit in libffi 1, which seems to be
included in the packages repo 2 (which in my case isn't enough).

After tinkering with the patch a bit, I've come up with this modified
patch:

https://gist.github.com/dmke/a4f673eb89862ef9dc2724c238480bb9#file-301-fix-mips-fix-mips-softfloat-build-issue-patch

That however fails to compile gccgo's go command:

$ $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0-final/./gcc/gccgo -B$LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0-final/./gcc/ -B$LEDE_SOURCE/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/mipsel-openwrt-linux-gnu/bin/ -B$LEDE_SOURCE/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/mipsel-openwrt-linux-gnu/lib/ -isystem $LEDE_SOURCE/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/mipsel-openwrt-linux-gnu/include -isystem $LEDE_SOURCE/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/mipsel-openwrt-linux-gnu/sys-include -Os -pipe -mno-branch-likely -mips32r2 -mtune=24kc -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -static-libstdc++ -static-libgcc -L ../mipsel-openwrt-linux-gnu/libgo -L ../mipsel-openwrt-linux-gnu/libgo/.libs -o go $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/gotools/../libgo/go/cmd/go/alldocs.go $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/gotools/../libgo/go/cmd/go/bug.go $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/gotools/../libgo/go/cmd/go/build.go $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/gotools/../libgo/go/cmd/go/clean.go $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/gotools/../libgo/go/cmd/go/context.go $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/gotools/../libgo/go/cmd/go/discovery.go $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/gotools/../libgo/go/cmd/go/doc.go $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/gotools/../libgo/go/cmd/go/env.go $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/gotools/../libgo/go/cmd/go/fix.go $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/gotools/../libgo/go/cmd/go/fmt.go $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/gotools/../libgo/go/cmd/go/generate.go $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/gotools/../libgo/go/cmd/go/get.go $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/gotools/../libgo/go/cmd/go/go11.go $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/gotools/../libgo/go/cmd/go/help.go $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/gotools/../libgo/go/cmd/go/http.go $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/gotools/../libgo/go/cmd/go/list.go $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/gotools/../libgo/go/cmd/go/main.go $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/gotools/../libgo/go/cmd/go/note.go $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/gotools/../libgo/go/cmd/go/pkg.go $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/gotools/../libgo/go/cmd/go/run.go $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/gotools/../libgo/go/cmd/go/signal.go $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/gotools/../libgo/go/cmd/go/signal_unix.go $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/gotools/../libgo/go/cmd/go/test.go $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/gotools/../libgo/go/cmd/go/testflag.go $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/gotools/../libgo/go/cmd/go/tool.go $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/gotools/../libgo/go/cmd/go/vcs.go $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/gotools/../libgo/go/cmd/go/version.go $LEDE_SOURCE/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0/gotools/../libgo/go/cmd/go/vet.go ../mipsel-openwrt-linux-gnu/libgo/zstdpkglist.go zdefaultcc.go
$LEDE_SOURCE/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/mipsel-openwrt-linux-gnu/bin/ld: warning: libgcc_s.so.1, needed by ../mipsel-openwrt-linux-gnu/libgo/.libs/libgo.so, not found (try using -rpath or -rpath-link)

I've found you'll need to call gccgo with additional parameters

-Xlinker -rpath-link -Xlinker $LEDE_ROOT/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0-final/mipsel-openwrt-linux-gnu/libgcc/

which gets me a step closer, but still fails with:

$LEDE_ROOT/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/mipsel-openwrt-linux-gnu/bin/ld: /tmp/ccApaPgG.o: undefined reference to symbol '_Unwind_Resume@@GCC_3.0'
$LEDE_ROOT/build_dir/toolchain-mipsel_24kc_gcc-7.3.0_glibc/gcc-7.3.0-final/mipsel-openwrt-linux-gnu/libgcc//libgcc_s.so.1: error adding symbols: DSO missing from command line

That's currently way over my head. Where do I continue?

@openwrt-bot
Copy link
Author

yousong:

Hi,

I have a patch [1] for the missing libgcc_s.so issue. Please test and see if it works for you

[1] https://github.com/yousong/build-scripts/blob/4345973ac9b86a065f53752e814ad24801bf4ed7/build-gcc-pass0.sh#L80

@openwrt-bot
Copy link
Author

dmke:

So far this looks promising: building the toolchain succeedes without error.

I'll confirm whether the compiler actually works in a moment.

@openwrt-bot
Copy link
Author

yousong:

Fixed for 7.3.0 by https://git.openwrt.org/?p=openwrt/openwrt.git;a=commitdiff;h=f172456edcee41d37d182bdb6423247c90a1333f

Thank you for the feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant