hyperscan icon indicating copy to clipboard operation
hyperscan copied to clipboard

CMake not detecting ${GNUCC_ARCH} on Arch Linux, gcc 9.2

Open amno1 opened this issue 6 years ago • 7 comments

I have just cloned Hyperscan to my machine and am building it. Os is Arch Linux with latest kernel and GCC and I had some trouble with CMake. It repported error with Unix Makefiles generator. It didn't found the right architecture for -mtune flag.

The macro was in CMakeLists.txt, line 196: set (EXEC_ARGS ${CC_ARG1} -E - -mtune=${GNUCC_ARCH})

Changing this to: set EXEC_ARGS ${CC_ARG1} -E - -mtune=native)

seems to fix the issue. At least it did for me, Hyperscan seems to have built fine.

amno1 avatar Nov 01 '19 20:11 amno1

Can you show us the output of gcc -c -Q --help=target -march=native -mtune=native on your system?

xiangwang1 avatar Nov 22 '19 06:11 xiangwang1

Sure:

The following options are target specific:
  -m128bit-long-double        		[enabled]
  -m16                        		[disabled]
  -m32                        		[disabled]
  -m3dnow                     		[disabled]
  -m3dnowa                    		[disabled]
  -m64                        		[enabled]
  -m80387                     		[enabled]
  -m8bit-idiv                 		[disabled]
  -m96bit-long-double         		[disabled]
  -mabi=                      		sysv
  -mabm                       		[enabled]
  -maccumulate-outgoing-args  		[disabled]
  -maddress-mode=             		long
  -madx                       		[enabled]
  -maes                       		[enabled]
  -malign-data=               		compat
  -malign-double              		[disabled]
  -malign-functions=          		0
  -malign-jumps=              		0
  -malign-loops=              		0
  -malign-stringops           		[enabled]
  -mandroid                   		[disabled]
  -march=                     		skylake
  -masm=                      		att
  -mavx                       		[enabled]
  -mavx2                      		[enabled]
  -mavx256-split-unaligned-load 	[disabled]
  -mavx256-split-unaligned-store 	[disabled]
  -mavx5124fmaps              		[disabled]
  -mavx5124vnniw              		[disabled]
  -mavx512bitalg              		[disabled]
  -mavx512bw                  		[disabled]
  -mavx512cd                  		[disabled]
  -mavx512dq                  		[disabled]
  -mavx512er                  		[disabled]
  -mavx512f                   		[disabled]
  -mavx512ifma                		[disabled]
  -mavx512pf                  		[disabled]
  -mavx512vbmi                		[disabled]
  -mavx512vbmi2               		[disabled]
  -mavx512vl                  		[disabled]
  -mavx512vnni                		[disabled]
  -mavx512vpopcntdq           		[disabled]
  -mbionic                    		[disabled]
  -mbmi                       		[enabled]
  -mbmi2                      		[enabled]
  -mbranch-cost=<0,5>         		3
  -mcall-ms2sysv-xlogues      		[disabled]
  -mcet-switch                		[disabled]
  -mcld                       		[disabled]
  -mcldemote                  		[disabled]
  -mclflushopt                		[enabled]
  -mclwb                      		[disabled]
  -mclzero                    		[disabled]
  -mcmodel=                   		[default]
  -mcpu=                      		
  -mcrc32                     		[disabled]
  -mcx16                      		[enabled]
  -mdispatch-scheduler        		[disabled]
  -mdump-tune-features        		[disabled]
  -mf16c                      		[enabled]
  -mfancy-math-387            		[enabled]
  -mfentry                    		[disabled]
  -mfentry-name=              		
  -mfentry-section=           		
  -mfma                       		[enabled]
  -mfma4                      		[disabled]
  -mforce-drap                		[disabled]
  -mforce-indirect-call       		[disabled]
  -mfp-ret-in-387             		[enabled]
  -mfpmath=                   		sse
  -mfsgsbase                  		[enabled]
  -mfunction-return=          		keep
  -mfused-madd                		
  -mfxsr                      		[enabled]
  -mgeneral-regs-only         		[disabled]
  -mgfni                      		[disabled]
  -mglibc                     		[enabled]
  -mhard-float                		[enabled]
  -mhle                       		[enabled]
  -miamcu                     		[disabled]
  -mieee-fp                   		[enabled]
  -mincoming-stack-boundary=  		0
  -mindirect-branch-register  		[disabled]
  -mindirect-branch=          		keep
  -minline-all-stringops      		[disabled]
  -minline-stringops-dynamically 	[disabled]
  -minstrument-return=        		none
  -mintel-syntax              		
  -mlarge-data-threshold=<number> 	65536
  -mlong-double-128           		[disabled]
  -mlong-double-64            		[disabled]
  -mlong-double-80            		[enabled]
  -mlwp                       		[disabled]
  -mlzcnt                     		[enabled]
  -mmanual-endbr              		[disabled]
  -mmemcpy-strategy=          		
  -mmemset-strategy=          		
  -mmitigate-rop              		[disabled]
  -mmmx                       		[enabled]
  -mmovbe                     		[enabled]
  -mmovdir64b                 		[disabled]
  -mmovdiri                   		[disabled]
  -mmpx                       		[disabled]
  -mms-bitfields              		[disabled]
  -mmusl                      		[disabled]
  -mmwaitx                    		[disabled]
  -mno-align-stringops        		[disabled]
  -mno-default                		[disabled]
  -mno-fancy-math-387         		[disabled]
  -mno-push-args              		[disabled]
  -mno-red-zone               		[disabled]
  -mno-sse4                   		[disabled]
  -mnop-mcount                		[disabled]
  -momit-leaf-frame-pointer   		[disabled]
  -mpc32                      		[disabled]
  -mpc64                      		[disabled]
  -mpc80                      		[disabled]
  -mpclmul                    		[enabled]
  -mpcommit                   		[disabled]
  -mpconfig                   		[disabled]
  -mpku                       		[disabled]
  -mpopcnt                    		[enabled]
  -mprefer-avx128             		
  -mprefer-vector-width=      		none
  -mpreferred-stack-boundary= 		0
  -mprefetchwt1               		[disabled]
  -mprfchw                    		[enabled]
  -mptwrite                   		[disabled]
  -mpush-args                 		[enabled]
  -mrdpid                     		[disabled]
  -mrdrnd                     		[enabled]
  -mrdseed                    		[enabled]
  -mrecip                     		[disabled]
  -mrecip=                    		
  -mrecord-mcount             		[disabled]
  -mrecord-return             		[disabled]
  -mred-zone                  		[enabled]
  -mregparm=                  		6
  -mrtd                       		[disabled]
  -mrtm                       		[enabled]
  -msahf                      		[enabled]
  -msgx                       		[enabled]
  -msha                       		[disabled]
  -mshstk                     		[disabled]
  -mskip-rax-setup            		[disabled]
  -msoft-float                		[disabled]
  -msse                       		[enabled]
  -msse2                      		[enabled]
  -msse2avx                   		[disabled]
  -msse3                      		[enabled]
  -msse4                      		[enabled]
  -msse4.1                    		[enabled]
  -msse4.2                    		[enabled]
  -msse4a                     		[disabled]
  -msse5                      		
  -msseregparm                		[disabled]
  -mssse3                     		[enabled]
  -mstack-arg-probe           		[disabled]
  -mstack-protector-guard-offset= 	
  -mstack-protector-guard-reg= 		
  -mstack-protector-guard-symbol= 	
  -mstack-protector-guard=    		tls
  -mstackrealign              		[disabled]
  -mstringop-strategy=        		[default]
  -mstv                       		[enabled]
  -mtbm                       		[disabled]
  -mtls-dialect=              		gnu
  -mtls-direct-seg-refs       		[enabled]
  -mtune-ctrl=                		
  -mtune=                     		skylake
  -muclibc                    		[disabled]
  -mvaes                      		[disabled]
  -mveclibabi=                		[default]
  -mvect8-ret-in-mem          		[disabled]
  -mvpclmulqdq                		[disabled]
  -mvzeroupper                		[enabled]
  -mwaitpkg                   		[disabled]
  -mwbnoinvd                  		[disabled]
  -mx32                       		[disabled]
  -mxop                       		[disabled]
  -mxsave                     		[enabled]
  -mxsavec                    		[enabled]
  -mxsaveopt                  		[enabled]
  -mxsaves                    		[enabled]

  Known assembler dialects (for use with the -masm= option):
    att intel

  Known ABIs (for use with the -mabi= option):
    ms sysv

  Known code models (for use with the -mcmodel= option):
    32 kernel large medium small

  Valid arguments to -mfpmath=:
    387 387+sse 387,sse both sse sse+387 sse,387

  Known indirect branch choices (for use with the -mindirect-branch=/-mfunction-return= options):
    keep thunk thunk-extern thunk-inline

  Known choices for return instrumentation with -minstrument-return=:
    call none nop5

  Known data alignment choices (for use with the -malign-data= option):
    abi cacheline compat

  Known vectorization library ABIs (for use with the -mveclibabi= option):
    acml svml

  Known address mode (for use with the -maddress-mode= option):
    long short

  Known preferred register vector length (to use with the -mprefer-vector-width= option):
    128 256 512 none

  Known stack protector guard (for use with the -mstack-protector-guard= option):
    global tls

  Valid arguments to -mstringop-strategy=:
    byte_loop libcall loop rep_4byte rep_8byte rep_byte unrolled_loop vector_loop

  Known TLS dialects (for use with the -mtls-dialect= option):
    gnu gnu2

  Known valid arguments for -march= option:
    i386 i486 i586 pentium lakemont pentium-mmx winchip-c6 winchip2 c3 samuel-2 c3-2 nehemiah c7 esther i686 pentiumpro pentium2 pentium3 pentium3m pentium-m pentium4 pentium4m prescott nocona core2 nehalem corei7 westmere sandybridge corei7-avx ivybridge core-avx-i haswell core-avx2 broadwell skylake skylake-avx512 cannonlake icelake-client icelake-server cascadelake bonnell atom silvermont slm goldmont goldmont-plus tremont knl knm intel geode k6 k6-2 k6-3 athlon athlon-tbird athlon-4 athlon-xp athlon-mp x86-64 eden-x2 nano nano-1000 nano-2000 nano-3000 nano-x2 eden-x4 nano-x4 k8 k8-sse3 opteron opteron-sse3 athlon64 athlon64-sse3 athlon-fx amdfam10 barcelona bdver1 bdver2 bdver3 bdver4 znver1 znver2 btver1 btver2 generic native

  Known valid arguments for -mtune= option:
    generic i386 i486 pentium lakemont pentiumpro pentium4 nocona core2 nehalem sandybridge haswell bonnell silvermont goldmont goldmont-plus tremont knl knm skylake skylake-avx512 cannonlake icelake-client icelake-server cascadelake intel geode k6 athlon k8 amdfam10 bdver1 bdver2 bdver3 bdver4 btver1 btver2 znver1 znver2

