Build fails when CXXFLAGS=-march=native
eigengrau opened this issue · comments
I’ve noticed that compilation fails (using gcc 6.1.1) when ucg is configured with CXXFLAGS
set to -march=native
.
g++ -ggdb3 -O3 -fno-omit-frame-pointer -pthread -Wformat -Wformat-security -Werror=format-security -march=native -ftree-vectorize -o ucg ucg-main.o ucg-build_info.o ./src/libsrc.a ./src/libext/libext.a ./src/future/libfuture.a ./src/libsrc_sse2.a ./src/libsrc_sse4_2_no_popcnt.a ./src/libsrc_sse4_2_popcnt.a ./src/libsrc.a -lpcre2-8 -lpcre
./src/libsrc.a(libsrc_a-FileScanner.o): In function `resolve_CountLinesSinceLastMatch':
/tmp/makepkg/ucg-git/src/ucg/src/FileScanner.cpp:296: undefined reference to `FileScanner::CountLinesSinceLastMatch_sse2(char const*, char const*)'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:631: ucg] Error 1
make[2]: Leaving directory '/tmp/makepkg/ucg-git/src/ucg'
make[1]: *** [Makefile:714: all-recursive] Error 1
make[1]: Leaving directory '/tmp/makepkg/ucg-git/src/ucg'
make: *** [Makefile:518: all] Error 2
Confirmed here on Fedora 24 x86-64/GCC 6.1.1/current master. I'll take a look.....
...and thanks for the report @eigengrau .
@eigengrau , what's the native arch for you?
I’m on ivybridge. More verbosely, gcc -march=native -E -v - </dev/null |& grep cc1
gives me
/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/cc1 -E -quiet -v - -march=ivybridge -mmmx -mno-3dnow -msse -msse2 -msse3 -mssse3 -mno-sse4a -mcx16 -msahf -mno-movbe -maes -mno-sha -mpclmul -mpopcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-bmi2 -mno-tbm -mavx -mno-avx2 -msse4.2 -msse4.1 -mno-lzcnt -mno-rtm -mno-hle -mrdrnd -mf16c -mfsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -mxsave -mxsaveopt -mno-avx512f -mno-avx512er -mno-avx512cd -mno-avx512pf -mno-prefetchwt1 -mno-clflushopt -mno-xsavec -mno-xsaves -mno-avx512dq -mno-avx512bw -mno-avx512vl -mno-avx512ifma -mno-avx512vbmi -mno-clwb -mno-pcommit -mno-mwaitx -mno-clzero -mno-pku --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=6144 -mtune=ivybridge
...yeah, I really need to get a new rig ;-).
As I feared, this is going to be another epic battle with Autoconf/Automake and company. The arch-specific separate compilations of FileScanner_sse4_2.cpp need to not have any additional -march=
or any other -msomeisaextension
flags on the command line, but ac/am are specifically designed to let the user (CXXFLAGS) always have the last say. I haven't found a way to undo a '-march=' in the source itself (e.g. _Pragma("GCC target (\"arch=x86-64,sse2\")")
doesn't seem to do anything), and that wouldn't be portable anyway. I'll get it somehow, -march=
should really work.
Or just don't use autotools... ;)
@kirbyfan64 Believe me, I have tried. And not just cmake
either (which had next to zero docs the last time I tried it, probably worth wasting a few weeks on again), and not just on this project. I always end up coming back to the GNU Build System AKA Autotools because there almost always is some way to work around whatever problem it is that I run into, and 80% of what I'm trying to do works on 99.44% of the platforms out there, including Windows if you count Cygwin and MinGW. Of course, that's because it goes all least-common-denominator under the hood. But then you get a request for OSX support, and hey, not having to worry if it's csh under there looks pretty good ;-).
Or maybe it's Stockholm Syndrome. Meh, six of one....
;-)
@gvansickle Haha... I wasn't actually referring to CMake. Tried it once and felt like I lost brain cells... I usually use one of Fbuild (the bias is real, though), gn, or Waf (works really well...when it wants to).
Well this just gets better and better. Guess what OSX has to say about my latest efforts, which work fine on BSD/Linux/Cygwin:
ld: warning: ignoring file ./src/libsrc_isa_ext_x86_64.a, file was built for archive which is not the architecture being linked (x86_64): ./src/libsrc_isa_ext_x86_64.a
And of course the link fails. Grrrrrrr.......
...AND I'M SPENT! And also, make CXXFLAGS='-march=whatever -mavx -mssewhatever ...
should now work on all platforms (at least x86-64 ones).
@eigengrau , can you please update to the latest master and try it again? I had to resort to libtool, so you'll have to re-autoreconf -i
your working dir. Thanks!
… and the crowd goes wild! 🎉
can you please update to the latest master and try it again?
I just tested on my work machine (sandybridge) and -march=native
worked fine. Will try ivybridge in the evening.
Excellent! Let me know and I'll close this issue as fixed.
Works on ivybridge just as well! Thanks @gvansickle!
We please to aim!