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

windows build linker line too long error #21

Open
minghuadev opened this issue May 23, 2019 · 0 comments
Open

windows build linker line too long error #21

minghuadev opened this issue May 23, 2019 · 0 comments

Comments

@minghuadev
Copy link

Hi, Just would like to let you know the thanks for the great work bringing the golang to the bare metal world! Really appreciated your work!

I'm building it on windows. Though, the note say it is run under cygwin, really it can just use the raw windows cmd window. Because both the cross-toolchain and the go-sdk installed are for raw windows. The notes is here: https://github.com/minghuadev/emgo/blob/minghuadev-notes/localnotes-win-cygwin.md

In either case, building the stm32/examples/f4-explorer/blinky sample will hit a linker line too long error. The reason is that all the lists of dependents for every package are concatenated together such that some packages appeared too many times on the command line. And the windows clearly cannot cope with it.

I'm using this patch to get it work around:

--- a/egc/buildtools.go
+++ b/egc/buildtools.go
@@ -240,6 +240,20 @@ func (bt *BuildTools) Link(e string, imports []string, o ...string) error {
        if err != nil {
                return err
        }
+       // eliminate duplicate elements.
+       a = func(b []string) ([]string) {
+               rv := make([]string, 0)
+               regm := make(map[string]int)
+               for _,x := range b {
+                       if _,ok := regm[x]; !ok {
+                               rv = append(rv, x)
+                               regm[x] = 1
+                       }
+               }
+               return rv
+       }(a)
+       // then supply the list twice for linker to find earlier dependants
+       args = append(args, a...)
        args = append(args, a...)

        if bt.LDlibgcc != "" {

Since I'm not very good at golang, this may not be the best fix. Hope a better patch can be applied.

If you wonder, I'm thinking of porting it to picorv32 or myblaze. A long way ahead.

Thanks.

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

1 participant