From ff0b0c1d3d0ccd4db1347187a365a683306e5605 Mon Sep 17 00:00:00 2001 From: Ajay Brahmakshatriya Date: Mon, 18 Dec 2023 14:18:51 -0500 Subject: [PATCH 1/4] Added support for passing arguments to lambda_wrapper and added coroutine_wrapper --- Makefile | 2 ++ include/builder/builder_context.h | 7 ++++--- make/setvars.mk | 4 +++- src/builder/builder_context.cpp | 5 +---- src/builder/builder_context_support.cpp | 18 +++++++++++++----- src/util/tracer.cpp | 2 +- 6 files changed, 24 insertions(+), 14 deletions(-) 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..727ee3c 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 { From 8d592c09bd5001fa1161c22ed090996cab0ff84a Mon Sep 17 00:00:00 2001 From: Ajay Brahmakshatriya Date: Mon, 18 Dec 2023 14:24:56 -0500 Subject: [PATCH 2/4] Added install g++ to github actions --- .github/workflows/ci-all-samples.yml | 1 + 1 file changed, 1 insertion(+) 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 From 25b69028b57cccd7cab1747d1e0fbb728f73f77b Mon Sep 17 00:00:00 2001 From: Ajay Brahmakshatriya Date: Mon, 18 Dec 2023 14:28:03 -0500 Subject: [PATCH 3/4] Added V=1 to github action --- .github/workflows/ci-all-samples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-all-samples.yml b/.github/workflows/ci-all-samples.yml index c6cef88..ceac4cb 100644 --- a/.github/workflows/ci-all-samples.yml +++ b/.github/workflows/ci-all-samples.yml @@ -10,7 +10,7 @@ jobs: with: submodules: recursive - run: sudo apt-get install g++ - - run: make -C ${{ github.workspace }} -j$(nproc) run + - run: make V=1 -C ${{ github.workspace }} -j$(nproc) run - name: Install libunwind-dev run: sudo apt-get install libunwind-dev libdwarf-dev=20200114-1 libdwarf1=20200114-1 - run: make -C ${{ github.workspace }} RECOVER_VAR_NAMES=1 -j$(nproc) run From 6cf5fcf53b61c6bb1846db0d44ae664b3a351052 Mon Sep 17 00:00:00 2001 From: Ajay Brahmakshatriya Date: Mon, 18 Dec 2023 14:30:22 -0500 Subject: [PATCH 4/4] Fixed default value for EXTRA_CFLAGS --- .github/workflows/ci-all-samples.yml | 2 +- make/setvars.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-all-samples.yml b/.github/workflows/ci-all-samples.yml index ceac4cb..c6cef88 100644 --- a/.github/workflows/ci-all-samples.yml +++ b/.github/workflows/ci-all-samples.yml @@ -10,7 +10,7 @@ jobs: with: submodules: recursive - run: sudo apt-get install g++ - - run: make V=1 -C ${{ github.workspace }} -j$(nproc) run + - 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 - run: make -C ${{ github.workspace }} RECOVER_VAR_NAMES=1 -j$(nproc) run diff --git a/make/setvars.mk b/make/setvars.mk index 727ee3c..fd03063 100644 --- a/make/setvars.mk +++ b/make/setvars.mk @@ -9,7 +9,7 @@ endif DEBUG=1 endif -EXTRA_CFLAGS?="" +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