travisdowns / freq-bench

Fine-grained frequency and voltage transition tests
19 stars 4 forks source link

Build break with clang #1

Closed ahh closed 4 years ago

ahh commented 4 years ago

Hey--I'm trying to build (on branch post1) using clang. (I'm on an odd system that has a truly ancient GCC.) Trying CC=clang CXX=clang make I got the following errors (many repetitions of this; edited for concision.)

` clang -DNDEBUG -MMD -Wall -Wextra -Werror -O2 -g -march=haswell -Wno-unused-parameter -Wno-error=unused-variable -Wno-unknown-pragmas -std=c++14 -DENABLE_TIMER=1 -c -o basic-impls.o basic-impls.cpp

:4:8: error: unexpected token in '.endr' directive .endr 4 ^ basic-impls.cpp:128:14: note: while in macro instantiation ALL_RATIOS_X(MAKE250ADD) ^ :2:2: note: instantiated into assembly here .rept 10 ^ :8:8: error: unexpected token in '.endr' directive .endr 4 ` This replicates with clang 7.0 and 9.0 on two systems. Anything else I can do to help you replicate the problem? Thanks!
travisdowns commented 4 years ago

@ahh - thanks for your report, I'm looking now.

travisdowns commented 4 years ago

@ahh - this issue should be fixed now, I just had a 4 hanging out in the inline asm for no particular reason and gcc accepts it while clang doesn't.

Note that to build with clang, you should do it like:

CC=clang CXX=clang++ make

That is, you need clang++ for CXX, not just clang. Otherwise you'll get all sorts of link errors since CXX is also used as the linker and clang doesn't link the C++ runtime by default.

After this change, I was able to build the benchmark with clang (10) on my system.

Let me know how it goes!

ahh commented 4 years ago

Fix verified; builds for me now. (And you're right about clang++, in many cases clang does a good enough job autodetecting that I rarely remember, but here it's necessary.)

Thanks!

travisdowns commented 4 years ago

in many cases clang does a good enough job autodetecting that I rarely remember, but here it's necessary.

Yeah it seems to auto-detect fine for compilation but for linking I think you need to call the right one or explicitly include the C++ libs.

Have fun with the benchmark!