cc/gcc: fix linking with static PPL 0.11+
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon Mar 28 01:07:31 2011 +0200 (2011-03-28)
changeset 2368482a006e5b18
parent 2367 d4c9c0071bbb
child 2369 c92281709a49
cc/gcc: fix linking with static PPL 0.11+

PPL 0.11+ installs three libs: lippl, libppl_c and libpwl.
libppl_c has a dependency on libpwl (at least for watchdog stuff).

While gcc correctly links with libppl and libppl_c, it does not
pull libpwl in. In case of shared libs, this is not a problem, as
libppl_c has a NEEDED dependency on libpwl. But for static libs,
that does not work. Although libppl_c.la exists and has a correct
dependency on lipwl, somehow gcc misses it. So we have to force
pulling libpwl when needed.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
config/companion_libs/ppl.in
scripts/build/cc/gcc.sh
     1.1 --- a/config/companion_libs/ppl.in	Sat Mar 26 22:04:22 2011 +0100
     1.2 +++ b/config/companion_libs/ppl.in	Mon Mar 28 01:07:31 2011 +0200
     1.3 @@ -10,16 +10,19 @@
     1.4      bool
     1.5      prompt "0.11.2 (EXPERIMENTAL)"
     1.6      depends on EXPERIMENTAL
     1.7 +    select PPL_0_11
     1.8  
     1.9  config PPL_V_0_11_1
    1.10      bool
    1.11      prompt "0.11.1 (EXPERIMENTAL)"
    1.12      depends on EXPERIMENTAL
    1.13 +    select PPL_0_11
    1.14  
    1.15  config PPL_V_0_11
    1.16      bool
    1.17      prompt "0.11 (EXPERIMENTAL)"
    1.18      depends on EXPERIMENTAL
    1.19 +    select PPL_0_11
    1.20  
    1.21  config PPL_V_0_10_2
    1.22      bool
    1.23 @@ -35,3 +38,13 @@
    1.24      default "0.11.1" if PPL_V_0_11_1
    1.25      default "0.11" if PPL_V_0_11
    1.26      default "0.10.2" if PPL_V_0_10_2
    1.27 +
    1.28 +# For PPL 0.11, we need to pull libpwl if configured static
    1.29 +config PPL_0_11
    1.30 +    bool
    1.31 +    default n
    1.32 +    select PPL_NEEDS_LIBPWL if ! COMPLIBS_SHARED
    1.33 +
    1.34 +config PPL_NEEDS_LIBPWL
    1.35 +    bool
    1.36 +    default n
     2.1 --- a/scripts/build/cc/gcc.sh	Sat Mar 26 22:04:22 2011 +0100
     2.2 +++ b/scripts/build/cc/gcc.sh	Mon Mar 28 01:07:31 2011 +0200
     2.3 @@ -117,6 +117,7 @@
     2.4      local core_prefix_dir
     2.5      local lang_opt
     2.6      local tmp
     2.7 +    local -a host_libstdcxx_flags
     2.8      local -a extra_config
     2.9      local -a core_LDFLAGS
    2.10      local -a core_targets
    2.11 @@ -186,7 +187,9 @@
    2.12      # with the same block in do_cc, below.
    2.13      if [ "${build_staticlinked}" = "yes" ]; then
    2.14          core_LDFLAGS+=("-static")
    2.15 -        extra_config+=("--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++ -lm")
    2.16 +        host_libstdcxx_flags+=("-static-libgcc")
    2.17 +        host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++")
    2.18 +        host_libstdcxx_flags+=("-lm")
    2.19          # Companion libraries are build static (eg !shared), so
    2.20          # the libstdc++ is not pulled automatically, although it
    2.21          # is needed. Shoe-horn it in our LDFLAGS
    2.22 @@ -199,7 +202,9 @@
    2.23              # build script
    2.24              # FIXME: if the host gcc is gcc-4.5 then presumably we could use -static-libstdc++,
    2.25              # see http://gcc.gnu.org/ml/gcc-patches/2009-06/msg01635.html
    2.26 -            extra_config+=("--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm")
    2.27 +            host_libstdcxx_flags+=("-static-libgcc")
    2.28 +            host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++,-Bdynamic")
    2.29 +            host_libstdcxx_flags+=("-lm")
    2.30          elif [ "${CT_COMPLIBS_SHARED}" != "y" ]; then
    2.31              # When companion libraries are build static (eg !shared),
    2.32              # the libstdc++ is not pulled automatically, although it
    2.33 @@ -219,6 +224,11 @@
    2.34      fi
    2.35      if [ "${CT_CC_GCC_USE_GRAPHITE}" = "y" ]; then
    2.36          extra_config+=("--with-ppl=${CT_COMPLIBS_DIR}")
    2.37 +        # With PPL 0.11+, also pull libpwl if needed
    2.38 +        if [ "${CT_PPL_NEEDS_LIBPWL}" = "y" ]; then
    2.39 +            host_libstdcxx_flags+=("-L${CT_COMPLIBS_DIR}/lib")
    2.40 +            host_libstdcxx_flags+=("-lpwl")
    2.41 +        fi
    2.42          extra_config+=("--with-cloog=${CT_COMPLIBS_DIR}")
    2.43      elif [ "${CT_CC_GCC_HAS_GRAPHITE}" = "y" ]; then
    2.44          extra_config+=("--with-ppl=no")
    2.45 @@ -232,6 +242,10 @@
    2.46          extra_config+=("--disable-lto")
    2.47      fi
    2.48  
    2.49 +    if [ ${#host_libstdcxx_flags[@]} -ne 0 ]; then
    2.50 +        extra_config+=("--with-host-libstdcxx=${host_libstdcxx_flags[*]}")
    2.51 +    fi
    2.52 +
    2.53      if [ "${CT_CC_GCC_ENABLE_TARGET_OPTSPACE}" = "y" ]; then
    2.54          extra_config+=("--enable-target-optspace")
    2.55      fi
    2.56 @@ -349,6 +363,7 @@
    2.57  #------------------------------------------------------------------------------
    2.58  # Build final gcc
    2.59  do_cc() {
    2.60 +    local -a host_libstdcxx_flags
    2.61      local -a extra_config
    2.62      local -a final_LDFLAGS
    2.63      local tmp
    2.64 @@ -423,7 +438,9 @@
    2.65      # with the same block in do_cc_core, above.
    2.66      if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
    2.67          final_LDFLAGS+=("-static")
    2.68 -        extra_config+=("--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++ -lm")
    2.69 +        host_libstdcxx_flags+=("-static-libgcc")
    2.70 +        host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++")
    2.71 +        host_libstdcxx_flags+=("-lm")
    2.72          # Companion libraries are build static (eg !shared), so
    2.73          # the libstdc++ is not pulled automatically, although it
    2.74          # is needed. Shoe-horn it in our LDFLAGS
    2.75 @@ -436,7 +453,9 @@
    2.76              # build script
    2.77              # FIXME: if the host gcc is gcc-4.5 then presumably we could use -static-libstdc++,
    2.78              # see http://gcc.gnu.org/ml/gcc-patches/2009-06/msg01635.html
    2.79 -            extra_config+=("--with-host-libstdcxx=-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm")
    2.80 +            host_libstdcxx_flags+=("-static-libgcc")
    2.81 +            host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++,-Bdynamic")
    2.82 +            host_libstdcxx_flags+=("-lm")
    2.83          elif [ "${CT_COMPLIBS_SHARED}" != "y" ]; then
    2.84              # When companion libraries are build static (eg !shared),
    2.85              # the libstdc++ is not pulled automatically, although it
    2.86 @@ -456,6 +475,11 @@
    2.87      fi
    2.88      if [ "${CT_CC_GCC_USE_GRAPHITE}" = "y" ]; then
    2.89          extra_config+=("--with-ppl=${CT_COMPLIBS_DIR}")
    2.90 +        # With PPL 0.11+, also pull libpwl if needed
    2.91 +        if [ "${CT_PPL_NEEDS_LIBPWL}" = "y" ]; then
    2.92 +            host_libstdcxx_flags+=("-L${CT_COMPLIBS_DIR}/lib")
    2.93 +            host_libstdcxx_flags+=("-lpwl")
    2.94 +        fi
    2.95          extra_config+=("--with-cloog=${CT_COMPLIBS_DIR}")
    2.96      elif [ "${CT_CC_GCC_HAS_GRAPHITE}" = "y" ]; then
    2.97          extra_config+=("--with-ppl=no")
    2.98 @@ -467,6 +491,10 @@
    2.99          extra_config+=("--with-libelf=no")
   2.100      fi
   2.101  
   2.102 +    if [ ${#host_libstdcxx_flags[@]} -ne 0 ]; then
   2.103 +        extra_config+=("--with-host-libstdcxx=${host_libstdcxx_flags[*]}")
   2.104 +    fi
   2.105 +
   2.106      if [ "${CT_THREADS}" = "none" ]; then
   2.107          extra_config+=("--disable-threads")
   2.108          if [ "${CT_CC_GCC_4_2_or_later}" = y ]; then