diff --git a/.github/workflows/ci-all-samples.yml b/.github/workflows/ci-all-samples.yml index 2eac6bd..c6cef88 100644 --- a/.github/workflows/ci-all-samples.yml +++ b/.github/workflows/ci-all-samples.yml @@ -9,6 +9,7 @@ jobs: uses: actions/checkout@v2 with: submodules: recursive + - run: sudo apt-get install g++ - run: make -C ${{ github.workspace }} -j$(nproc) run - name: Install libunwind-dev run: sudo apt-get install libunwind-dev libdwarf-dev=20200114-1 libdwarf1=20200114-1 diff --git a/Makefile b/Makefile index 5a7d792..43e70e9 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,8 @@ all: executables CHECK_CONFIG=1 CONFIG_STR=DEBUG=$(DEBUG) RECOVER_VAR_NAMES=$(RECOVER_VAR_NAMES) TRACER_USE_LIBUNWIND=$(TRACER_USE_LIBUNWIND) +CONFIG_STR+=EXTRA_CFLAGS=$(EXTRA_CFLAGS) + # Create a scratch directory where the files are stored $(shell mkdir -p $(BASE_DIR)/scratch) diff --git a/include/builder/builder_context.h b/include/builder/builder_context.h index 9fd2603..25d8e7a 100644 --- a/include/builder/builder_context.h +++ b/include/builder/builder_context.h @@ -37,9 +37,11 @@ class tag_map { std::unordered_map map; }; -void lambda_wrapper(void); +void lambda_wrapper(std::function); void lambda_wrapper_close(void); -void lambda_wrapper_impl(void); + +void coroutine_wrapper(std::function); +void coroutine_wrapper_close(void); class builder_context { public: @@ -47,7 +49,6 @@ class builder_context { static int debug_creation_counter; std::function internal_stored_lambda; - std::function current_function; std::list uncommitted_sequence; block::stmt::Ptr ast; diff --git a/make/setvars.mk b/make/setvars.mk index 871b33f..fd03063 100644 --- a/make/setvars.mk +++ b/make/setvars.mk @@ -9,10 +9,11 @@ endif DEBUG=1 endif +EXTRA_CFLAGS?= # Create CFLAGS, LINKER_FLAGS, CFLAGS_INTERNAL and INCLUDE_FLAGS based on config CFLAGS_INTERNAL=-std=c++11 -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wmissing-declarations -CFLAGS_INTERNAL+=-Woverloaded-virtual -Wno-deprecated -Wdelete-non-virtual-dtor -Werror -Wno-vla -pedantic-errors +CFLAGS_INTERNAL+=-Woverloaded-virtual -Wno-deprecated -Wdelete-non-virtual-dtor -Werror -Wno-vla -pedantic-errors CFLAGS= LINKER_FLAGS=-L$(BUILD_DIR)/ -l$(LIBRARY_NAME) INCLUDE_FLAGS=-I$(INCLUDE_DIR) -I$(BUILD_DIR)/gen_headers/ @@ -49,4 +50,5 @@ endif LINKER_FLAGS+=-ldl +CFLAGS+=$(EXTRA_CFLAGS) # --- flags are all ready diff --git a/src/builder/builder_context.cpp b/src/builder/builder_context.cpp index 13ee079..aacf40f 100644 --- a/src/builder/builder_context.cpp +++ b/src/builder/builder_context.cpp @@ -328,7 +328,7 @@ block::stmt::Ptr builder_context::extract_ast_from_function_internal(std::vector try { current_builder_context = this; // function(); - lambda_wrapper(); + lambda_wrapper(internal_stored_lambda); commit_uncommitted(); ret_ast = ast; current_builder_context = nullptr; @@ -463,8 +463,5 @@ block::stmt::Ptr builder_context::extract_ast_from_function_internal(std::vector return ret_ast; } -void lambda_wrapper_impl(void) { - builder_context::current_builder_context->internal_stored_lambda(); -} } // namespace builder diff --git a/src/builder/builder_context_support.cpp b/src/builder/builder_context_support.cpp index db75240..d377d2d 100644 --- a/src/builder/builder_context_support.cpp +++ b/src/builder/builder_context_support.cpp @@ -1,14 +1,22 @@ - +#include namespace builder { -void lambda_wrapper_impl(void); -void lambda_wrapper(void); +void lambda_wrapper(std::function); void lambda_wrapper_close(void); +void coroutine_wrapper(std::function); +void coroutine_wrapper_close(void); int tail_call_guard; -void lambda_wrapper(void) { - lambda_wrapper_impl(); +void lambda_wrapper(std::function f) { + f(); tail_call_guard += 1; } void lambda_wrapper_close(void) {} + + +void coroutine_wrapper(std::function f) { + f(); + tail_call_guard +=1; +} +void coroutine_wrapper_close(void) {} } // namespace builder diff --git a/src/util/tracer.cpp b/src/util/tracer.cpp index 44260cb..0e4b70e 100644 --- a/src/util/tracer.cpp +++ b/src/util/tracer.cpp @@ -8,7 +8,7 @@ #endif namespace builder { -extern void lambda_wrapper(void); +extern void lambda_wrapper(std::function); extern void lambda_wrapper_close(void); } // namespace builder namespace tracer {