libgo: check for AES instruction
The runtime uses this to enable AES hash.
Change-Id: I0875f1aa219a6633a1561679c62fc94e3a981a7e
Reviewed-on: https://go-review.googlesource.com/c/160117
Reviewed-by: Than McIntosh <thanm@google.com>
diff --git a/cmake/modules/ConfigSetup.cmake b/cmake/modules/ConfigSetup.cmake
index e6874f6..fae5dd8 100644
--- a/cmake/modules/ConfigSetup.cmake
+++ b/cmake/modules/ConfigSetup.cmake
@@ -132,6 +132,8 @@
check_c_source_compiles("int main(int argc, char **argv) { return __sync_fetch_and_add(&argc, 1); }\n" HAVE_SYNC_FETCH_AND_ADD_4)
check_c_source_compiles("#include <stdint.h>\nstatic uint64_t s;\nint main(int argc, char **argv) { return __sync_add_and_fetch(&s, 1) == s ? 0 : 1; }\n" HAVE_SYNC_ADD_AND_FETCH_8)
+check_c_source_compiles("int main() { __asm__(\"aesenc %xmm0, %xmm1\"); return 0; }\n" HAVE_AS_X86_AES)
+
# Issue an error if the C compiler doesn't support -fsplit-stack
# (in theory you can build libgo without it, so I suppose this could
# be changed to a warning).
diff --git a/libgo/config.h.cmake b/libgo/config.h.cmake
index 21aaa0e..4c90352 100644
--- a/libgo/config.h.cmake
+++ b/libgo/config.h.cmake
@@ -156,6 +156,9 @@
/* Define to 1 if you have '__sync_add_and_fetch_8'. */
#cmakedefine HAVE_SYNC_ADD_AND_FETCH_8 1
+/* Define to 1 if assembler supports AES instructions. */
+#cmakedefine HAVE_AS_X86_AES 1
+
/* Define if we're to use libffi. */
#cmakedefine USE_LIBFFI 1