[sledge] Query llvm-config for compilation flags for tests

Summary:
At least when installation of the conf-llvm package uses a non-system
llvm, additional compilation flags are needed. These can be queries by
asking opam for the location of the llvm-config binary, and asking
that for the compilation flags.

Reviewed By: ngorogiannis

Differential Revision: D28907810

fbshipit-source-id: 6806c78a8
master
Josh Berdine 3 years ago committed by Facebook GitHub Bot
parent 5a8fe540d3
commit 0d430efb42

@ -36,6 +36,10 @@ diff?=patdiff
# select llvm and clang used by opam # select llvm and clang used by opam
export PATH := $(shell $$(opam config var conf-llvm:config) --bindir):$(PATH) export PATH := $(shell $$(opam config var conf-llvm:config) --bindir):$(PATH)
# query llvm-config for compilation flags
C_FLAGS = $(shell $$(opam config var conf-llvm:config) --cflags)
CXX_FLAGS = $(shell $$(opam config var conf-llvm:config) --cxxflags)
# configure sort # configure sort
export LANG := C export LANG := C
@ -43,11 +47,11 @@ default: test
# compile c to llvm bitcode # compile c to llvm bitcode
%.bc : %.c $(CURDIR)/../model/llair_intrinsics.h %.bc : %.c $(CURDIR)/../model/llair_intrinsics.h
(cd $(@D) && clang -g -c -emit-llvm -include $(CURDIR)/../model/llair_intrinsics.h -Wno-main-return-type $(CLANG_ARGS) -o $(@F) $(<F)) (cd $(@D) && clang -g -c -emit-llvm $(C_FLAGS) -include $(CURDIR)/../model/llair_intrinsics.h -Wno-main-return-type $(CLANG_ARGS) -o $(@F) $(<F))
# compile c++ to llvm bitcode # compile c++ to llvm bitcode
%.bc : %.cpp %.bc : %.cpp
(cd $(@D) && clang++ -g -c -emit-llvm $(CLANG_ARGS) -o $(@F) $(<F)) (cd $(@D) && clang++ -g -c -emit-llvm $(CXX_FLAGS) $(CLANG_ARGS) -o $(@F) $(<F))
# disassemble bitcode to llvm assembly # disassemble bitcode to llvm assembly
%.ll : %.bc %.ll : %.bc

Loading…
Cancel
Save