]> granicus.if.org Git - clang/commitdiff
[WebAssembly] Add --gc-sections to the link line.
authorDan Gohman <dan433584@gmail.com>
Wed, 6 Jan 2016 19:43:32 +0000 (19:43 +0000)
committerDan Gohman <dan433584@gmail.com>
Wed, 6 Jan 2016 19:43:32 +0000 (19:43 +0000)
This will eventually be accompanied with a change to enable -ffunction-sections
and -fdata-sections by default, which is currently delayed by some development
process issues.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256967 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Tools.cpp
test/Driver/wasm-toolchain.c

index 84681053dd1a4fb5209738e1a74acbae984df2d8..598ebc955ee0b735798cb452143d76aeecb3a763 100644 (file)
@@ -6534,6 +6534,11 @@ void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA,
   ArgStringList CmdArgs;
   CmdArgs.push_back("-flavor");
   CmdArgs.push_back("ld");
+
+  // Enable garbage collection of unused input sections by default, since code
+  // size is of particular importance.
+  CmdArgs.push_back("--gc-sections");
+
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
index 4d707a0f6c8f157b3672d94477e174f81147b9b8..78cb711145541f676deb3b4b31278689afd7f1e1 100644 (file)
@@ -1,3 +1,3 @@
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown -x assembler %s 2>&1 | FileCheck -check-prefix=AS_LINK %s
 // AS_LINK: clang{{.*}}" "-cc1as" {{.*}} "-o" "[[temp:[^"]*]]"
-// AS_LINK: lld{{.*}}" "-flavor" "ld" "[[temp]]" "-o" "a.out"
+// AS_LINK: lld{{.*}}" "-flavor" "ld" "--gc-sections" "[[temp]]" "-o" "a.out"