Skip to content

cmd/compile: cleanup code paths that aren't needed now that -p is required #51734

Closed

Description

@mdempsky

Since CL 391014 (a987aaf), cmd/compile now requires the -p flag. There's a lot of code to handle code paths that aren't needed any more.

At least a few cleanups I can think of:

  1. Initialize types.LocalPkg with base.Ctxt.Pkgpath instead of "".
  2. Change types.TypeHash to use t.LinkString instead of fmtTypeIDHash.
  3. Get rid of "package height" and just sort method sets on identifier and package path. (We can just write package height as 0 in the iexport data format; public importers ignore it anyway.)
  4. Change cmd/link (or cmd/internal/obj?) to Fatalf if it sees "". in any linker symbols.

Perhaps other opportunities.

The iexport file format uses "" for the current package too, which probably needs to be retained for compatibility with legacy importers.

/cc @randall77 @dr2chase @cuonglm

Activity

  1. added
    NeedsFixThe path to resolution is known, but the work has not been done.
    on Mar 16, 2022
  2. added this to the Go1.19 milestone on Mar 16, 2022
  3. randall77 commented on Mar 16, 2022

    @randall77
    Contributor

    I think point 2 will be the right fix to revert/improve what CL 389474 did.

  4. cuonglm commented on Mar 17, 2022

    @cuonglm
    Member

    I think point 2 will be the right fix to revert/improve what CL 389474 did.

    I'm going to send a CL for this.

  5. cuonglm commented on Mar 17, 2022

    @cuonglm
    Member

    I think point 2 will be the right fix to revert/improve what CL 389474 did.

    I'm going to send a CL for this.

    Hmm, simply changing types.TypeHash to use t.LinkString() make go run run.go panic with:

    panic: interface conversion: reflect.Type is *reflect.rtype, not *reflect.rtype (types from different scopes)
    
    goroutine 1 [running]:
    reflect.PointerTo(...)
    	/home/cuonglm/sources/go/src/reflect/type.go:1442
    encoding/json.newTypeEncoder({0x566c30?, 0x516440?}, 0x1?)
    	/home/cuonglm/sources/go/src/encoding/json/encode.go:422 +0x3e5
    encoding/json.typeEncoder({0x566c30?, 0x516440})
    	/home/cuonglm/sources/go/src/encoding/json/encode.go:404 +0x16b
    encoding/json.typeFields({0x566c30, 0x528440})
    	/home/cuonglm/sources/go/src/encoding/json/encode.go:1385 +0x668
    encoding/json.cachedTypeFields({0x566c30?, 0x528440})
    	/home/cuonglm/sources/go/src/encoding/json/encode.go:1417 +0xab
    encoding/json.(*decodeState).object(0xc0000022a8, {0x5123c0?, 0xc00002e5c0?, 0xc000061980?})
    	/home/cuonglm/sources/go/src/encoding/json/decode.go:654 +0x21e
    encoding/json.(*decodeState).value(0xc0000022a8, {0x5123c0?, 0xc00002e5c0?, 0xc0000619d0?})
    	/home/cuonglm/sources/go/src/encoding/json/decode.go:373 +0x45
    encoding/json.(*decodeState).unmarshal(0xc0000022a8, {0x5123c0?, 0xc00002e5c0?})
    	/home/cuonglm/sources/go/src/encoding/json/decode.go:180 +0x1de
    encoding/json.(*Decoder).Decode(0xc000002280, {0x5123c0, 0xc00002e5c0})
    	/home/cuonglm/sources/go/src/encoding/json/stream.go:73 +0x177
    main.glob..func1()
    	/home/cuonglm/sources/go/test/run.go:68 +0x1a5
    main.init()
    	/home/cuonglm/sources/go/test/run.go:75 +0x3f9
    exit status 2
    

    It seems to need more works than I expect, so feel free to go ahead if you have one, otherwise, I will take another look when I'm back with my laptop.

    cc @mdempsky @randall77

  6. mdempsky commented on Mar 17, 2022

    @mdempsky
    ContributorAuthor

    @cuonglm At least step 1 needs to happen before we can do step 2. :)

  7. gopherbot commented on Mar 18, 2022

    @gopherbot
    Contributor

    Change https://go.dev/cl/393715 mentions this issue: cmd/compile: set LocalPkg.Path to -p flag

  8. gopherbot commented on Mar 18, 2022

    @gopherbot
    Contributor

    Change https://go.dev/cl/393716 mentions this issue: cmd/compile/internal/types: use Type.LinkString in TypeHash

  9. gopherbot commented on Mar 18, 2022

    @gopherbot
    Contributor

    Change https://go.dev/cl/393896 mentions this issue: test: remove obsolete test cases that misuse -p

  10. gopherbot commented on May 3, 2022

    @gopherbot
    Contributor

    Change https://go.dev/cl/403757 mentions this issue: cmd/compile: combo set LocalPkg.Path to -p flag

  11. gopherbot commented on May 12, 2022

    @gopherbot
    Contributor

    Change https://go.dev/cl/406059 mentions this issue: cmd/compile/internal/ir: remove PkgFuncName assumption that LocalPkg.Path == ""

  12. gopherbot commented on May 12, 2022

    @gopherbot
    Contributor

    Change https://go.dev/cl/406056 mentions this issue: cmd/compile/internal/noder: remove unified IR assumptions on LocalPkg.Path == ""

  13. gopherbot commented on May 12, 2022

    @gopherbot
    Contributor

    Change https://go.dev/cl/406057 mentions this issue: cmd/compile/internal/typecheck: remove iexport assumption of LocalPkg.Path == ""

  14. gopherbot commented on May 12, 2022

    @gopherbot
    Contributor

    Change https://go.dev/cl/406055 mentions this issue: cmd/compile/internal/gc: parse command-line flags earlier

  15. 38 remaining items

  16. moved this from Triage Backlog to Todo in Go Compiler / Runtime / Commandon Nov 23, 2022
  17. moved this from Todo to No status in Go Compiler / Runtime / Commandon Nov 23, 2022
  18. mdempsky commented on Nov 30, 2022

    @mdempsky
    ContributorAuthor

    I think this is more or less done now. This issue has served its purpose.

  19. locked and limited conversation to collaborators on Nov 30, 2023
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

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions