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

Upgrade Go to 1.18 #7

Closed

Conversation

eduardvintila
Copy link
Member

@eduardvintila eduardvintila commented Jul 26, 2023

This PR is part of a series of PRs that work in conjunction for the update of Go support to 1.18:

For testing, make sure to pass to QEMU the -cpu host argument (this is necessary because the paging API and ukvmem are required by libgo as part of Virtual Address space management, and somehow the default CPU just won't handle 1GB pages).

Only GCC12 (with gccgo >=12) and x86 is supported for the moment.

@StefanJum
Copy link
Member

@eduardvintila What gccgo version should we use? I'm using gccgo-11 and I get the following error

workdir/apps/helloworld-go/build/libgo/origin/gcc-12.1.0/libgo/go/internal/abi/abi.go:20:19: error: use of undefined type ‘any’                                   
   20 | func FuncPCABI0(f any) uintptr { 

All prs mentioned in the description are merged.

@eduardvintila
Copy link
Member Author

eduardvintila commented Aug 5, 2023

What gccgo version should we use?

@StefanJum, you should use version 12, as stated in the description (though indeed I did not mention explicitly gccgo, I'll have to edit that). Obviously this should be officially documented, so I'll update the README.md file as well

@eduardvintila
Copy link
Member Author

I've updated the documentation.

Copy link
Member

@StefanJum StefanJum left a comment

Choose a reason for hiding this comment

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

@eduardvintila new issue, any idea on this one?

CRITICAL:root:2
workdir/libs/libgo/Makefile.build:3: workdir/apps/helloworld-go/build/go/apphelloworldgo/Makefile: No such file or directory
make[3]: *** No rule to make target 'workdir/apps/helloworld-go/build/go/apphelloworldgo/Makefile'.  Stop.

@eduardvintila
Copy link
Member Author

@StefanJum hmm, did you also update app-helloworld-go?

@StefanJum
Copy link
Member

@StefanJum hmm, did you also update app-helloworld-go?

Yes, it's weird, I've built it in a docker container and everything builds and runs fine, but if I try to build locally it fails.
It might be some version stuff, I'll keep looking.

@razvand
Copy link
Contributor

razvand commented Aug 6, 2023

@StefanJum , you need golang package installed.

@StefanJum StefanJum self-requested a review August 6, 2023 19:26
Copy link

@RaduNichita RaduNichita left a comment

Choose a reason for hiding this comment

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

Nice work, @eduardvintila

I have a question: could we reduce the number of files modified by this PR by not including the autogenerated files and generating them on the fly?

@@ -1,11 +1,12 @@
// This file was automatically generated by mksyscall.awk
// Code generated by mksyscall.awk. DO NOT EDIT.

Choose a reason for hiding this comment

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

If this file was automatically generated, could we add a rule in the makefile for that generating it of including it per se?

Copy link
Member Author

Choose a reason for hiding this comment

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

mksyscall.awk is from the upstream gcc build system. It's not integrated with Unikraft, and I don't see an easy way to add a rule in the Makefile for the moment. Ofc it would be ideal if we could automate this, but I don't think it's feasible for this release :).

Choose a reason for hiding this comment

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

Ok, let's stick with this. Maybe you should open a issue regarding this so we don't lose it in the comments.

@@ -0,0 +1,3548 @@
# This file has been auto-generated for go1.18 gccgo (GCC) 12.1.0.

Choose a reason for hiding this comment

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

Same here

Copy link
Member Author

Choose a reason for hiding this comment

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

This one is generated by the helper scripts, found in the scripts/ directory (also introduced with this PR). In a similar manner, lib-musl also includes generated Makefiles for each component (i.e. Makefile.uk.musl.complex, Makefile.uk.musl.signal etc.), providing also helper scripts to generate them. So I think we should keep this approach for consistency.

Copy link

@RaduNichita RaduNichita left a comment

Choose a reason for hiding this comment

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

Nice work, @eduardvintila

Reviewed-by: Radu Nichita radunichita99@gmail.com

Copy link
Member

@StefanJum StefanJum left a comment

Choose a reason for hiding this comment

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

@eduardvintila everything seems to work fine.

One comment I have it's that everything is done very x86-targeted (i.e. adding -D__x86_64__, x86 headers and source files, setting x86 in config files, etc.), and this might be an issue if we want to add arm support in the future.
We tried (with @razvand) to compile this for arm and we eventually made it to the linking step, but I would make everything that is architecture specific depend on $(ARCH) being set to x86_64.

@razvand
Copy link
Contributor

razvand commented Aug 7, 2023

@StefanJum, @eduardvintila, we will have only x86_64 for Go this release. I had made progress with the AArch64 part, but it requires further work. We'll do it after the release and have a sub-release with Go support for AArch64.

@eduardvintila eduardvintila force-pushed the go-updated-gcc12 branch 2 times, most recently from 1199562 to ae29375 Compare August 8, 2023 08:09
@eduardvintila
Copy link
Member Author

@StefanJum, you're right. I've refactored the makefiles and some source files to emphasize which parts are architecture dependent.

@razvand, for an ARM build to work, the ukvmem library is necessary, which is not yet adapted to aarch64.

@StefanJum
Copy link
Member

One more thing @eduardvintila, I think we should add compiler version checks in the Makefile.uk (similar to what we have in the Unikraft Makefile). I think it's the best way to document the minimum required compiler version.

This commit upgrades the library version to 1.18 by using the upstream
GO runtime library provided by GCC12.
New Makefile rules are introduced to compartimentalize GO pacakge
bulding. Helper scripts are also added to assist with creation of such
Makefiles.
Glue code was also added to help with compatibility, and additional
headers from `libffi` and `libbacktrace` were also introduced.

Co-authored-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Co-authored-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Signed-off-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Signed-off-by: Eduard Vintilă <eduard.vintila47@gmail.com>
@eduardvintila
Copy link
Member Author

Thank you, @StefanJum - I've included your suggestion! Also updated the PR based on the changes introduced by this commit from Unikraft core.

@StefanJum
Copy link
Member

StefanJum commented Aug 11, 2023

@eduardvintila I get these errors, I remember I've got them before but I can't figure out what I did to get pass them.

/home/unikraft/SJ/maintainer-tools/workdir/apps/helloworld-go/build/libsyscall_shim/uk_syscall_r_fn.c:321:9: error: duplicate case value                                                                           
  321 |         case SYS_madvise:                                                                                                                                                                                  
      |         ^~~~                                                                                     
/home/unikraft/SJ/maintainer-tools/workdir/apps/helloworld-go/build/libsyscall_shim/uk_syscall_r_fn.c:81:9: note: previously used here                                                                             
   81 |         case SYS_madvise:                                                                                                                                                                                  
      |         ^~~~             
/home/unikraft/SJ/maintainer-tools/workdir/apps/helloworld-go/build/libsyscall_shim/uk_syscall_r_fn.c:331:9: error: duplicate case value                                                                           
  331 |         case SYS_mprotect:                                                                                                                                                                                 
      |         ^~~~                                                                                                                                                                                               
/home/unikraft/SJ/maintainer-tools/workdir/apps/helloworld-go/build/libsyscall_shim/uk_syscall_r_fn.c:76:9: note: previously used here                                                                             
   76 |         case SYS_mprotect:  

Any unmerged pr that I need or some extra config options?

@eduardvintila
Copy link
Member Author

eduardvintila commented Aug 11, 2023

@eduardvintila I get these errors, I remember I've got them before but I can't figure out what I did to get pass them.

/home/unikraft/SJ/maintainer-tools/workdir/apps/helloworld-go/build/libsyscall_shim/uk_syscall_r_fn.c:321:9: error: duplicate case value                                                                           
  321 |         case SYS_madvise:                                                                                                                                                                                  
      |         ^~~~                                                                                     
/home/unikraft/SJ/maintainer-tools/workdir/apps/helloworld-go/build/libsyscall_shim/uk_syscall_r_fn.c:81:9: note: previously used here                                                                             
   81 |         case SYS_madvise:                                                                                                                                                                                  
      |         ^~~~             
/home/unikraft/SJ/maintainer-tools/workdir/apps/helloworld-go/build/libsyscall_shim/uk_syscall_r_fn.c:331:9: error: duplicate case value                                                                           
  331 |         case SYS_mprotect:                                                                                                                                                                                 
      |         ^~~~                                                                                                                                                                                               
/home/unikraft/SJ/maintainer-tools/workdir/apps/helloworld-go/build/libsyscall_shim/uk_syscall_r_fn.c:76:9: note: previously used here                                                                             
   76 |         case SYS_mprotect:  

Any unmerged pr that I need or some extra config options?

@StefanJum Nope, no additional PR is needed. It looks like the same syscalls are provided by two seperate libraries. By any chance, do you have both ukmmap and posix-mmap selected? This obviously should not happen, but sometimes it's influenced by the order in which you select the libraries... However, this commit should've solved the problem; I did not encounter it after it was merged

@StefanJum
Copy link
Member

@StefanJum Nope, no additional PR is needed. It looks like the same syscalls are provided by two seperate libraries. By any chance, do you have both ukmmap and posix-mmap selected? This obviously should not happen, but sometimes it's influenced by the order in which you select the libraries... However, this commit should've solved the problem; I did not encounter it after it was merged

Yes, that was it. It's really messed up, it was selected even if it did not show up in the config menu (due to the depends on statement). I had to unselect everything and get it to show up, deselect it end select everything else again 🥲

Copy link
Member

@StefanJum StefanJum left a comment

Choose a reason for hiding this comment

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

Anyway this works, we need to soon get rid of ukmmap tho.
Thanks a lot for the work @eduardvintila 🎉 🎉

Copy link
Member

@StefanJum StefanJum left a comment

Choose a reason for hiding this comment

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

Reviewed-by: Stefan Jumarea stefanjumarea02@gmail.com

Copy link
Contributor

@razvand razvand left a comment

Choose a reason for hiding this comment

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

Approved-by: Razvan Deaconescu razvand@unikraft.io

unikraft-bot pushed a commit that referenced this pull request Aug 11, 2023
Signed-off-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Reviewed-by: Radu Nichita <radunichita99@gmail.com>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci/merged enhancement New feature or request
Projects
Status: Done!
Development

Successfully merging this pull request may close these issues.

6 participants