diff options
author | Dan Liew <daniel.liew@imperial.ac.uk> | 2017-07-24 09:48:04 +0100 |
---|---|---|
committer | Dan Liew <daniel.liew@imperial.ac.uk> | 2017-07-24 10:13:31 +0100 |
commit | c0d1bfe5386d73f9998e439a0e28e5ec6a4083e1 (patch) | |
tree | 57f48ccdd41695e2c3c3079e15553a64a300c90d /runtime | |
parent | 9fb2f5666d5f8c7c2f335fc8408883a0cf958964 (diff) | |
download | klee-c0d1bfe5386d73f9998e439a0e28e5ec6a4083e1.tar.gz |
[CMake] Fix bug where the runtime build system would not rebuild bitcode
archive/modules when the list of source files that constitute it changes. To fix this a file is written in the build directory that contains the list of `.bc` files. This file is updated whenever the list of `.bc` files for a module changes and then the rule that builds the module/archive depends on that file. This fixes a bug reported by @ccadar in #718.
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/Makefile.cmake.bitcode.rules | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/runtime/Makefile.cmake.bitcode.rules b/runtime/Makefile.cmake.bitcode.rules index 2737eb80..472c979b 100644 --- a/runtime/Makefile.cmake.bitcode.rules +++ b/runtime/Makefile.cmake.bitcode.rules @@ -81,7 +81,7 @@ endif # Compute the directory to put build files LOCAL_BUILD_DIR := $(abspath $(ROOT_OBJ)/$(DIR_SUFFIX)) -C_SRCS := $(shell echo $(SRC_DIR)/*.c) +C_SRCS := $(sort $(shell echo $(SRC_DIR)/*.c)) 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)) @@ -92,6 +92,12 @@ BC_FILES := $(addprefix $(LOCAL_BUILD_DIR)/,$(BC_FILES_NO_DIR)) # of all sources LLVMCC_FLAGS_FILE := $(LOCAL_BUILD_DIR)/LLVMCC_FLAGS +# Path to file that stores list of bc files that constitute +# bitcode archive or bitcode module. If the list of bitcode +# files changes this should trigger a rebuild of the bitcode +# archive or module +BC_FILE_LIST_FILE := $(LOCAL_BUILD_DIR)/BC_FILE_LIST + # All bitcode files have these additional dependencies $(BC_FILES) : $(ADDITIONAL_BUILD_DEPS) $(LLVMCC_FLAGS_FILE) @@ -114,6 +120,14 @@ $(LLVMCC_FLAGS_FILE): force $(Verb) $(MKDIR) -p "$(dir $(LLVMCC_FLAGS_FILE))" $(Verb)echo "$(LLVMCC_FLAGS_FOR_FILE)" | $(CMP) -s - $@ || echo "$(LLVMCC_FLAGS_FOR_FILE)" > $@ +# $(BC_FILE_LIST_FILE) depends on `force` which will force rule to +# rerun every build. However the rule will only update the file when +# the list of bc files changes which means we should only trigger a rebuild +# or the bitcode archive/module when the list of bc files changes +$(BC_FILE_LIST_FILE): force + $(Verb) $(MKDIR) -p "$(dir $(BC_FILE_LIST_FILE))" + $(Verb)echo "$(BC_FILES_NO_DIR)" | $(CMP) -s - $@ || echo "$(BC_FILES_NO_DIR)" > $@ + clean:: @echo "Removing bitcode files" $(Verb) $(RM) -f $(BC_FILES) @@ -132,10 +146,12 @@ MODULE_FILE := $(MODULE_DEST)/$(MODULE_NAME).bc build_at_level:: $(MODULE_FILE) # Rule for building LLVM bitcode module -$(MODULE_FILE): $(BC_FILES) +# NOTE: Dependency on $(BC_FILE_LIST_FILE) is to force +# rebuild when list of BC_FILES changes. +$(MODULE_FILE): $(BC_FILES) $(BC_FILE_LIST_FILE) $(Verb) $(MKDIR) -p $(MODULE_DEST) @echo "Creating LLVM module $@" - $(Verb)$(LLVM_LINK) -o $@ $^ + $(Verb)$(LLVM_LINK) -o $@ $(BC_FILES) clean:: @echo "Removing LLVM module $(MODULE_FILE)" @@ -148,11 +164,13 @@ ARCHIVE_FILE := $(ARCHIVE_DEST)/lib$(ARCHIVE_NAME).bca build_at_level:: $(ARCHIVE_FILE) # Rule for building LLVM bitcode archive -$(ARCHIVE_FILE): $(BC_FILES) +# NOTE: Dependency on $(BC_FILE_LIST_FILE) is to force +# rebuild when list of BC_FILES changes. +$(ARCHIVE_FILE): $(BC_FILES) $(BC_FILE_LIST_FILE) $(Verb) $(MKDIR) -p $(ARCHIVE_DEST) @echo "Creating LLVM archive $@" $(Verb) $(RM) -f $@ - $(Verb)$(LLVM_AR) rcs $@ $^ + $(Verb)$(LLVM_AR) rcs $@ $(BC_FILES) clean:: @echo "Removing LLVM bitcode archive $(ARCHIVE_FILE)" @@ -170,6 +188,8 @@ debug_vars: @echo "ARCHIVE_FILE := $(ARCHIVE_FILE)" @echo "ASSERTIONS_ENABLED := $(ASSERTIONS_ENABLED)" @echo "BC_FILES := $(BC_FILES)" + @echo "BC_FILES_NO_DIR := $(BC_FILES_NO_DIR)" + @echo "BC_FILE_LIST_FILE := $(BC_FILE_LIST_FILE)" @echo "BUILD_ROOT := $(BUILD_ROOT)" @echo "C_SRCS := $(C_SRCS)" @echo "CURRENT_DIR := $(CURRENT_DIR)" |