r233299 - Enable -ffunction-sections and -fdata-sections for CloudABI by default.

Rafael EspĂ­ndola rafael.espindola at gmail.com
Thu Mar 26 19:08:01 PDT 2015


Nice :-)

You might like -fno-unique-section-names for the size issue, but
regard it as alpha as the syntax is not yet fixed.

On 26 March 2015 at 13:50, Ed Schouten <ed at nuxi.nl> wrote:
> Author: ed
> Date: Thu Mar 26 12:50:28 2015
> New Revision: 233299
>
> URL: http://llvm.org/viewvc/llvm-project?rev=233299&view=rev
> Log:
> 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
>
> Modified:
>     cfe/trunk/lib/Driver/Tools.cpp
>     cfe/trunk/test/Driver/cloudabi.c
>     cfe/trunk/test/Driver/cloudabi.cpp
>
> Modified: cfe/trunk/lib/Driver/Tools.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=233299&r1=233298&r2=233299&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Driver/Tools.cpp (original)
> +++ cfe/trunk/lib/Driver/Tools.cpp Thu Mar 26 12:50:28 2015
> @@ -3318,13 +3318,16 @@ void Clang::ConstructJob(Compilation &C,
>      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");
>    }
>
>
> Modified: cfe/trunk/test/Driver/cloudabi.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cloudabi.c?rev=233299&r1=233298&r2=233299&view=diff
> ==============================================================================
> --- cfe/trunk/test/Driver/cloudabi.c (original)
> +++ cfe/trunk/test/Driver/cloudabi.c Thu Mar 26 12:50:28 2015
> @@ -1,3 +1,3 @@
>  // RUN: %clang %s -### -target x86_64-unknown-cloudabi 2>&1 | FileCheck %s
> -// CHECK: "-cc1" "-triple" "x86_64-unknown-cloudabi"
> +// CHECK: "-cc1" "-triple" "x86_64-unknown-cloudabi" {{.*}} "-ffunction-sections" "-fdata-sections"
>  // CHECK: "-Bstatic" "--eh-frame-hdr" "--gc-sections" "-o" "a.out" "crt0.o" "crtbegin.o" "{{.*}}" "{{.*}}" "-lc" "-lcompiler_rt" "crtend.o"
>
> Modified: cfe/trunk/test/Driver/cloudabi.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cloudabi.cpp?rev=233299&r1=233298&r2=233299&view=diff
> ==============================================================================
> --- cfe/trunk/test/Driver/cloudabi.cpp (original)
> +++ cfe/trunk/test/Driver/cloudabi.cpp Thu Mar 26 12:50:28 2015
> @@ -1,3 +1,3 @@
>  // RUN: %clangxx %s -### -target x86_64-unknown-cloudabi 2>&1 | FileCheck %s
> -// CHECK: "-cc1" "-triple" "x86_64-unknown-cloudabi"
> +// CHECK: "-cc1" "-triple" "x86_64-unknown-cloudabi" {{.*}} "-ffunction-sections" "-fdata-sections"
>  // CHECK: "-Bstatic" "--eh-frame-hdr" "--gc-sections" "-o" "a.out" "crt0.o" "crtbegin.o" "{{.*}}" "{{.*}}" "-lc++" "-lc++abi" "-lunwind" "-lc" "-lcompiler_rt" "crtend.o"
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits



More information about the cfe-commits mailing list