diff --git a/compiler_tests.py b/compiler_tests.py index 76521cc8..fbfc09b5 100644 --- a/compiler_tests.py +++ b/compiler_tests.py @@ -24,6 +24,7 @@ def compile_to_binary(source: str, memory: int, debug: bool) -> str: with open(os.path.join(dirname, "cli.c"), "r") as f: c_file.write(f.read()) with tempfile.NamedTemporaryFile(mode="w", suffix=".out", delete=False) as out_file: + print(" ".join([*cc, *cflags, "-o", out_file.name, c_file.name])) subprocess.run([*cc, *cflags, "-o", out_file.name, c_file.name], check=True) return out_file.name diff --git a/runtime.c b/runtime.c index fc36f778..29af2a16 100644 --- a/runtime.c +++ b/runtime.c @@ -206,8 +206,16 @@ struct object* heap_tag(uintptr_t addr) { #undef __attribute__ #endif -extern char __start_const_heap[]; -extern char __stop_const_heap[]; +extern char __start_const_heap[] +#ifdef __APPLE__ +__asm("section$start$__DATA$const_heap") +#endif +; +extern char __stop_const_heap[] +#ifdef __APPLE__ +__asm("section$end$__DATA$const_heap") +#endif +; bool in_const_heap(struct gc_obj* obj) { return (uword)obj >= (uword)__start_const_heap && @@ -861,7 +869,11 @@ struct object* println(struct object* obj) { // Put something in the const heap so that __start_const_heap and // __stop_const_heap are defined by the linker. +#ifdef __APPLE__ +#define CONST_HEAP const __attribute__((section("__DATA,const_heap"))) +#else #define CONST_HEAP const __attribute__((section("const_heap"))) +#endif CONST_HEAP __attribute__((used)) struct heap_string private_unused_const_heap = { .HEAD.tag = TAG_STRING, .size = 11, .data = "hello world"};