scripts/build/companion_libs/libelf.sh
author "Benoît Thébaudeau" <benoit.thebaudeau@advansee.com>
Fri Jan 27 13:31:16 2012 +0100 (2012-01-27)
changeset 2854 a70abdbfa342
parent 2381 0ca0f85a4b2a
child 2905 286b2937c101
permissions -rw-r--r--
complibs/cloog: fix linking with libm

In Ubuntu 11.04 and 11.10, the default options for ld have changed.
--no-copy-dt-needed-entries and --as-needed are now enabled by default, which
causes errors like:

[EXTRA] Checking CLooG/ppl
[DEBUG] ==> Executing: 'make' '-j3' '-s' 'check'
[ALL ] Making check in .
[ALL ] config.status: creating include/cloog/cloog-config.h
[ALL ] config.status: include/cloog/cloog-config.h is unchanged
[ALL ] libtool: link: i686-build_pc-linux-gnu-gcc -Wall -fomit-frame-pointer
-pipe -o cloog cloog.o -L/<snip>/build/static/lib ./.libs/libcloog.a -lm
/<snip>/build/static/lib/libppl_c.a /<snip>/build/static/lib/libpwl.a
/<snip>/build/static/lib/libppl.a /<snip>/build/static/lib/libgmpxx.a
/<snip>/build/static/lib/libgmp.a -lstdc++
[ALL ] /usr/bin/ld: /<snip>/build/static/lib/libppl.a(MIP_Problem.o):
undefined reference to symbol 'sqrt@@GLIBC_2.0'
[ALL ] /usr/bin/ld: note: 'sqrt@@GLIBC_2.0' is defined in DSO
/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/libm.so so try adding
it to the linker command line
[ALL ] /usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/libm.so:
could not read symbols: Invalid operation
[ALL ] collect2: ld returned 1 exit status
[ERROR] make[2]: *** [cloog] Error 1
[ERROR] make[1]: *** [check-recursive] Error 1

See:
https://wiki.ubuntu.com/NattyNarwhal/ToolchainTransition

This patch fixes these errors by placing '-lm' at the right place on the command
line as libppl requires libm when linking cloog.

Signed-off-by: "Benoît Thébaudeau" <benoit.thebaudeau@advansee.com>
yann@479
     1
# Build script for libelf
yann@479
     2
yann@1811
     3
do_libelf_get() { :; }
yann@1811
     4
do_libelf_extract() { :; }
yann@1811
     5
do_libelf() { :; }
yann@1811
     6
do_libelf_target() { :; }
yann@1811
     7
yann@1811
     8
if [ "${CT_LIBELF}" = "y" -o "${CT_LIBELF_TARGET}" = "y" ]; then
yann@1811
     9
yann@1811
    10
do_libelf_get() {
yann@479
    11
    # The server hosting libelf will return an "HTTP 300 : Multiple Choices"
yann@479
    12
    # error code if we try to download a file that does not exists there.
yann@479
    13
    # So we have to request the file with an explicit extension.
yann@479
    14
    CT_GetFile "libelf-${CT_LIBELF_VERSION}" .tar.gz http://www.mr511.de/software/
yann@479
    15
}
yann@479
    16
yann@1811
    17
do_libelf_extract() {
yann@1126
    18
    CT_Extract "libelf-${CT_LIBELF_VERSION}"
yann@1901
    19
    CT_Patch "libelf" "${CT_LIBELF_VERSION}"
yann@479
    20
}
yann@479
    21
yann@1811
    22
if [ "${CT_LIBELF}" = "y" ]; then
yann@1811
    23
yann@1811
    24
do_libelf() {
yann@1918
    25
    CT_DoStep INFO "Installing libelf"
yann@1918
    26
    mkdir -p "${CT_BUILD_DIR}/build-libelf"
yann@1918
    27
    CT_Pushd "${CT_BUILD_DIR}/build-libelf"
yann@1918
    28
yann@1918
    29
    CT_DoLog EXTRA "Configuring libelf"
yann@1918
    30
yann@2351
    31
    CT_DoExecLog CFG                                        \
kalle@2216
    32
    CC="${CT_HOST}-gcc"                                     \
yann@2242
    33
    CFLAGS="-fPIC"                                          \
yann@1918
    34
    "${CT_SRC_DIR}/libelf-${CT_LIBELF_VERSION}/configure"   \
yann@1918
    35
        --build=${CT_BUILD}                                 \
yann@1918
    36
        --host=${CT_HOST}                                   \
yann@1918
    37
        --target=${CT_TARGET}                               \
yann@1918
    38
        --prefix="${CT_COMPLIBS_DIR}"                       \
yann@1918
    39
        --enable-compat                                     \
yann@1918
    40
        --enable-elf64                                      \
yann@1918
    41
        --enable-extended-format                            \
yann@2381
    42
        --disable-shared                                    \
yann@2381
    43
        --enable-static
yann@1918
    44
yann@1918
    45
    CT_DoLog EXTRA "Building libelf"
yann@1918
    46
    CT_DoExecLog ALL make
yann@1918
    47
yann@1918
    48
    CT_DoLog EXTRA "Installing libelf"
yann@1918
    49
    CT_DoExecLog ALL make install
yann@1918
    50
yann@1918
    51
    CT_Popd
yann@1918
    52
    CT_EndStep
yann@1811
    53
}
yann@1811
    54
yann@1811
    55
fi # CT_LIBELF
yann@1811
    56
yann@1811
    57
if [ "${CT_LIBELF_TARGET}" = "y" ]; then
yann@1811
    58
yann@1811
    59
do_libelf_target() {
yann@1811
    60
    CT_DoStep INFO "Installing libelf for the target"
yann@1917
    61
    mkdir -p "${CT_BUILD_DIR}/build-libelf-for-target"
yann@1917
    62
    CT_Pushd "${CT_BUILD_DIR}/build-libelf-for-target"
yann@479
    63
yann@479
    64
    CT_DoLog EXTRA "Configuring libelf"
yann@2351
    65
    CT_DoExecLog CFG                                        \
yann@479
    66
    CC="${CT_TARGET}-gcc"                                   \
yann@2242
    67
    CFLAGS="-fPIC"                                          \
titus@2624
    68
    RANLIB="${CT_TARGET}-ranlib"                            \
yann@479
    69
    "${CT_SRC_DIR}/libelf-${CT_LIBELF_VERSION}/configure"   \
yann@479
    70
        --build=${CT_BUILD}                                 \
yann@479
    71
        --host=${CT_TARGET}                                 \
yann@479
    72
        --target=${CT_TARGET}                               \
yann@479
    73
        --prefix=/usr                                       \
yann@479
    74
        --enable-compat                                     \
yann@479
    75
        --enable-elf64                                      \
yann@479
    76
        --enable-shared                                     \
yann@479
    77
        --enable-extended-format                            \
yann@663
    78
        --enable-static
yann@479
    79
yann@479
    80
    CT_DoLog EXTRA "Building libelf"
yann@663
    81
    CT_DoExecLog ALL make
yann@479
    82
yann@479
    83
    CT_DoLog EXTRA "Installing libelf"
yann@663
    84
    CT_DoExecLog ALL make instroot="${CT_SYSROOT_DIR}" install
yann@479
    85
yann@479
    86
    CT_Popd
yann@479
    87
    CT_EndStep
yann@479
    88
}
yann@479
    89
yann@1811
    90
fi # CT_LIBELF_TARGET
yann@1811
    91
yann@1811
    92
fi # CT_LIBELF || CT_LIBELF_TARGET