From: Yaxun Liu Date: Fri, 9 Nov 2018 18:52:05 +0000 (+0000) Subject: [HIP] Remove useless sections in linked files X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1b6c047b6c36b3799dafc748f589afc735058089;p=clang [HIP] Remove useless sections in linked files clang-offload-bundler creates __CLANG_OFFLOAD_BUNDLE__* sections in the bundles, which get into the linked files. These sections are useless after linking. They waste disk space and cause confusion for clang when directly linked with other object files, therefore should be removed. Differential Revision: https://reviews.llvm.org/D54275 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@346536 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains/CommonArgs.cpp b/lib/Driver/ToolChains/CommonArgs.cpp index a2db515310..3803dde8da 100644 --- a/lib/Driver/ToolChains/CommonArgs.cpp +++ b/lib/Driver/ToolChains/CommonArgs.cpp @@ -1436,6 +1436,10 @@ void tools::AddHIPLinkerScript(const ToolChain &TC, Compilation &C, LksStream << " PROVIDE_HIDDEN(__hip_fatbin = .);\n"; LksStream << " " << BundleFileName << "\n"; LksStream << " }\n"; + LksStream << " /DISCARD/ :\n"; + LksStream << " {\n"; + LksStream << " * ( __CLANG_OFFLOAD_BUNDLE__* )\n"; + LksStream << " }\n"; LksStream << "}\n"; LksStream << "INSERT BEFORE .data\n"; LksStream.flush();