Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Fix syscalls in the C SDK failing at runtime when compiled as C++ #17124

Merged
merged 1 commit into from
May 8, 2021

Conversation

machacekch
Copy link
Contributor

Problem

Some syscalls are wrongly declared static in solana_sdk.h, which makes clang++ assume they are local to the compilation unit. It therefore ignores the extern "C" {} block and mangles their names. While that doesn't break C++ compilation, the syscall fails at runtime with something along the lines of ELF error: Unresolved symbol (_ZL26sol_create_program_addressPK13SolSignerSeediPK9SolPubkeyS4_).

Summary of Changes

Cleanly separate syscalls from non-syscalls and ensure the former are no longer declared static.

Some syscalls are wrongly declared "static" in solana_sdk.h, which makes clang++ assume they are local to the compilation unit. It therefore ignores the extern "C" {} block and mangles their names. While that doesn't break C++ compilation, the syscall fails at runtime with something along the lines of "ELF error: Unresolved symbol (_ZL26sol_create_program_addressPK13SolSignerSeediPK9SolPubkeyS4_)".
@mvines mvines added v1.6 automerge Merge this Pull Request automatically once CI passes labels May 8, 2021
Copy link
Contributor

@mvines mvines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mergify mergify bot merged commit 6927d0c into solana-labs:master May 8, 2021
mergify bot pushed a commit that referenced this pull request May 8, 2021
…7124)

Some syscalls are wrongly declared "static" in solana_sdk.h, which makes clang++ assume they are local to the compilation unit. It therefore ignores the extern "C" {} block and mangles their names. While that doesn't break C++ compilation, the syscall fails at runtime with something along the lines of "ELF error: Unresolved symbol (_ZL26sol_create_program_addressPK13SolSignerSeediPK9SolPubkeyS4_)".

(cherry picked from commit 6927d0c)
mergify bot added a commit that referenced this pull request May 8, 2021
…7124) (#17126)

Some syscalls are wrongly declared "static" in solana_sdk.h, which makes clang++ assume they are local to the compilation unit. It therefore ignores the extern "C" {} block and mangles their names. While that doesn't break C++ compilation, the syscall fails at runtime with something along the lines of "ELF error: Unresolved symbol (_ZL26sol_create_program_addressPK13SolSignerSeediPK9SolPubkeyS4_)".

(cherry picked from commit 6927d0c)

Co-authored-by: Christian Machacek <39452430+machacekch@users.noreply.github.com>
@brooksprumo brooksprumo mentioned this pull request Aug 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
automerge Merge this Pull Request automatically once CI passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants