[libc-commits] [PATCH] D149527: [libc] Support global constructors and destructors on NVPTX

Joseph Huber via Phabricator via libc-commits libc-commits at lists.llvm.org
Sat Apr 29 12:38:13 PDT 2023


jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992, tra, sivachandra, lntue, michaelrj.
Herald added subscribers: libc-commits, mattd, gchakrabarti, asavonic, ecnelises, tschuett, mgrang.
Herald added projects: libc-project, All.
jhuber6 requested review of this revision.

This patch adds the necessary hacks to support global constructors and
destructors. This is an incredibly hacky process caused by the primary
fact that Nvidia does not provide any binary tools and very little
linker support. We first had to emit references to these functions and
their priority in D149451 <https://reviews.llvm.org/D149451>. Then we dig them out of the module once it's
loaded to manually create the list that the linker should have made for
us. This patch also contains a few Nvidia specific hacks, but it passes
the test, albeit with a stack size warning from `ptxas` for the
callback. But this should be fine given the resource usage of a common
test.

This also adds a dependency on LLVM to the NVPTX loader, which hopefully doesn't
cause problems with our CUDA buildbot.

Depends on D149451 <https://reviews.llvm.org/D149451>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149527

Files:
  libc/startup/gpu/nvptx/CMakeLists.txt
  libc/startup/gpu/nvptx/start.cpp
  libc/test/IntegrationTest/test.cpp
  libc/test/integration/startup/gpu/CMakeLists.txt
  libc/test/integration/startup/gpu/init_fini_array_test.cpp
  libc/utils/gpu/loader/CMakeLists.txt
  libc/utils/gpu/loader/nvptx/CMakeLists.txt
  libc/utils/gpu/loader/nvptx/Loader.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149527.518227.patch
Type: text/x-patch
Size: 14132 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230429/f50b926a/attachment.bin>


More information about the libc-commits mailing list