diff options
author | Cristian Cadar <c.cadar@imperial.ac.uk> | 2016-12-09 12:20:49 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-09 12:20:49 +0000 |
commit | d7b03c98210d056bdc9cbf75156c6758b0dfa712 (patch) | |
tree | a9928caaf478c75a2f9ed940d9cc36fc4c6e5b5a | |
parent | c1c06b5f8e6579e3d0921b7ea5a828410986fbc5 (diff) | |
parent | e1255fbb2728eef85d995782ce72bea9f7179d35 (diff) | |
download | klee-d7b03c98210d056bdc9cbf75156c6758b0dfa712.tar.gz |
Merge pull request #535 from delcypher/cmake_fix_bitcode_rebuild_on_flag_change
[CMake] Fix bugs in the Makefile bitcode build system
-rw-r--r-- | runtime/Makefile.cmake.bitcode.config.in | 1 | ||||
-rw-r--r-- | runtime/Makefile.cmake.bitcode.rules | 21 |
2 files changed, 20 insertions, 2 deletions
diff --git a/runtime/Makefile.cmake.bitcode.config.in b/runtime/Makefile.cmake.bitcode.config.in index c554265f..5efa0154 100644 --- a/runtime/Makefile.cmake.bitcode.config.in +++ b/runtime/Makefile.cmake.bitcode.config.in @@ -39,6 +39,7 @@ USE_MODULE_INSTEAD_OF_BCA := @USE_RUNTIME_BINARY_TYPE_HACK@ # Commands MKDIR := mkdir RM := rm +CMP := cmp # Compiler flags LLVMCC.Flags += $(LLVMCC.ExtraFlags) \ diff --git a/runtime/Makefile.cmake.bitcode.rules b/runtime/Makefile.cmake.bitcode.rules index 27abde54..8261ce99 100644 --- a/runtime/Makefile.cmake.bitcode.rules +++ b/runtime/Makefile.cmake.bitcode.rules @@ -9,7 +9,7 @@ # This files defines the rules used for the bitcode build system. They are # inspired by LLVM's old Makefile build system. #===------------------------------------------------------------------------===# -.PHONY: all build_at_level clean debug_vars +.PHONY: all build_at_level clean debug_vars force CURRENT_DIR:= $(shell pwd) @@ -25,6 +25,7 @@ endif # Any changes to the files listed here will trigger a rebuild of the sources ADDITIONAL_BUILD_DEPS := $(CURRENT_DIR)/Makefile.cmake.bitcode \ $(RUNTIME_CMAKE_BINARY_DIR)/Makefile.cmake.bitcode.config \ + $(RUNTIME_CMAKE_BINARY_DIR)/Makefile.cmake.bitcode.rules \ $(RUNTIME_CMAKE_BINARY_DIR)/Makefile.cmake.bitcode # Handle VERBOSE @@ -78,8 +79,14 @@ C_SRCS_NO_DIR := $(notdir $(C_SRCS)) BC_FILES_NO_DIR := $(C_SRCS_NO_DIR:.c=.bc) BC_FILES := $(addprefix $(LOCAL_BUILD_DIR)/,$(BC_FILES_NO_DIR)) +# Path to file that stores the flags used for LLVMCC. +# If the build flags are changed this should trigger +# a change to the this file which will force a recompile +# of all sources +LLVMCC_FLAGS_FILE := $(LOCAL_BUILD_DIR)/LLVMCC_FLAGS + # All bitcode files have these additional dependencies -$(BC_FILES) : $(ADDITIONAL_BUILD_DEPS) +$(BC_FILES) : $(ADDITIONAL_BUILD_DEPS) $(LLVMCC_FLAGS_FILE) # Include dependency information generated by previous # compiler invocations if they exist @@ -91,6 +98,15 @@ $(LOCAL_BUILD_DIR)/%.bc : $(SRC_DIR)/%.c $(Verb) $(MKDIR) -p $(LOCAL_BUILD_DIR) $(Verb) $(LLVMCC) $(LLVMCC.Flags) $(LLVMCC.Warnings) $< -c -o $@ -MP -MMD -MF $(LOCAL_BUILD_DIR)/$*.dep +# $(LLVMCC_FLAGS_FILE) depends on `force` which will force the rule to +# rerun every build. However the rule will only update the file when the +# compile flags change which means we will trigger a rebuild when the compile +# flags change. +LLVMCC_FLAGS_FOR_FILE := $(LLVMCC) $(LLVMCC.Flags) $(LLVMCC.Warnings) +$(LLVMCC_FLAGS_FILE): force + $(Verb) $(MKDIR) -p "$(dir $(LLVMCC_FLAGS_FILE))" + $(Verb)echo "$(LLVMCC_FLAGS_FOR_FILE)" | $(CMP) -s - $@ || echo "$(LLVMCC_FLAGS_FOR_FILE)" > $@ + clean:: @echo "Removing bitcode files" $(Verb) $(RM) -f $(BC_FILES) @@ -154,6 +170,7 @@ debug_vars: @echo "IS_RELEASE := $(IS_RELEASE)" @echo "LOCAL_BUILD_DIR := $(LOCAL_BUILD_DIR)" @echo "LLVMCC := $(LLVMCC)" + @echo "LLVMCC_FLAGS_FILE := $(LLVMCC_FLAGS_FILE)" @echo "LLVMCC.Flags := $(LLVMCC.Flags)" @echo "LLVMCC.ExtraFlags := $(LLVMCC.ExtraFlags)" @echo "LLVMCC.Warnings := $(LLVMCC.Warnings)" |