From: "Michael R. Crusoe" <crusoe@debian.org>
Date: Sat, 1 Feb 2020 15:13:31 +0100
Subject: Increase portability by using SIMD Everywhere library

Forwarded: https://github.com/vgteam/vg/pull/2867
---
 Makefile                      |  6 +-----
 deps/dozeu/dozeu.h            |  2 +-
 deps/gssw/src/gssw.c          |  2 +-
 deps/gssw/src/gssw.h          |  2 +-
 deps/sdsl-lite/CMakeLists.txt | 13 -------------
 src/preflight.cpp             | 27 ---------------------------
 src/preflight.hpp             |  9 +--------
 7 files changed, 5 insertions(+), 56 deletions(-)

diff --git a/Makefile b/Makefile
index 8101f38..b8fece4 100644
--- a/Makefile
+++ b/Makefile
@@ -624,10 +624,7 @@ $(LIB_DIR)/libstructures.a: $(STRUCTURES_DIR)/src/include/structures/*.hpp $(STR
 $(INC_DIR)/sha1.hpp: $(SHA1_DIR)/sha1.hpp
 	+cp $(SHA1_DIR)/*.h* $(CWD)/$(INC_DIR)/
 
-$(INC_DIR)/simde/x86/sse4.1.h: $(DOZEU_DIR)/simde/*.h $(DOZEU_DIR)/simde/x86/*.h
-	+cp -r $(DOZEU_DIR)/simde $(INC_DIR)
-
-$(INC_DIR)/dozeu/dozeu.h: $(DOZEU_DIR)/*.h $(INC_DIR)/simde/x86/sse4.1.h
+$(INC_DIR)/dozeu/dozeu.h: $(DOZEU_DIR)/*.h
 	+mkdir -p $(CWD)/$(INC_DIR)/dozeu && cp $(DOZEU_DIR)/*.h $(CWD)/$(INC_DIR)/dozeu/
 
 $(OBJ_DIR)/sha1.o: $(SHA1_DIR)/sha1.cpp $(SHA1_DIR)/sha1.hpp
@@ -841,7 +838,6 @@ clean-vg:
 
 clean:
 	$(RM) -r $(UNITTEST_BIN_DIR)
-	$(RM) -r $(BIN_DIR)
 	$(RM) -r $(LIB_DIR)
 	$(RM) -r $(UNITTEST_SUPPORT_OBJ_DIR)
 	$(RM) -r $(UNITTEST_OBJ_DIR)
diff --git a/deps/dozeu/dozeu.h b/deps/dozeu/dozeu.h
index 5d27362..9b9f01f 100644
--- a/deps/dozeu/dozeu.h
+++ b/deps/dozeu/dozeu.h
@@ -37,7 +37,7 @@
 #endif
 
 #define SIMDE_ENABLE_NATIVE_ALIASES
-#include "simde/x86/sse4.1.h"
+#include <simde/x86/sse4.1.h>
 
 // Only turn on extern "C" after including code that can use C++ features.
 #ifdef __cplusplus
diff --git a/deps/gssw/src/gssw.c b/deps/gssw/src/gssw.c
index 9981bf6..7c494b8 100644
--- a/deps/gssw/src/gssw.c
+++ b/deps/gssw/src/gssw.c
@@ -30,7 +30,7 @@
  *  Generalized to operate on graphs by Erik Garrison and renamed gssw.c
  */
 #define SIMDE_ENABLE_NATIVE_ALIASES
-#include "simde/x86/sse2.h"
+#include <simde/x86/sse2.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <stdio.h>
diff --git a/deps/gssw/src/gssw.h b/deps/gssw/src/gssw.h
index 176af7d..bfa44ff 100644
--- a/deps/gssw/src/gssw.h
+++ b/deps/gssw/src/gssw.h
@@ -14,7 +14,7 @@
 #include <string.h>
 #include <stdbool.h>
 #define SIMDE_ENABLE_NATIVE_ALIASES
-#include "simde/x86/sse4.1.h"
+#include <simde/x86/sse4.1.h>
 
 /*!	@typedef	structure of the query profile	*/
 struct gssw_profile;
diff --git a/deps/sdsl-lite/CMakeLists.txt b/deps/sdsl-lite/CMakeLists.txt
index 012ad23..a099805 100644
--- a/deps/sdsl-lite/CMakeLists.txt
+++ b/deps/sdsl-lite/CMakeLists.txt
@@ -79,19 +79,6 @@ if( MODE_TI )
   endif()
 endif()
 
-include(CheckSSE4_2)
-if( BUILTIN_POPCNT )
-  if( CMAKE_COMPILER_IS_GNUCXX )
-    append_cxx_compiler_flags("-msse4.2 -march=native" "GCC" CMAKE_CXX_OPT_FLAGS)
-  endif()
-  if( CMAKE_COMPILER_IS_GNUCXX )
-    append_cxx_compiler_flags("-msse4.2 -march=native" "CLANG" CMAKE_CXX_OPT_FLAGS)
-  endif()
-  if( CMAKE_COMPILER_IS_INTEL )
-    append_cxx_compiler_flags("-msse4.2 -march=native" "INTEL" CMAKE_CXX_FLAGS)
-  endif()
-endif()
-
 # check for demangle support to get pretty C++ class names
 include(FindCxaDemangle)
 if( HAVE_CXA_DEMANGLE )
diff --git a/src/preflight.cpp b/src/preflight.cpp
index fde71e4..8e02e8b 100644
--- a/src/preflight.cpp
+++ b/src/preflight.cpp
@@ -1,38 +1,11 @@
 #include "preflight.hpp"
 
-#include <iostream>
-#include <cstdlib>
-
-#ifdef __x86_64__
-#include <cpuid.h>
-#endif
-
 namespace vg {
 
 using namespace std;
 
 void preflight_check() {
     
-#ifdef __x86_64__
-    // We assume we are on x86_64 on POSIX (and not Windows).
-    // We use the method of dlib's dlib/simd/simd_check.h
-    
-    // Define a place to put the cpuid info
-    unsigned int cpuid_info[4];
-    
-    // Call cpuid function 1 (which reports SSE4.2, and other stuff up to original AVX)
-    __cpuid(1, cpuid_info[0], cpuid_info[1], cpuid_info[2], cpuid_info[3]);
-    
-    // Bit 20 of result 2 is the SSE 4.2 flag.
-    bool have_sse4_2 = cpuid_info[2] & (1 << 20);
-    
-    if (!have_sse4_2) {
-        cerr << "error[vg::preflight_check]: The CPU does not support SSE4.2 instructions. VG cannot run here. "
-            << "Please use a system with SSE4.2 support." << endl;
-        exit(1);
-    }
-#endif
-    // If not on x86_64, we are probably on ARM and using fake SSE anyway.
     
 }
 
diff --git a/src/preflight.hpp b/src/preflight.hpp
index 7db872e..45a5f49 100644
--- a/src/preflight.hpp
+++ b/src/preflight.hpp
@@ -11,14 +11,7 @@
 
 namespace vg {
 
-/// Define a macro to tell things to be built for every X86_64 architecture, if possible.
-/// This *doesn't* work on Mac with GNU GCC and Apple libc++, because functions
-/// for x86-64 can't use std::endl, so we exclude that combination.
-#if defined(__x86_64__) && (!defined(__GNUC__) || !defined(_LIBCPP_VERSION) || !defined(__APPLE__))
-    #define VG_PREFLIGHT_EVERYWHERE __attribute__((__target__("arch=x86-64")))
-#else
-    #define VG_PREFLIGHT_EVERYWHERE
-#endif
+#define VG_PREFLIGHT_EVERYWHERE
 
 /// Run a preflight check to make sure that the system is usable for this build of vg.
 /// Aborts with a helpful message if this is not the case.