amno1 avatar Nov 24 '19 13:11 amno1

Just for completeness this is gcc version i used:

 2019-11-24 14:48:31 ⌚  pascal in ~
○ → gcc --version
gcc (GCC) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

And the OS:

 2019-11-24 14:52:43 ⌚  pascal in ~
○ → uname -a
Linux pascal 5.3.13-arch1-1 #1 SMP PREEMPT Sun, 24 Nov 2019 10:15:50 +0000 x86_64 GNU/Linux

amno1 avatar Nov 24 '19 13:11 amno1

Thanks. They look find to me. string(REGEX REPLACE ".*march=[ \t]*([^ \n]*)[ \n].*" "\\1" should be able to extract skylake from the line -march= skylake in your output.

Can you print out the value of ${GNUCC_ARCH}?

xiangwang1 avatar Nov 25 '19 08:11 xiangwang1

Sorry, I am not sure what do you want me to do? ${GNUCC_ARCH}, is that a cmake macro? How do I extract that?

Just for the curiosity, why? Can you not just use -mtune=native and -march=native and let gcc do it on it's own? Why bother to pass it from within cmake? Or am I missing something?

amno1 avatar Nov 25 '19 14:11 amno1

The macro was in CMakeLists.txt, line 196: set (EXEC_ARGS ${CC_ARG1} -E - -mtune=${GNUCC_ARCH})

As you mentioned that CMake didn't found the right architecture for -mtune flag, then the value of GNUCC_ARCH shouldn't be valid. If so, it'll be good to know its value.

We used to have -mtune=native and -march=native, but the generated instructions by GCC weren't consistent with that of explicitly specifying the CPU architecture, which may impact our performance in some cases.

xiangwang1 avatar Nov 26 '19 01:11 xiangwang1

It was none, empty string. At least what I believe. I have edited back cmakelists.txt and run cmake to generate makefiles, this is what I get:

2019-11-26 05:14:07 ⌚  pascal in ~/repos/hyperscan/build
± |master U:1 ?:2 ✗| → cmake .. -G "Unix Makefiles"
-- The C compiler identification is GNU 9.2.0
-- The CXX compiler identification is GNU 9.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test ARCH_64_BIT
-- Performing Test ARCH_64_BIT - Success
-- Performing Test ARCH_32_BIT
-- Performing Test ARCH_32_BIT - Failed
-- Default build type 'Release with debug info'
-- using release build
-- Boost version: 1.71.0
-- Found PythonInterp: /usr/bin/python (found version "3.8")
-- Build date: 2019-11-26
-- Building static libraries
-- gcc version 9.2.0
CMake Error at CMakeLists.txt:202 (message):
  Something went wrong determining gcc tune: -mtune=: not valid


-- g++ version 9.2.0
-- Looking for include file unistd.h
-- Looking for include file unistd.h - found
-- Looking for include file intrin.h
-- Looking for include file intrin.h - not found
-- Looking for C++ include intrin.h
-- Looking for C++ include intrin.h - not found
-- Looking for include file x86intrin.h
-- Looking for include file x86intrin.h - found
-- Looking for C++ include x86intrin.h
-- Looking for C++ include x86intrin.h - found
-- Looking for posix_memalign
-- Looking for posix_memalign - found
-- Looking for _aligned_malloc
-- Looking for _aligned_malloc - not found
-- Performing Test HAS_C_HIDDEN
-- Performing Test HAS_C_HIDDEN - Success
-- Performing Test HAS_CXX_HIDDEN
-- Performing Test HAS_CXX_HIDDEN - Success
-- Looking for _LIBCPP_VERSION
-- Looking for _LIBCPP_VERSION - not found
-- generator is Unix Makefiles
-- Performing Test HAS_C_ATTR_IFUNC
-- Performing Test HAS_C_ATTR_IFUNC - Success
-- Performing Test HAVE_SSSE3
-- Performing Test HAVE_SSSE3 - Success
-- Performing Test HAVE_AVX2
-- Performing Test HAVE_AVX2 - Success
-- Performing Test HAVE_AVX512
-- Performing Test HAVE_AVX512 - Failed
-- Performing Test HAVE_CC_BUILTIN_ASSUME_ALIGNED
-- Performing Test HAVE_CC_BUILTIN_ASSUME_ALIGNED - Success
-- Performing Test HAVE_CXX_BUILTIN_ASSUME_ALIGNED
-- Performing Test HAVE_CXX_BUILTIN_ASSUME_ALIGNED - Success
-- Performing Test HAVE__BUILTIN_CONSTANT_P
-- Performing Test HAVE__BUILTIN_CONSTANT_P - Success
-- Performing Test C_FLAG_Wvla
-- Performing Test C_FLAG_Wvla - Success
-- Performing Test C_FLAG_Wpointer_arith
-- Performing Test C_FLAG_Wpointer_arith - Success
-- Performing Test C_FLAG_Wstrict_prototypes
-- Performing Test C_FLAG_Wstrict_prototypes - Success
-- Performing Test C_FLAG_Wmissing_prototypes
-- Performing Test C_FLAG_Wmissing_prototypes - Success
-- Performing Test CXX_FLAG_Wvla
-- Performing Test CXX_FLAG_Wvla - Success
-- Performing Test CXX_FLAG_Wpointer_arith
-- Performing Test CXX_FLAG_Wpointer_arith - Success
-- Performing Test CC_SELF_ASSIGN
-- Performing Test CC_SELF_ASSIGN - Failed
-- Performing Test CXX_SELF_ASSIGN
-- Performing Test CXX_SELF_ASSIGN - Failed
-- Performing Test CC_PAREN_EQUALITY
-- Performing Test CC_PAREN_EQUALITY - Failed
-- Performing Test CXX_UNUSED_CONST_VAR
-- Performing Test CXX_UNUSED_CONST_VAR - Success
-- Performing Test CXX_IGNORED_ATTR
-- Performing Test CXX_IGNORED_ATTR - Success
-- Performing Test CXX_REDUNDANT_MOVE
-- Performing Test CXX_REDUNDANT_MOVE - Success
-- Performing Test CXX_WEAK_VTABLES
-- Performing Test CXX_WEAK_VTABLES - Failed
-- Performing Test CXX_MISSING_DECLARATIONS
-- Performing Test CXX_MISSING_DECLARATIONS - Success
-- Performing Test CXX_UNUSED_LOCAL_TYPEDEFS
-- Performing Test CXX_UNUSED_LOCAL_TYPEDEFS - Success
-- Performing Test CXX_WUNUSED_VARIABLE
-- Performing Test CXX_WUNUSED_VARIABLE - Success
-- Building runtime for multiple microarchitectures
-- Looking for mmap
-- Looking for mmap - found
-- Found PkgConfig: /usr/bin/pkg-config (found version "1.6.3")
-- Checking for module 'libpcre>=8.41'
--   Found libpcre, version 8.43
-- PCRE version 8.41 or above
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Checking for module 'sqlite3'
--   Found sqlite3, version 3.30.1
-- Performing Test SQLITE_VERSION_OK
-- Performing Test SQLITE_VERSION_OK - Success
-- Looking for sqlite3_open_v2
-- Looking for sqlite3_open_v2 - found
-- Looking for C++ include pthread_np.h
-- Looking for C++ include pthread_np.h - not found
-- Looking for pthread_setaffinity_np
-- Looking for pthread_setaffinity_np - found
-- Looking for malloc_info
-- Looking for malloc_info - found
-- Looking for shmget
-- Looking for shmget - found
-- Performing Test BACKTRACE_LIBC
-- Performing Test BACKTRACE_LIBC - Success
-- Performing Test HAS_RDYNAMIC
-- Performing Test HAS_RDYNAMIC - Success
-- Looking for sigaltstack
-- Looking for sigaltstack - found
-- Looking for sigaction
-- Looking for sigaction - found
-- Looking for setrlimit
-- Looking for setrlimit - found
-- Configuring incomplete, errors occurred!
See also "/home/arthur/repos/hyperscan/build/CMakeFiles/CMakeOutput.log".
See also "/home/arthur/repos/hyperscan/build/CMakeFiles/CMakeError.log".

When I change back from -mtune=${GNUCC_ARCH} to -mtune=native it generates makefiles fine, and I can build hyperscan.

Is there some way I can see what value of GNUCC_ARCH evalutes to in cmake? I am sorry I am not that versatile with cmake. Tried some options I found on SX, but didn't give me anything reasonable.

amno1 avatar Nov 26 '19 04:11 amno1