From 52d390d00300af655740194fdcb3200009db93df Mon Sep 17 00:00:00 2001 From: "John F. Carr" Date: Mon, 13 Apr 2026 17:11:33 -0400 Subject: [PATCH] Put both exception personalities into the main runtime library --- runtime/CMakeLists.txt | 17 +++------------- runtime/Makefile | 24 ++--------------------- runtime/personality-c.c | 33 ------------------------------- runtime/personality-cpp.cpp | 34 -------------------------------- runtime/personality.cpp | 39 +++++++++++++++++++++++++++++++++++++ 5 files changed, 44 insertions(+), 103 deletions(-) delete mode 100644 runtime/personality-c.c delete mode 100644 runtime/personality-cpp.cpp diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index a77fbb34..0e6f7d46 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -30,14 +30,6 @@ set(CHEETAH_PEDIGREE_LIB_SOURCES pedigree_lib.cpp ) -set(CHEETAH_PERSONALITY_C_SOURCES - personality-c.c -) - -set(CHEETAH_PERSONALITY_CPP_SOURCES - personality-cpp.cpp -) - #set_source_files_properties(file.cpp PROPERTIES COMPILE_OPTIONS -...) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) @@ -81,9 +73,6 @@ set(CHEETAH_BITCODE_ABI_COMPILE_DEFS ${CHEETAH_COMPILE_DEFS} "CHEETAH_API_CONSUMER=1" "CILK_DEBUG=0") -set(CHEETAH_PERSONALITY_COMPILE_DEFS ${CHEETAH_COMPILE_DEFS} - "CHEETAH_API_CONSUMER=1") - # Set compile flags, compile defs, and link flags for ASan build set(CHEETAH_ASAN_COMPILE_FLAGS ${CHEETAH_COMPILE_FLAGS}) set(CHEETAH_ASAN_COMPILE_DEFS ${CHEETAH_COMPILE_DEFS} "CILK_ENABLE_ASAN_HOOKS=1") @@ -112,9 +101,9 @@ set(CHEETAH_BITCODES "opencilk-abi") set(CHEETAH_ASAN_BITCODES "opencilk-asan-abi") set(CHEETAH_BITCODE_SOURCES "CHEETAH_ABI_SOURCE") # List of libraries and corresponding sources -set(CHEETAH_LIBRARIES "opencilk" "opencilk-personality-c" "opencilk-personality-cpp" "opencilk-pedigrees") -set(CHEETAH_ASAN_LIBRARIES "opencilk-asan" "opencilk-asan-personality-c" "opencilk-asan-personality-cpp" "opencilk-pedigrees-asan") -set(CHEETAH_LIBRARY_SOURCES "CHEETAH_SOURCES" "CHEETAH_PERSONALITY_C_SOURCES" "CHEETAH_PERSONALITY_CPP_SOURCES" "CHEETAH_PEDIGREE_LIB_SOURCES") +set(CHEETAH_LIBRARIES "opencilk" "opencilk-pedigrees") +set(CHEETAH_ASAN_LIBRARIES "opencilk-asan" "opencilk-pedigrees-asan") +set(CHEETAH_LIBRARY_SOURCES "CHEETAH_SOURCES" "CHEETAH_PEDIGREE_LIB_SOURCES") # Add all bitcode and library variants if (APPLE) diff --git a/runtime/Makefile b/runtime/Makefile index 0a61d215..a336bb31 100644 --- a/runtime/Makefile +++ b/runtime/Makefile @@ -15,16 +15,12 @@ INCLUDES = -I../include/ DEFINES = $(REDUCER_DEF) $(ABI_DEF) $(ALERT_DEF) OPTIONS = $(OPT) $(DBG) $(ARCH) -Werror -Wall -fpic $(DEFINES) $(INCLUDES) -gdwarf-4 -PERSON_C = $(RTS_LIBDIR)/$(RTS_C_PERSONALITY_LIB) -PERSON_CPP = $(RTS_LIBDIR)/$(RTS_CXX_PERSONALITY_LIB) -PERSON_C_SRC = personality-c -PERSON_CPP_SRC = personality-cpp PEDIGREE_LIB = $(RTS_LIBDIR)/$(RTS_PEDIGREE_LIB) PEDIGREE_LIB_SRC = pedigree_lib .PHONY: all clean build -all: build $(RTS_LIBDIR) $(MAIN).a $(MAIN).so $(PERSON_C).a $(PERSON_C).so $(PERSON_CPP).a $(PERSON_CPP).so $(BITCODE_ABI) +all: build $(RTS_LIBDIR) $(MAIN).a $(MAIN).so $(BITCODE_ABI) $(MAIN).a: $(OBJS) $(AR) rcs $@ $^ @@ -32,22 +28,6 @@ $(MAIN).a: $(OBJS) $(MAIN).so: $(OBJS) $(CXX) -shared -o $@ $^ -$(PERSON_C).a: build/$(PERSON_C_SRC).o - $(AR) rcs $@ $^ - -$(PERSON_C).so: $(RTS_LIBDIR)/libopencilk.so - -$(PERSON_C).so: build/$(PERSON_C_SRC).o - $(CC) -shared -o $@ $^ -L$(RTS_LIBDIR) -lopencilk - -$(PERSON_CPP).a: build/$(PERSON_CPP_SRC).o - $(AR) rcs $@ $^ - -$(PERSON_CPP).so: $(RTS_LIBDIR)/libopencilk.so - -$(PERSON_CPP).so: ./build/$(PERSON_CPP_SRC).o - $(CXX) -shared -o $@ $^ -L$(RTS_LIBDIR) -lopencilk - $(PEDIGREE_LIB).a: build/$(PEDIGREE_LIB_SRC).o $(AR) rcs $@ $^ @@ -73,5 +53,5 @@ $(BITCODE_ABI) : build/cilk2c_inlined.bc cp $< $@ clean: - rm -f $(OBJS) build/$(PERSON_C_SRC).o build/$(PERSON_CPP_SRC).o $(RTS_LIBDIR)/*.a $(RTS_LIBDIR)/*.so $(RTS_LIBDIR)/*.bc *~ + rm -f $(OBJS) $(RTS_LIBDIR)/*.a $(RTS_LIBDIR)/*.so $(RTS_LIBDIR)/*.bc *~ rm -f build/cilk2c_inlined.bc diff --git a/runtime/personality-c.c b/runtime/personality-c.c deleted file mode 100644 index a15179b4..00000000 --- a/runtime/personality-c.c +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include - -typedef _Unwind_Reason_Code (*__personality_routine)( - int version, _Unwind_Action actions, uint64_t exception_class, - struct _Unwind_Exception *exception_object, - struct _Unwind_Context *context); - -_Unwind_Reason_Code __gcc_personality_v0(int version, _Unwind_Action actions, - uint64_t exception_class, - struct _Unwind_Exception *ue_header, - struct _Unwind_Context *context); - -_Unwind_Reason_Code __cilk_personality_internal( - __personality_routine std_lib_personality, int version, - _Unwind_Action actions, uint64_t exception_class, - struct _Unwind_Exception *ue_header, struct _Unwind_Context *context); - -_Unwind_Reason_Code __cilk_personality_c_v0(int version, _Unwind_Action actions, - uint64_t exception_class, - struct _Unwind_Exception *ue_header, - struct _Unwind_Context *context) { - return __cilk_personality_internal(__gcc_personality_v0, version, actions, - exception_class, ue_header, context); -} - -_Unwind_Reason_Code __cilk_personality_v0(int version, _Unwind_Action actions, - uint64_t exception_class, - struct _Unwind_Exception *ue_header, - struct _Unwind_Context *context) { - return __cilk_personality_c_v0(version, actions, exception_class, ue_header, - context); -} diff --git a/runtime/personality-cpp.cpp b/runtime/personality-cpp.cpp deleted file mode 100644 index dfd7b8c3..00000000 --- a/runtime/personality-cpp.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include - -typedef _Unwind_Reason_Code (*__personality_routine)( - int version, _Unwind_Action actions, uint64_t exception_class, - struct _Unwind_Exception *exception_object, - struct _Unwind_Context *context); - -extern "C" { -_Unwind_Reason_Code __gxx_personality_v0(int version, _Unwind_Action actions, - uint64_t exception_class, - struct _Unwind_Exception *ue_header, - struct _Unwind_Context *context); - -_Unwind_Reason_Code __cilk_personality_internal( - __personality_routine std_lib_personality, int version, - _Unwind_Action actions, uint64_t exception_class, - struct _Unwind_Exception *ue_header, struct _Unwind_Context *context); - -_Unwind_Reason_Code __cilk_personality_cpp_v0( - int version, _Unwind_Action actions, uint64_t exception_class, - struct _Unwind_Exception *ue_header, struct _Unwind_Context *context) { - return __cilk_personality_internal(__gxx_personality_v0, version, actions, - exception_class, ue_header, context); -} - -_Unwind_Reason_Code __cilk_personality_v0(int version, _Unwind_Action actions, - uint64_t exception_class, - struct _Unwind_Exception *ue_header, - struct _Unwind_Context *context) { - return __cilk_personality_cpp_v0(version, actions, exception_class, - ue_header, context); -} -} diff --git a/runtime/personality.cpp b/runtime/personality.cpp index 8c80ff37..4cc9a89e 100644 --- a/runtime/personality.cpp +++ b/runtime/personality.cpp @@ -22,6 +22,18 @@ typedef _Unwind_Reason_Code (*__personality_routine)( int version, _Unwind_Action actions, uint64_t exception_class, _Unwind_Exception *exception_object, _Unwind_Context *context); +extern "C" +_Unwind_Reason_Code __gcc_personality_v0(int version, _Unwind_Action actions, + uint64_t exception_class, + struct _Unwind_Exception *ue_header, + struct _Unwind_Context *context); +extern "C" +_Unwind_Reason_Code __gxx_personality_v0(int version, _Unwind_Action actions, + uint64_t exception_class, + struct _Unwind_Exception *ue_header, + struct _Unwind_Context *context); + + static char *get_cfa(_Unwind_Context *context) { /* _Unwind_GetCFA is originally a gcc extension. FreeBSD has its own library without that extension. */ @@ -314,3 +326,30 @@ extern "C" _Unwind_Reason_Code __cilk_personality_internal( return _URC_FATAL_PHASE1_ERROR; } } + +extern "C" { +_Unwind_Reason_Code __cilk_personality_c_v0(int version, _Unwind_Action actions, + uint64_t exception_class, + struct _Unwind_Exception *ue_header, + struct _Unwind_Context *context) { + return __cilk_personality_internal(__gcc_personality_v0, version, actions, + exception_class, ue_header, context); +} + +// Legacy name +_Unwind_Reason_Code __cilk_personality_v0(int version, _Unwind_Action actions, + uint64_t exception_class, + struct _Unwind_Exception *ue_header, + struct _Unwind_Context *context) { + return __cilk_personality_c_v0(version, actions, exception_class, ue_header, + context); +} + +_Unwind_Reason_Code __cilk_personality_cpp_v0( + int version, _Unwind_Action actions, uint64_t exception_class, + struct _Unwind_Exception *ue_header, struct _Unwind_Context *context) { + return __cilk_personality_internal(__gxx_personality_v0, version, actions, + exception_class, ue_header, context); +} + +}