aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Driver/Tools.cpp
diff options
context:
space:
mode:
authorEd Schouten <ed@nuxi.nl>2015-03-26 17:50:28 +0000
committerEd Schouten <ed@nuxi.nl>2015-03-26 17:50:28 +0000
commit6e57615ac80c92c60a9cd05f275c5f5629a2dfd7 (patch)
tree64d901f1580e1ed862c0ef6061d7a5220c97b06a /clang/lib/Driver/Tools.cpp
parentca05ae2bfffa5662866514ccda47d25d7a09ad60 (diff)
downloadllvm-6e57615ac80c92c60a9cd05f275c5f5629a2dfd7.zip
llvm-6e57615ac80c92c60a9cd05f275c5f5629a2dfd7.tar.gz
llvm-6e57615ac80c92c60a9cd05f275c5f5629a2dfd7.tar.bz2
Enable -ffunction-sections and -fdata-sections for CloudABI by default.
Unlike most of the other platforms supported by Clang, CloudABI only supports static linkage, for the reason that global filesystem access is prohibited. Functions provided by dlfcn.h are not present. As we know that applications will not try to do any symbol lookups at run-time, we can garbage collect unused code quite aggressively. Because of this, it makes sense to enable -ffunction-sections and -fdata-sections by default. Object files will be a bit larger than usual, but the resulting binary will not be affected, as the sections are merged again. However, when --gc-sections is used, the linker is able to remove unused code far more more aggressively. It also has the advantage that transitive library dependencies only need to be provided to the linker in case that functionality is actually used. Differential Revision: http://reviews.llvm.org/D8635 Reviewed by: echristo llvm-svn: 233299
Diffstat (limited to 'clang/lib/Driver/Tools.cpp')
-rw-r--r--clang/lib/Driver/Tools.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index 874484d..ed1bd3e 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -3318,13 +3318,16 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-generate-type-units");
}
+ // CloudABI uses -ffunction-sections and -fdata-sections by default.
+ bool UseSeparateSections = Triple.getOS() == llvm::Triple::CloudABI;
+
if (Args.hasFlag(options::OPT_ffunction_sections,
- options::OPT_fno_function_sections, false)) {
+ options::OPT_fno_function_sections, UseSeparateSections)) {
CmdArgs.push_back("-ffunction-sections");
}
if (Args.hasFlag(options::OPT_fdata_sections,
- options::OPT_fno_data_sections, false)) {
+ options::OPT_fno_data_sections, UseSeparateSections)) {
CmdArgs.push_back("-fdata-sections");
}