gollvm: cmake update to sync with libgo cpu change
This patch updates the cmake rules to sync up with a libgo
change that introduces a new generation file (gcpugen.go),
in https://golang.org/cl/194438.
Change-Id: I09ced2c22dc2a993e00dc4465d8b67cd850207d2
Reviewed-on: https://go-review.googlesource.com/c/gollvm/+/194558
Reviewed-by: Cherry Zhang <cherryyz@google.com>
diff --git a/cmake/modules/AutoGenGo.cmake b/cmake/modules/AutoGenGo.cmake
index e51643d..ae4d4bd 100644
--- a/cmake/modules/AutoGenGo.cmake
+++ b/cmake/modules/AutoGenGo.cmake
@@ -152,6 +152,36 @@
endfunction()
+#----------------------------------------------------------------------
+# Emit 'gcpugen.go', another cpu-specific generated Go file. Based
+# on the libgo Makefile recipe.
+#
+# Unnamed parameters:
+#
+# * GOARCH setting (target architecture)
+# * output file
+# * root of src containing libgo script files
+#
+function(mkgcpugen 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}\n")
+ else()
+ message(FATAL_ERROR "goarch.sh invocation failed: ${errmsg}")
+ endif()
+ file(APPEND ${outfile} "\n")
+
+endfunction()
+
macro(upperfirst name result)
string(SUBSTRING ${name} 0 1 c1)
string(SUBSTRING ${name} 1 -1 crem)
diff --git a/libgo/CMakeLists.txt b/libgo/CMakeLists.txt
index 0a442eb..eddbd5a 100644
--- a/libgo/CMakeLists.txt
+++ b/libgo/CMakeLists.txt
@@ -104,6 +104,7 @@
set(cmd_internal_objabi_extra_go_files "objabi.go")
set(internal_goroot_extra_go_files "zstdpkglist.go")
set(internal_cpu_extra_go_files "cpugen.go")
+set(golang_org_x_sys_cpu_extra_go_files "gcpugen.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")
@@ -120,7 +121,8 @@
message(SEND_ERROR "Package directory ${pack} does not exist.")
else()
- string(REPLACE "/" "_" ptarget "${pack}")
+ string(REPLACE "/" "_" ptarget2 "${pack}")
+ string(REPLACE "." "_" ptarget "${ptarget2}")
set(packfilestmp "${libgo_binroot}/${ptarget}.gofiles")
# Package-specific match args
@@ -161,7 +163,8 @@
set(packsrcs)
set(packopts)
- string(REPLACE "/" "_" ptarget "${pack}")
+ string(REPLACE "/" "_" ptarget2 "${pack}")
+ string(REPLACE "." "_" ptarget "${ptarget2}")
set(packfilestmp "${libgo_binroot}/${ptarget}.gofiles")
file(STRINGS ${packfilestmp} matchoutput)
separate_arguments(matchoutput)
@@ -326,6 +329,12 @@
mkcpugen(${goarch} ${cpugentmp} ${libgo_scriptroot})
copy_if_different(${cpugentmp} ${cpugendotgo})
+# Generated file gcpugen.go
+set(gcpugendotgo "${libgo_binroot}/gcpugen.go")
+set(gcpugentmp "${libgo_binroot}/gcpugen.go.tmp")
+mkgcpugen(${goarch} ${gcpugentmp} ${libgo_scriptroot})
+copy_if_different(${gcpugentmp} ${gcpugendotgo})
+
#........................................................................
message(STATUS "Libgo: creating stdlib package targets")
@@ -337,7 +346,8 @@
# Process each package
foreach( pack ${allpackages})
- string(REPLACE "/" "_" ptarget "${pack}")
+ string(REPLACE "/" "_" ptarget2 "${pack}")
+ string(REPLACE "." "_" ptarget "${ptarget2}")
collect_package_inputs(${pack})
@@ -585,7 +595,8 @@
message(STATUS "Libgo: generating check targets")
foreach( pack ${checkpackages})
- string(REPLACE "/" "_" ptarget "${pack}")
+ string(REPLACE "/" "_" ptarget2 "${pack}")
+ string(REPLACE "." "_" ptarget "${ptarget}")
set(runner "${CMAKE_CURRENT_SOURCE_DIR}/checkpackage.sh")
# This will set 'packsrcs' and 'packopts'