gollvm: update cmake files for libgo 1.11

Changes to CMake code to sync with the recent libgo update to Go 1.11.

Change-Id: Ib06aa66d685cd1d94d4dded1d5db0e82d243a8ae
Reviewed-on: https://go-review.googlesource.com/c/139159
Reviewed-by: Cherry Zhang <cherryyz@google.com>
diff --git a/cmake/modules/AutoGenGo.cmake b/cmake/modules/AutoGenGo.cmake
index c5f40b3..fa695e6 100644
--- a/cmake/modules/AutoGenGo.cmake
+++ b/cmake/modules/AutoGenGo.cmake
@@ -120,6 +120,36 @@
   file(APPEND ${outfile} "type Uintreg uintptr\n")
 endfunction()
 
+#----------------------------------------------------------------------
+# Emit 'cpugen.go'. Similar to version.go, but with a smaller set of
+# CPU-specific constants. Based on the libgo Makefile recipe.
+#
+# Unnamed parameters:
+#
+#   * GOARCH setting (target architecture)
+#   * output file
+#   * root of src containing libgo script files
+#
+function(mkcpugen goarch outfile scriptroot)
+
+  file(REMOVE ${outfile})
+  file(WRITE ${outfile} "package cpu\n")
+
+  # Invoke goarch.sh
+  execute_process(COMMAND ${shell} "${scriptroot}/goarch.sh"
+    ${goarch} "cachelinesize"
+      OUTPUT_VARIABLE result
+      ERROR_VARIABLE errmsg
+      RESULT_VARIABLE exitstatus)
+    if(${exitstatus} MATCHES 0)
+      file(APPEND ${outfile} "const CacheLineSize = ${result}")
+    else()
+      message(FATAL_ERROR "goarch.sh invocation failed: ${errmsg}")
+    endif()
+    file(APPEND ${outfile} "\n\n")
+
+endfunction()
+
 macro(upperfirst name result)
   string(SUBSTRING ${name} 0 1 c1)
   string(SUBSTRING ${name} 1 -1 crem)
@@ -206,6 +236,7 @@
   file(APPEND ${outfile} "const defaultGO386 = `sse2`\n")
   file(APPEND ${outfile} "const defaultGOARM = `5`\n")
   file(APPEND ${outfile} "const defaultGOMIPS = `hardfloat`\n")
+  file(APPEND ${outfile} "const defaultGOMIPS64 = `hardfloat`\n")
   file(APPEND ${outfile} "const defaultGOOS = runtime.GOOS\n")
   file(APPEND ${outfile} "const defaultGOARCH = runtime.GOARCH\n")
   file(APPEND ${outfile} "const defaultGO_EXTLINK_ENABLED = ``\n")
diff --git a/cmake/modules/GoVars.cmake b/cmake/modules/GoVars.cmake
index f6735cb..edd4cfb 100644
--- a/cmake/modules/GoVars.cmake
+++ b/cmake/modules/GoVars.cmake
@@ -13,8 +13,8 @@
 endif()
 
 # List of all architectures, families, os flavors.
-set(allgoarch "386" "alpha" "amd64" "amd64p32" "arm" "armbe" "arm64" "arm64be" "ia64" "m68k" "mips" "mipsle" "mips64" "mips64le" "mips64p32" "mips64p32le" "ppc" "ppc64" "ppc64le" "s390" "s390x" "sparc" "sparc64")
-set(allgoarchfamily "I386" "ALPHA" "AMD64" "ARM" "ARM64" "IA64" "M68K" "MIPS" "MIPS64" "PPC" "PPC64" "S390" "S390X" "SPARC" "SPARC64")
+set(allgoarch "386" "alpha" "amd64" "amd64p32" "arm" "armbe" "arm64" "arm64be" "ia64" "m68k" "mips" "mipsle" "mips64" "mips64le" "mips64p32" "mips64p32le" "nios2" "ppc" "ppc64" "ppc64le" "riscv" "riscv64" "s390" "s390x" "sh" "shbe" "sparc" "sparc64" "wasm")
+set(allgoarchfamily "I386" "ALPHA" "AMD64" "ARM" "ARM64" "IA64" "M68K" "MIPS" "MIPS64" "PPC" "PPC64" "RISCV" "RISCV64" "S390" "S390X" "SH" "SPARC" "SPARC64" "WASM")
 set(allgoos "aix" "android" "darwin" "dragonfly" "freebsd" "irix" "linux" "netbsd" "openbsd" "plan9" "rtems" "solaris" "windows")
 
 # Set library suffix based on target triple
diff --git a/gotools/CMakeLists.txt b/gotools/CMakeLists.txt
index 2968609..fdb70aa 100644
--- a/gotools/CMakeLists.txt
+++ b/gotools/CMakeLists.txt
@@ -180,7 +180,10 @@
     "SUBDIR" "src/cmd/vet"
     "LOGFILE" "${gotools_binroot}/cmd_vet-testlog"
     "SETENV" "GOPATH=${gotools_binroot}/check-vet-dir"
