From 93a5b564397d24fce87c83809dc01ad5e4c824da Mon Sep 17 00:00:00 2001 From: Jacob Nevins Date: Sat, 26 Jan 2019 19:57:37 +0000 Subject: [PATCH] Fix build with GCC4.x. Since the rewrite of hardware SHA support in cbbd464fd7, we've been attempting to build with SHA-NI support on x86 with some GCC 4.x, including Ubuntu 14.04's 4.8.x, whereas before we only tried it with GCC 5.x and above. Revert to that. (I think that GCC has had some support for this extension since 4.9.0 -- the "sha" attribute went in in upstream commit fc975a4090 -- and it at least compiles with 4.9.2, but I'm assuming Pavel had a good reason for sticking to 5+ in 5a38b293bd.) --- sshsh256.c | 10 ++++------ sshsha.c | 11 +++++------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/sshsh256.c b/sshsh256.c index d90cd9d9..03ff6ab1 100644 --- a/sshsh256.c +++ b/sshsh256.c @@ -22,8 +22,7 @@ # define HW_SHA256 HW_SHA256_NI # endif #elif defined(__GNUC__) -# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) && \ - (defined(__x86_64__) || defined(__i386)) +# if (__GNUC__ >= 5) && (defined(__x86_64__) || defined(__i386)) # define HW_SHA256 HW_SHA256_NI # endif #elif defined (_MSC_VER) @@ -339,13 +338,12 @@ const ssh_hashalg ssh_sha256_sw = { /* * Set target architecture for Clang and GCC */ -#if !defined(__clang__) && defined(__GNUC__) +#if defined(__clang__) || defined(__GNUC__) +# define FUNC_ISA __attribute__ ((target("sse4.1,sha"))) +#if !defined(__clang__) # pragma GCC target("sha") # pragma GCC target("sse4.1") #endif - -#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) -# define FUNC_ISA __attribute__ ((target("sse4.1,sha"))) #else # define FUNC_ISA #endif diff --git a/sshsha.c b/sshsha.c index eaf81c51..d59f1f3d 100644 --- a/sshsha.c +++ b/sshsha.c @@ -22,8 +22,7 @@ # define HW_SHA1 HW_SHA1_NI # endif #elif defined(__GNUC__) -# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) && \ - (defined(__x86_64__) || defined(__i386)) +# if (__GNUC__ >= 5) && (defined(__x86_64__) || defined(__i386)) # define HW_SHA1 HW_SHA1_NI # endif #elif defined (_MSC_VER) @@ -322,13 +321,13 @@ const ssh_hashalg ssh_sha1_sw = { /* * Set target architecture for Clang and GCC */ -#if !defined(__clang__) && defined(__GNUC__) + +#if defined(__clang__) || defined(__GNUC__) +# define FUNC_ISA __attribute__ ((target("sse4.1,sha"))) +#if !defined(__clang__) # pragma GCC target("sha") # pragma GCC target("sse4.1") #endif - -#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) -# define FUNC_ISA __attribute__ ((target("sse4.1,sha"))) #else # define FUNC_ISA #endif