mirror of
https://github.com/johndoe6345789/typthon.git
synced 2026-04-24 13:45:05 +00:00
Fix and enable faulthandler module compilation
- Fixed non-constant initializer error by replacing Py_ARRAY_LENGTH with sizeof - Enabled faulthandler.c in CMakeLists.txt - Removed faulthandler stubs from frozen_stubs.c - Updated STUBS.md to reflect faulthandler is now functional Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
@@ -102,7 +102,7 @@ set(OTHER_MODULE_SOURCES
|
||||
Modules/symtablemodule.c
|
||||
Modules/xxsubtype.c
|
||||
Modules/atexitmodule.c
|
||||
# Modules/faulthandler.c # Has compilation issues with constant initialization
|
||||
Modules/faulthandler.c
|
||||
Modules/_datetimemodule.c
|
||||
Modules/_tracemalloc.c
|
||||
)
|
||||
|
||||
@@ -71,8 +71,10 @@ static fault_handler_t faulthandler_handlers[] = {
|
||||
handler fails in faulthandler_fatal_error() */
|
||||
{SIGSEGV, 0, "Segmentation fault", }
|
||||
};
|
||||
/* Calculate array length using sizeof instead of Py_ARRAY_LENGTH to avoid
|
||||
non-constant initializer error */
|
||||
static const size_t faulthandler_nsignals = \
|
||||
Py_ARRAY_LENGTH(faulthandler_handlers);
|
||||
sizeof(faulthandler_handlers) / sizeof(faulthandler_handlers[0]);
|
||||
|
||||
#ifdef FAULTHANDLER_USE_ALT_STACK
|
||||
# define stack _PyRuntime.faulthandler.stack
|
||||
|
||||
@@ -66,19 +66,6 @@ _PyConfig_InitPathConfig(PyConfig *config, int compute_path_config)
|
||||
return PyStatus_Ok();
|
||||
}
|
||||
|
||||
/* Faulthandler stubs - module excluded from build */
|
||||
int
|
||||
_PyFaulthandler_Init(int enable)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
_PyFaulthandler_Fini(void)
|
||||
{
|
||||
/* No-op */
|
||||
}
|
||||
|
||||
/* plock stub - not available on all systems */
|
||||
#ifndef HAVE_PLOCK
|
||||
int plock(int op)
|
||||
|
||||
23
STUBS.md
23
STUBS.md
@@ -63,13 +63,14 @@ All stubs are implemented in: `Python/frozen_stubs.c`
|
||||
|
||||
**Purpose**: Signal handling and crash reporting module.
|
||||
|
||||
**Stubs Created**:
|
||||
- `_PyFaulthandler_Init()` - Initialize fault handler
|
||||
- `_PyFaulthandler_Fini()` - Finalize fault handler
|
||||
**Status**: ✅ **RESOLVED** - Faulthandler module is now fully functional and included in the build.
|
||||
|
||||
**Implementation**: No-op functions that return success. Fault handler module excluded from build due to compilation issues.
|
||||
**Resolution**: Fixed the constant initialization error by replacing `Py_ARRAY_LENGTH()` macro with direct `sizeof` calculation for the `faulthandler_nsignals` variable. The macro's type-checking feature using `__builtin_types_compatible_p` is not a constant expression, so using simple `sizeof(array) / sizeof(array[0])` resolves the compilation issue.
|
||||
|
||||
**Note**: The faulthandler module was excluded from compilation (`Modules/faulthandler.c`) due to constant initialization errors with `Py_ARRAY_LENGTH` macro.
|
||||
**Changes Made**:
|
||||
- Modified `Modules/faulthandler.c` to use `sizeof` instead of `Py_ARRAY_LENGTH` for array length calculation
|
||||
- Enabled faulthandler module in `CMakeLists.txt`
|
||||
- Removed stub implementations from `Python/frozen_stubs.c`
|
||||
|
||||
### 7. POSIX Functions
|
||||
|
||||
@@ -97,16 +98,18 @@ This prevents the code from attempting to call the non-existent `plock()` functi
|
||||
|
||||
## Module Exclusions
|
||||
|
||||
The following module was excluded from the build:
|
||||
~~The following module was excluded from the build:~~
|
||||
|
||||
- **faulthandler** (`Modules/faulthandler.c`) - Excluded due to compilation errors with non-constant array initialization
|
||||
~~- **faulthandler** (`Modules/faulthandler.c`) - Excluded due to compilation errors with non-constant array initialization~~
|
||||
|
||||
**Update**: No modules are currently excluded. The faulthandler module has been fixed and is now included in the build.
|
||||
|
||||
## Impact on Functionality
|
||||
|
||||
These stubs mean the following features are not available in this build:
|
||||
|
||||
1. **No frozen modules**: Cannot embed Python code as frozen C arrays
|
||||
2. **No fault handler**: No signal handling for crashes/segfaults
|
||||
2. ~~**No fault handler**: No signal handling for crashes/segfaults~~ **✅ RESOLVED** - Fault handler is now available
|
||||
3. **No plock**: No Solaris-style process memory locking
|
||||
4. **Minimal build info**: Git metadata is stubbed with placeholder values
|
||||
5. **No custom built-in modules**: Only modules explicitly linked are available
|
||||
@@ -116,7 +119,7 @@ These stubs mean the following features are not available in this build:
|
||||
To get a fully-functional Python interpreter, the following would be needed:
|
||||
|
||||
1. Generate actual frozen modules using `Tools/build/freeze_modules.py`
|
||||
2. Re-enable and fix the faulthandler module compilation
|
||||
2. ~~Re-enable and fix the faulthandler module compilation~~ **✅ COMPLETED**
|
||||
3. Implement proper path configuration in `_PyConfig_InitPathConfig()`
|
||||
4. Generate real build information with git metadata
|
||||
5. Add more built-in modules to the `_PyImport_Inittab` table
|
||||
@@ -131,7 +134,7 @@ The interpreter successfully:
|
||||
|
||||
## Build Statistics
|
||||
|
||||
- **Total source files compiled**: 177
|
||||
- **Total source files compiled**: 178 (increased from 177 with faulthandler enabled)
|
||||
- **Core library size**: libpython_core.a
|
||||
- **Executable**: typthon
|
||||
- **Build tool**: Ninja (recommended) or Unix Makefiles
|
||||
|
||||
Reference in New Issue
Block a user