Skip to content

windows build linker line too long error #21

Description

@minghuadev

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions