]> granicus.if.org Git - clang/commitdiff
[HIP] Remove useless sections in linked files
authorYaxun Liu <Yaxun.Liu@amd.com>
Fri, 9 Nov 2018 18:52:05 +0000 (18:52 +0000)
committerYaxun Liu <Yaxun.Liu@amd.com>
Fri, 9 Nov 2018 18:52:05 +0000 (18:52 +0000)
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

lib/Driver/ToolChains/CommonArgs.cpp

index a2db515310c31e543204d1e7be1a43f7ee966ec9..3803dde8daf8d4a9163362619fb7fe147959aa75 100644 (file)
@@ -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();