From 69aeb9e034c82646fb0eeb88c3efc3a43e7e67a2 Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Tue, 29 Sep 2020 12:12:53 -0700 Subject: [PATCH] Fix runtime build rules in Makefile: - one of the Windows-specific runtime files had a 32-vs-64 glitch - CMake now uses `fno-threadsafe-statics` (instead of `-std=gnu++98`) to disable thread-safe static initialization; as a result, this allowed C++11 code requirements to creep in (via d3d12compute.cpp), but we didn't notice because the Makefile wasn't properly building that file due to the 32-vs-64 glitch. Fixed by updating the Makefile to use this flag instead (which was an overdue fix anyway). --- Makefile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index e68ca8a8f55c..40b78f4b6901 100644 --- a/Makefile +++ b/Makefile @@ -973,9 +973,9 @@ RUNTIME_TRIPLE_64 = "le64-unknown-unknown-unknown" RUNTIME_TRIPLE_WIN_32 = "i386-unknown-unknown-unknown" RUNTIME_TRIPLE_WIN_64 = "x86_64-unknown-windows-unknown" -# -std=gnu++98 is deliberate; we do NOT want c++11 here, -# as we don't want static locals to get thread synchronization stuff. -RUNTIME_CXX_FLAGS = -O3 -fno-vectorize -ffreestanding -fno-blocks -fno-exceptions -fno-unwind-tables -std=gnu++98 +# `-fno-threadsafe-statics` is very important here (note that it allows us to use a 'modern' C++ +# standard but still skip threadsafe guards for static initialization in our runtime code) +RUNTIME_CXX_FLAGS = -std=c++11 -O3 -fno-vectorize -ffreestanding -fno-blocks -fno-exceptions -fno-unwind-tables -fno-threadsafe-statics $(BUILD_DIR)/initmod.windows_%_32.ll: $(SRC_DIR)/runtime/windows_%.cpp $(BUILD_DIR)/clang_ok @mkdir -p $(@D) @@ -995,7 +995,7 @@ $(BUILD_DIR)/initmod.%_32.ll: $(SRC_DIR)/runtime/%.cpp $(BUILD_DIR)/clang_ok $(BUILD_DIR)/initmod.windows_%_64_debug.ll: $(SRC_DIR)/runtime/windows_%.cpp $(BUILD_DIR)/clang_ok @mkdir -p $(@D) - $(CLANG) $(CXX_WARNING_FLAGS) -g -DDEBUG_RUNTIME $(RUNTIME_CXX_FLAGS) -m32 -target $(RUNTIME_TRIPLE_WIN_64) -DCOMPILING_HALIDE_RUNTIME -DBITS_32 -emit-llvm -S $(SRC_DIR)/runtime/windows_$*.cpp -o $@ -MMD -MP -MF $(BUILD_DIR)/initmod.windows_$*_32_debug.d + $(CLANG) $(CXX_WARNING_FLAGS) -g -DDEBUG_RUNTIME $(RUNTIME_CXX_FLAGS) -m32 -target $(RUNTIME_TRIPLE_WIN_64) -DCOMPILING_HALIDE_RUNTIME -DBITS_64 -emit-llvm -S $(SRC_DIR)/runtime/windows_$*.cpp -o $@ -MMD -MP -MF $(BUILD_DIR)/initmod.windows_$*_64_debug.d $(BUILD_DIR)/initmod.%_64_debug.ll: $(SRC_DIR)/runtime/%.cpp $(BUILD_DIR)/clang_ok @mkdir -p $(@D) @@ -1500,7 +1500,7 @@ $(FILTERS_DIR)/external_code.halide_generated.cpp: $(BIN_DIR)/external_code.gene @mkdir -p $(@D) $(CURDIR)/$< -g external_code -e c_source -o $(CURDIR)/$(FILTERS_DIR) target=$(TARGET)-no_runtime external_code_is_bitcode=false -$(FILTERS_DIR)/autograd_grad.a: $(BIN_DIR)/autograd.generator $(DISTRIB_DIR)/lib/libautoschedule_mullapudi2016.$(SHARED_EXT) +$(FILTERS_DIR)/autograd_grad.a: $(BIN_DIR)/autograd.generator $(DISTRIB_DIR)/lib/libautoschedule_mullapudi2016.$(SHARED_EXT) @mkdir -p $(@D) # FIXME: The autoscheduler looks for libHalide in the same # directory, which is normally a distro. But the generator @@ -1761,7 +1761,7 @@ $(BIN_DIR)/tutorial_lesson_21_auto_scheduler_generate: $(ROOT_DIR)/tutorial/less # ...in that order. LESSON_21_MACHINE_PARAMS = 32,16777216,40 -$(BIN_DIR)/tutorial_lesson_21_auto_scheduler_run: $(ROOT_DIR)/tutorial/lesson_21_auto_scheduler_run.cpp $(BIN_DIR)/tutorial_lesson_21_auto_scheduler_generate $(DISTRIB_DIR)/lib/libautoschedule_mullapudi2016.$(SHARED_EXT) +$(BIN_DIR)/tutorial_lesson_21_auto_scheduler_run: $(ROOT_DIR)/tutorial/lesson_21_auto_scheduler_run.cpp $(BIN_DIR)/tutorial_lesson_21_auto_scheduler_generate $(DISTRIB_DIR)/lib/libautoschedule_mullapudi2016.$(SHARED_EXT) @-mkdir -p $(TMP_DIR) # Run the generator $(BIN_DIR)/tutorial_lesson_21_auto_scheduler_generate -g auto_schedule_gen -o $(TMP_DIR) -e static_library,c_header,schedule -f auto_schedule_false target=host auto_schedule=false @@ -1872,7 +1872,7 @@ test_adams2019: distrib test_li2018: distrib build_python_bindings $(MAKE) -f $(SRC_DIR)/autoschedulers/li2018/Makefile test \ HALIDE_DISTRIB_PATH=$(CURDIR)/$(DISTRIB_DIR) \ - HALIDE_PYTHON_BINDINGS_PATH=$(CURDIR)/$(BIN_DIR)/python3_bindings + HALIDE_PYTHON_BINDINGS_PATH=$(CURDIR)/$(BIN_DIR)/python3_bindings time_compilation_test_%: $(BIN_DIR)/test_% $(TIME_COMPILATION) compile_times_correctness.csv make -f $(THIS_MAKEFILE) $(@:time_compilation_test_%=test_%)