Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#14895: enable gp-rel in kernels #15043

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tt_metal/hw/firmware/src/erisck.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

CBInterface cb_interface[NUM_CIRCULAR_BUFFERS];

void kernel_launch(uint32_t) {
extern "C" [[gnu::section(".start")]] void _start(uint32_t) {
DeviceZoneScopedMainChildN("ERISC-KERNEL");
rtos_context_switch_ptr = (void (*)())RtosTable[0];

Expand Down
2 changes: 2 additions & 0 deletions tt_metal/hw/toolchain/sections.ld
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ SECTIONS
__kernel_init_local_l1_base = .;
#endif

#if defined(TYPE_FIRMWARE)
PROVIDE(__global_pointer$ = ORIGIN(REGION_DATA) + 0x7f0);
#endif
.data DATA_START : ALIGN(4)
{
. = .; /* Force section emission. */
Expand Down
2 changes: 2 additions & 0 deletions tt_metal/hw/toolchain/tmu-crt0k.S
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@

_start:
// kernel_launch is responsible for the rest of crt -- clear bss, copy data image, run global constructors
// Enable GPREL optimizations
.reloc _start, R_RISCV_NONE, __global_pointer$
tail _Z13kernel_launchm
.size _start, .-_start
6 changes: 4 additions & 2 deletions tt_metal/jit_build/build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ void JitBuildState::finish_init() {
this->link_objs_ += build_dir + "ncrisc-halt.o ";
}
} else {
this->link_objs_ += build_dir + "tmu-crt0k.o ";
if (this->target_name_ != "erisc") {
this->link_objs_ += build_dir + "tmu-crt0k.o ";
}
}
if (this->target_name_ == "brisc" or this->target_name_ == "idle_erisc") {
this->link_objs_ += build_dir + "noc.o ";
Expand Down Expand Up @@ -600,7 +602,7 @@ void JitBuildState::weaken(const string& log_file, const string& out_dir) const

ll_api::ElfFile elf;
elf.ReadImage(pathname_in);
static std::string_view const strong_names[] = {"__fw_export_*"};
static std::string_view const strong_names[] = {"__fw_export_*", "__global_pointer$"};
elf.WeakenDataSymbols(strong_names);
elf.WriteImage(pathname_out);
}
Expand Down
Loading