diff options
author | Dan Gohman <dan433584@gmail.com> | 2016-01-07 00:32:04 +0000 |
---|---|---|
committer | Dan Gohman <dan433584@gmail.com> | 2016-01-07 00:32:04 +0000 |
commit | 4e480206b288d82c5cb525e739d39da346c64c55 (patch) | |
tree | a21fe3c75a6c59f902c11588c01a7050ed0df8ca | |
parent | 5ae84fec4c441622cbc6f27280b61996d9b14e16 (diff) | |
download | bcm5719-llvm-4e480206b288d82c5cb525e739d39da346c64c55.tar.gz bcm5719-llvm-4e480206b288d82c5cb525e739d39da346c64c55.zip |
[WebAssembly] Only enable --gc-sections when optimizations are enabled.
Also, revamp the wasm-toolchain.c test and add a test to ensure that
a user-supplied --no-gc-sections comes after --gc-sections.
llvm-svn: 257004
-rw-r--r-- | clang/lib/Driver/Tools.cpp | 3 | ||||
-rw-r--r-- | clang/test/Driver/wasm-toolchain.c | 26 |
2 files changed, 25 insertions, 4 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 598ebc955ee..0236e613a37 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -6537,7 +6537,8 @@ void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA, // Enable garbage collection of unused input sections by default, since code // size is of particular importance. - CmdArgs.push_back("--gc-sections"); + if (areOptimizationsEnabled(Args)) + CmdArgs.push_back("--gc-sections"); AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs); CmdArgs.push_back("-o"); diff --git a/clang/test/Driver/wasm-toolchain.c b/clang/test/Driver/wasm-toolchain.c index 78cb7111455..82c0c5828be 100644 --- a/clang/test/Driver/wasm-toolchain.c +++ b/clang/test/Driver/wasm-toolchain.c @@ -1,3 +1,23 @@ -// 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" "--gc-sections" "[[temp]]" "-o" "a.out" +// A basic clang -cc1 command-line. + +// RUN: %clang %s -### -target wasm32-unknown-unknown 2>&1 | FileCheck -check-prefix=CC1 %s +// CC1: clang{{.*}} "-cc1" "-triple" "wasm32-unknown-unknown" {{.*}} + +// A basic C link command-line. + +// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown %s 2>&1 | FileCheck -check-prefix=LINK %s +// LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]" +// LINK: lld{{.*}}" "-flavor" "ld" "[[temp]]" "-o" "a.out" + +// A basic C link command-line with optimization. + +// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown %s 2>&1 | FileCheck -check-prefix=LINK_OPT %s +// LINK_OPT: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]" +// LINK_OPT: lld{{.*}}" "-flavor" "ld" "--gc-sections" "[[temp]]" "-o" "a.out" + +// Ditto, but ensure that a user --no-gc-sections comes after the +// default --gc-sections. + +// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown -Wl,--no-gc-sections %s 2>&1 | FileCheck -check-prefix=NO_GC_SECTIONS %s +// NO_GC_SECTIONS: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]" +// NO_GC_SECTIONS: lld{{.*}}" "-flavor" "ld" "--gc-sections" "--no-gc-sections" "[[temp]]" "-o" "a.out" |