-
Notifications
You must be signed in to change notification settings - Fork 8
/
build-binutils-cross.sh
executable file
·59 lines (55 loc) · 1.9 KB
/
build-binutils-cross.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash -e
#
# GNU ar provided by binutils is different from BSD ar (/usr/bin/ar) present in
# Mac OS X. From the output of `/usr/bin/ar -vt lib/libncursesw.a' where
# `libncursesw.a' was generated with GNU ar, it seems that clang can only work
# with those made by /usr/bin/ar
#
# - http://stackoverflow.com/questions/22107616/static-library-built-for-archive-which-is-not-the-architecture-being-linked-x86
#
# To debug GNU linker from GCC, try adding option `-v -Wl,--trace`
#
. "$PWD/utils-toolchain.sh"
toolchain_init_pkg binutils
PKG_NAME=binutils-cross
PKG_PLATFORM=linux
PKG_DEPENDS='binutils-pass0'
. "$PWD/env.sh"
toolchain_init_vars_build_cross "$PKG_NAME"
# --disable-initfini-array is a configure option of ld. It was default off for
# cross build before 2.27 and was turned into a default on option since
# 2015-12-02 [1]. It has to be disabled for at least glibc 2.24 because bad
# values may creep into .init_array causing segfault at program startup time.
#
# See binutils/ld/scripttempl/elf.sc and glibc/elf/so{init,fini}.c for details.
# glibc uses ldscript emitted by command ld --verbose and stores it as
# shlib.lds at build time
#
# [1] Make --enable-initfini-array the default,
# https://sourceware.org/ml/binutils-cvs/2015-12/msg00016.html
CONFIGURE_ARGS+=(
--with-sysroot="$TOOLCHAIN_DIR"
--build="$TRI_BUILD"
--host="$TRI_HOST"
--target="$TRI_TARGET"
--enable-plugins
--enable-gold=yes
--enable-ld=default
--disable-multilib
--disable-werror
--disable-nls
--disable-sim
--disable-gdb
--disable-initfini-array
)
staging_post() {
local base="$PKG_STAGING_DIR$TOOLCHAIN_DIR"
# ld will look for libc.so.6, etc. in $base/$TRI_TARGET/lib which will be
# installed from glibc into $base/lib
#
# gcc-pass2 requires the existence of $base/usr/include
mkdir -p "$base/usr/include"
ln -sf 'lib' "$base/lib64"
ln -sf '../lib' "$base/$TRI_TARGET/lib64"
ln -sf '../lib' "$base/$TRI_TARGET/lib"
}