-    "COPYDIRS" "${cmd_srcroot}/vet:src/cmd"
+    "COPYDIRS"
+        "${cmd_srcroot}/vet:src/cmd"
+        "${cmd_srcroot}/internal/objabi:src/cmd/internal"
+    "COPYFILES" "${libgo_binroot}/objabi.go:src/cmd/internal/objabi"
     "TIMEOUT" ${default_check_timeout}
     "GOC" "${rungoc}"
     "BINDIR" ${gotools_binroot}
diff --git a/libgo/CMakeLists.txt b/libgo/CMakeLists.txt
index b629dcf..543eaaa 100644
--- a/libgo/CMakeLists.txt
+++ b/libgo/CMakeLists.txt
@@ -99,7 +99,8 @@
 # that <pkg>_extra_go_files holds the additional sources for <pkg>.
 set(runtime_extra_go_files "runtime_sysinfo.go" "sigtab.go")
 set(cmd_internal_objabi_extra_go_files "objabi.go")
-set(go_build_extra_go_files "zstdpkglist.go")
+set(internal_goroot_extra_go_files "zstdpkglist.go")
+set(internal_cpu_extra_go_files "cpugen.go")
 set(cmd_go_internal_cfg_extra_go_files "zdefaultcc.go")
 set(runtime_internal_sys_extra_go_files "version.go")
 set(go_types_extra_go_files "gccgosizes.go")
@@ -222,7 +223,7 @@
 # Rules for zstdpkglist.go
 set(zstdpkglistdotgo "${libgo_binroot}/zstdpkglist.go")
 set(zstdpkglisttmp "${libgo_binroot}/zstdpkglist.go.tmp")
-mkzstdpkglist("build" ${zstdpkglisttmp} "${libpackages}")
+mkzstdpkglist("goroot" ${zstdpkglisttmp} "${libpackages}")
 copy_if_different(${zstdpkglisttmp} ${zstdpkglistdotgo})
 
 # Rules for zdefaultcc.go
@@ -316,6 +317,12 @@
 mkepoll(${epolltmp})
 copy_if_different(${epolltmp} ${epolldotgo})
 
+# Generated file cpugen.go
+set(cpugendotgo "${libgo_binroot}/cpugen.go")
+set(cpugentmp "${libgo_binroot}/cpugen.go.tmp")
+mkcpugen(${goarch} ${cpugentmp} ${libgo_scriptroot})
+copy_if_different(${cpugentmp} ${cpugendotgo})
+
 #........................................................................
 
 message(STATUS "Libgo: creating stdlib package targets")
@@ -420,9 +427,11 @@
 # C files that happen to be living in other packages.
 list(APPEND runtimecfiles
   "go/bytes/indexbyte.c"
+  "go/internal/bytealg/bytealg.c"
   "go/log/syslog/syslog_c.c"
   "go/reflect/makefunc_ffi_c.c"
   "go/runtime/internal/atomic/atomic.c"
+  "go/internal/cpu/cpu_gccgo.c"
   "go/strings/indexbyte.c"
   "go/sync/atomic/atomic.c"
   "go/sync/cas.c"
@@ -547,6 +556,16 @@
 set(extra_check_libs_cmd_go_internal_generate "${libgo_binroot}/libgotool.a")
 set(extra_check_libs_cmd_go_internal_get "${libgo_binroot}/libgotool.a")
 set(extra_check_libs_cmd_go_internal_load "${libgo_binroot}/libgotool.a")
+set(extra_check_libs_cmd_go_internal_imports "${libgo_binroot}/libgotool.a")
+set(extra_check_libs_cmd_go_internal_modconv "${libgo_binroot}/libgotool.a")
+set(extra_check_libs_cmd_go_internal_modfetch "${libgo_binroot}/libgotool.a")
+set(extra_check_libs_cmd_go_internal_modfetch_codehost "${libgo_binroot}/libgotool.a")
+set(extra_check_libs_cmd_go_internal_modfile "${libgo_binroot}/libgotool.a")
+set(extra_check_libs_cmd_go_internal_modload "${libgo_binroot}/libgotool.a")
+set(extra_check_libs_cmd_go_internal_module "${libgo_binroot}/libgotool.a")
+set(extra_check_libs_cmd_go_internal_mvs "${libgo_binroot}/libgotool.a")
+set(extra_check_libs_cmd_go_internal_search "${libgo_binroot}/libgotool.a")
+set(extra_check_libs_cmd_go_internal_web2 "${libgo_binroot}/libgotool.a")
 set(extra_check_libs_cmd_go_internal_work "${libgo_binroot}/libgotool.a")
 set(extra_check_libs_cmd_vet_internal_cfg "${libgo_binroot}/libgotool.a")