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

Support Go 1.21 (RC3) #19

Merged
merged 15 commits into from
Jul 31, 2023
Merged

Support Go 1.21 (RC3) #19

merged 15 commits into from
Jul 31, 2023

Conversation

eh-steve
Copy link
Owner

@eh-steve eh-steve commented Jul 5, 2023

Addresses pkujhd#82

TODO:

  • type: '' for symbol 'io..stmp_2' not found (caused by reachability analysis incorrectly concluding that static/global vars and their types are not reachable)
  • k8s/protobuf init panic. 1.21 pkg init sequencing is no longer built into the inittasks themselves - the linker is instead responsible for ordering the inittasks correctly, so use Autolib() order
  • MacOS without CGo failing (caused by 1.21 automatically wrapping handwritten asm with a PUSH/POP BP to create frames for you)
  • Windows CGo failing (caused by new reloctypes and .bss segments not being handled previously
  • MacOS/arm64 CGo missing support for certain native reloc types macho.Reloc{Addr:0x58, Value:0x1, Type:0x4, Len:0x2, Pcrel:false, Extern:true, Scattered:false}
  • MacOS/arm64 jit_test.go:1629: failed to load linker: relocation epilogue not available but got a >24-bit CALLARM reloc with offset -387288228: unicode.map.init.0
  • Linux/arm64 missing support for elf.R_AARCH64_ADR_GOT_PAGE

@eh-steve eh-steve requested review from pkujhd and fumeboy July 5, 2023 23:23
@eh-steve eh-steve force-pushed the go-1.21-support branch 8 times, most recently from 61b25c5 to 757a943 Compare July 9, 2023 14:59
@eh-steve eh-steve force-pushed the go-1.21-support branch 3 times, most recently from 8458c43 to cea274e Compare July 18, 2023 00:12
Comment on lines +191 to +217
// The JIT type's mtyp would have been offset with respect to the new type's module's data base.
// Since the runtime assumes that types and their methods' types are defined in the same module, but we have a situation where the type
// is in the firstmodule, but method type is in a JIT module, we have to hack around runtime.resolveTypeOff
// by adding an entry under a negative offset (< -1) to the firstmodule's typemap
methodType := (*_type)(unsafe.Pointer(cm.module.types + uintptr(prevMethods[i].mtyp)))
firstModuleTypemapCounter--
if firstmoduledata.typemap == nil {
firstmoduledata.typemap = make(map[typeOff]*_type, len(firstmoduledata.typelinks)+1)
for _, tl := range firstmoduledata.typelinks {
firstmoduledata.typemap[typeOff(tl)] = (*_type)(unsafe.Pointer(firstmoduledata.types + uintptr(tl)))
}
pinnedTypemaps = append(pinnedTypemaps, firstmoduledata.typemap)
}
firstmoduledata.typemap[firstModuleTypemapCounter] = methodType
firstModuleTypemapEntries[methodType] = firstModuleTypemapCounter

cm.module.typemap[firstModuleTypemapCounter] = methodType // In case we need to resolve this method type with respect to the JIT type (unlikely since it should have been deduped with the firstmodule type?)
methods[i].mtyp = firstModuleTypemapCounter

err = mprotect.MprotectMakeReadOnly(page)
if err != nil {
return fmt.Errorf("failed to make page read only while patching type %s: %w", _name(t.nameOff(t.str)), err)
}
// Store for later cleanup on Unload()
patchedTypeMethodsMtyp[t][i] = firstModuleTypemapCounter
markedMissing = true
}
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fumeboy FYI

@eh-steve eh-steve changed the title WIP - support Go 1.21 (RC2) Support Go 1.21 (RC3) Jul 31, 2023
@eh-steve eh-steve merged commit b789213 into master Jul 31, 2023
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

Successfully merging this pull request may close these issues.

1 participant