Skip to content

Commit afd6c8e

Browse files
committed
Remove obsolete bss-related code/build features
GC for unix/windows builds doesn't make use of the bss section anymore, so we do not need the (sometimes complicated) build features and code related to it
1 parent 181bfb6 commit afd6c8e

File tree

7 files changed

+7
-137
lines changed

7 files changed

+7
-137
lines changed

py/gc.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -695,11 +695,9 @@ void gc_dump_alloc_table(void) {
695695
case AT_FREE: c = '.'; break;
696696
/* this prints out if the object is reachable from BSS or STACK (for unix only)
697697
case AT_HEAD: {
698-
extern char __bss_start, _end;
699-
extern char *stack_top;
700698
c = 'h';
701-
void **ptrs = (void**)&__bss_start;
702-
mp_uint_t len = ((mp_uint_t)&_end - (mp_uint_t)&__bss_start) / sizeof(mp_uint_t);
699+
void **ptrs = (void**)(void*)&mp_state_ctx;
700+
mp_uint_t len = offsetof(mp_state_ctx_t, vm.stack_top) / sizeof(mp_uint_t);
703701
for (mp_uint_t i = 0; i < len; i++) {
704702
mp_uint_t ptr = (mp_uint_t)ptrs[i];
705703
if (VERIFY_PTR(ptr) && BLOCK_FROM_PTR(ptr) == bl) {
@@ -709,7 +707,7 @@ void gc_dump_alloc_table(void) {
709707
}
710708
if (c == 'h') {
711709
ptrs = (void**)&c;
712-
len = ((mp_uint_t)stack_top - (mp_uint_t)&c) / sizeof(mp_uint_t);
710+
len = ((mp_uint_t)MP_STATE_VM(stack_top) - (mp_uint_t)&c) / sizeof(mp_uint_t);
713711
for (mp_uint_t i = 0; i < len; i++) {
714712
mp_uint_t ptr = (mp_uint_t)ptrs[i];
715713
if (VERIFY_PTR(ptr) && BLOCK_FROM_PTR(ptr) == bl) {

unix/Makefile

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ endif
3535
# if necessary override the value of 'CC' set in py/mkenv.mk
3636
ifeq ($(UNAME_S),Darwin)
3737
CC = clang
38-
# Use clang syntax for map file and set osx specific flags
39-
LDFLAGS_ARCH = -Wl,-order_file,$(BUILD)/order.def -Wl,-map,$@.map
38+
# Use clang syntax for map file
39+
LDFLAGS_ARCH = -Wl,-map,$@.map
4040
else
4141
# Use gcc syntax for map file
4242
LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref
@@ -92,17 +92,6 @@ SRC_C = \
9292
alloc.c \
9393
$(SRC_MOD)
9494

95-
ifeq ($(UNAME_S),Darwin)
96-
# Must be the last file in list of sources
97-
SRC_C += seg_helpers.c
98-
99-
# making seg_helpers.c rely on order.def will force order.def to be created
100-
seg_helpers.c: $(BUILD)/order.def
101-
102-
# create order.def in build directory
103-
$(BUILD)/order.def:
104-
$(Q)echo "seg_helpers.o: ___bss_start" > $@
105-
endif
10695

10796
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
10897

unix/seg_helpers.c

Lines changed: 0 additions & 38 deletions
This file was deleted.

windows/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ SRC_C = \
3737
realpath.c \
3838
init.c \
3939
sleep.c \
40-
bss.c \
4140

4241
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
4342

windows/bss.c

Lines changed: 0 additions & 71 deletions
This file was deleted.

windows/init.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,9 @@
2828
#include <stdio.h>
2929
#include <windows.h>
3030

31-
extern void getbss();
32-
3331
HANDLE hSleepEvent = NULL;
3432

3533
void init() {
36-
getbss();
3734
hSleepEvent = CreateEvent(NULL, TRUE, FALSE, FALSE);
3835
#ifdef __MINGW32__
3936
putenv("PRINTF_EXPONENT_DIGITS=2");

windows/mpconfigport.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ void msec_sleep(double msec);
166166
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
167167

168168

169-
// Put static/global variables in sections with a known name we can lookup for the GC
169+
// Put static/global variables in sections with a known name
170+
// This used to be required for GC, not the case anymore but keep it as it makes the map file easier to inspect
170171
// For this to work this header must be included by all sources, which is the case normally
171172
#define MICROPY_PORT_DATASECTION "upydata"
172173
#define MICROPY_PORT_BSSSECTION "upybss"
@@ -183,8 +184,3 @@ void msec_sleep(double msec);
183184

184185
int snprintf(char *dest, size_t count, const char *format, ...);
185186
#endif
186-
187-
// MingW specifics
188-
#ifdef __MINGW32__
189-
#define MICROPY_PORT_BSSSECTION ".bss"
190-
#endif

0 commit comments

Comments
 (0)