gollvm: fix setting for sys.DefaultGoroot
Somewhere along the line we seem to have lost the code that correctly
initializes the sys.DefaultGoroot variable; this patch restores it.
This is needed to get a valid runtime.GOROOT() return in cases where
GOROOT env variable is not set.
Change-Id: I427a66ccfa98985d27c44d444135b9505959ecfa
Reviewed-on: https://go-review.googlesource.com/c/gollvm/+/200059
Reviewed-by: Cherry Zhang <cherryyz@google.com>
diff --git a/cmake/modules/AutoGenGo.cmake b/cmake/modules/AutoGenGo.cmake
index 7bee31f..7c59578 100644
--- a/cmake/modules/AutoGenGo.cmake
+++ b/cmake/modules/AutoGenGo.cmake
@@ -24,12 +24,11 @@
# not currently supported -- the install prefix has to be set properly
# as part of the original build.
- # Tools subdir within the install.
- file(APPEND ${outfile} "func defaultGOROOTValue() string { return \"${CMAKE_INSTALL_PREFIX}\" }\n")
-
# Compiler version
file(STRINGS "${srcroot}/../VERSION" rawver)
string(STRIP ${rawver} ver)
+ # Default GOROOT var initialization.
+ file(APPEND ${outfile} "func init() { DefaultGoroot = \"${CMAKE_INSTALL_PREFIX}\" }\n")
file(APPEND ${outfile} "const TheVersion = ")
emitversionstring(${outfile} ${srcroot})
file(APPEND ${outfile} "\n")