Skip to content

Commit a40fd0b

Browse files
committed
Enable gcc-14 build rv_histogram on macOS/arm64
Error: Undefined symbols for architecture arm64: "_ebreak_handler", referenced from: lC0 in riscv.o "_ecall_handler", referenced from: lC0 in riscv.o "_log_impl", referenced from: _rv_create in riscv.o _rv_create in riscv.o _rv_create in riscv.o _rv_profile in riscv.o _rv_profile in riscv.o _rv_run in riscv.o "_log_level_string", referenced from: _rv_create in riscv.o "_log_set_level", referenced from: _rv_create in riscv.o "_log_set_stdout_stream", referenced from: _rv_remap_stdstream in riscv.o "_memcpy_handler", referenced from: lC0 in riscv.o "_memory_delete", referenced from: _rv_delete in riscv.o _rv_create in riscv.o "_memory_ifetch", referenced from: _on_mem_ifetch in riscv.o "_memory_new", referenced from: _rv_create in riscv.o "_memory_read_b", referenced from: _on_mem_read_b in riscv.o "_memory_read_s", referenced from: _on_mem_read_s in riscv.o "_memory_read_w", referenced from: _on_mem_read_w in riscv.o "_memory_write_b", referenced from: _on_mem_write_b in riscv.o "_memory_write_s", referenced from: _on_mem_write_s in riscv.o "_memory_write_w", referenced from: _on_mem_write_w in riscv.o "_memset_handler", referenced from: lC0 in riscv.o "_rv", referenced from: _rv_async_block_clear in riscv.o "_rv_step", referenced from: _rv_run in riscv.o _rv_run in riscv.o "_trap_handler", referenced from: lC0 in riscv.o ld: symbol(s) not found for architecture arm64 collect2: error: ld returned 1 exit status make: *** [build/rv_histogram] Error 1 Add emulate.o, syscall.o, syscall_sdl.o, io.o, and log.o objects and conditional build rv_async_block_clear() fixes the error and passes the build.
1 parent c78b27e commit a40fd0b

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

mk/tools.mk

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
HIST_BIN := $(OUT)/rv_histogram
22

3-
# FIXME: riscv.o and map.o are dependencies of 'elf.o', not 'rv_histogram'.
3+
# On macOS, gcc-14 requires linking symbols from emulate.o, syscall.o, syscall_sdl.o, io.o, and log.o.
4+
# However, these symbols are not actually used in rv_histogram, they are only needed to pass the build.
5+
#
6+
# riscv.o and map.o are dependencies of 'elf.o', not 'rv_histogram'. But, they are also needed to pass
7+
# the build.
48
HIST_OBJS := \
59
riscv.o \
610
utils.o \
@@ -9,6 +13,11 @@ HIST_OBJS := \
913
decode.o \
1014
mpool.o \
1115
utils.o \
16+
emulate.o \
17+
syscall.o \
18+
syscall_sdl.o \
19+
io.o \
20+
log.o \
1221
rv_histogram.o
1322

1423
HIST_OBJS := $(addprefix $(OUT)/, $(HIST_OBJS))

src/riscv.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ static void capture_keyboard_input()
357357

358358
#endif
359359

360+
#if RV32_HAS(SYSTEM) && !RV32_HAS(ELF_LOADER)
360361
/*
361362
*
362363
* atexit() registers void (*)(void) callbacks, so no parameters can be passed.
@@ -375,6 +376,7 @@ static void rv_async_block_clear()
375376
return;
376377
#endif /* !RV32_HAS(JIT) */
377378
}
379+
#endif
378380

379381
riscv_t *rv_create(riscv_user_t rv_attr)
380382
{
@@ -383,8 +385,10 @@ riscv_t *rv_create(riscv_user_t rv_attr)
383385
riscv_t *rv = calloc(1, sizeof(riscv_t));
384386
assert(rv);
385387

388+
#if RV32_HAS(SYSTEM) && !RV32_HAS(ELF_LOADER)
386389
/* register cleaning callback for CTRL+a+x exit */
387390
atexit(rv_async_block_clear);
391+
#endif
388392

389393
/* copy over the attr */
390394
rv->data = rv_attr;

0 commit comments

Comments
 (0)