Skip to content

[libc] Remove the optional arguments for NVPTX constructors #69536

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

Merged
merged 1 commit into from
Nov 20, 2023
Merged
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
8 changes: 5 additions & 3 deletions libc/startup/gpu/nvptx/start.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ uintptr_t *__fini_array_start [[gnu::visibility("protected")]];
uintptr_t *__fini_array_end [[gnu::visibility("protected")]];
}

using InitCallback = void(int, char **, char **);
// Nvidia requires that the signature of the function pointers match. This means
// we cannot support the extended constructor arguments.
using InitCallback = void(void);
using FiniCallback = void(void);

static void call_init_array_callbacks(int argc, char **argv, char **env) {
static void call_init_array_callbacks(int, char **, char **) {
size_t init_array_size = __init_array_end - __init_array_start;
for (size_t i = 0; i < init_array_size; ++i)
reinterpret_cast<InitCallback *>(__init_array_start[i])(argc, argv, env);
reinterpret_cast<InitCallback *>(__init_array_start[i])();
}

static void call_fini_array_callbacks() {
Expand Down
4 changes: 2 additions & 2 deletions libc/test/integration/startup/gpu/init_fini_array_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ A global(GLOBAL_INDEX, INITVAL_INITIALIZER);
int initval = 0;
int before = 0;

__attribute__((constructor(101))) void run_before(int, char **, char **) {
__attribute__((constructor(101))) void run_before() {
before = BEFORE_INITIALIZER;
}

__attribute__((constructor(65535))) void run_after(int, char **, char **) {
__attribute__((constructor(65535))) void run_after() {
ASSERT_EQ(before, BEFORE_INITIALIZER);
}

Expand Down