summaryrefslogtreecommitdiff
path: root/scripts/functions
diff options
context:
space:
mode:
authorAlexey Neyman <stilor@att.net>2016-03-30 19:15:54 (GMT)
committerAlexey Neyman <stilor@att.net>2016-08-23 18:00:27 (GMT)
commit82072d0cbc238000fd1547551deb198aa8c8d466 (patch)
tree47497379bd1d9a1f0c2c2bb264f3e6dc9ab81705 /scripts/functions
parentcc86d80da26aa27c382dee5ef44d21f450b3ae60 (diff)
multilib: Determine which options may pass through.
On some arches (e.g. MIPS) the options like -mabi do not work if specified more than once (see the comment in 100-gcc.sh). Therefore, we need to determine which of the options produced by <arch>.sh can be passed to multilib builds and which must be removed (i.e., which options vary among the multilibs). This presents a chicken-and-egg problem. GCC developers, in their infinite wisdom, do not allow arbitrary multilib specification to be supplied to GCC's configure. Instead, the target (and sometimes some extra options) determine the set of multilibs - which may include different CPUs, different ABIs, different endianness, different FPUs, different floating-point ABIs, ... That is, we don't know which parts vary until we build GCC and ask it. So, the solution implemented here is: - For multilib builds, start with empty CT_ARCH_TARGET_CFLAGS/LDFLAGS. - For multilib builds, require core pass 1. Pass 1 does not build any target binaries, so at that point, our target options have not been used yet. - Provide an API to modify the environment variables for the steps that follow the current one. - As a part of multilib-related housekeeping, determine the variable part of multilibs and filter out these options; pass the rest into CT_TARGET_CFLAGS/LDFLAGS. This still does not handle extra dependencies between GCC options (like -ma implying -mcpu=X -mtune=Y, etc.) but I feel that would complicate matters too much. Let's leave this until there's a compelling case for it. Also, query GCC's sysroot suffix for targets that use it (SuperH, for example) - the default multilib may not work if the command line specifies the default option explicitly (%sysroot_suffix_spec is not aware of multilib defaults). Signed-off-by: Alexey Neyman <stilor@att.net>
Diffstat (limited to 'scripts/functions')
-rw-r--r--scripts/functions25
1 files changed, 25 insertions, 0 deletions
diff --git a/scripts/functions b/scripts/functions
index 62d264e..557c028 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -1183,6 +1183,14 @@ CT_DoConfigSub() {
fi
}
+# Normally, each step is executed in a sub-shell and thus cannot modify the
+# environment for the next step(s). When this is needed, it can do so by
+# invoking this function.
+# Usage: CT_EnvModify VAR VALUE
+CT_EnvModify() {
+ echo "${1}=\"${2}\"" >> "${CT_BUILD_DIR}/env.modify.sh"
+}
+
# Compute the target tuple from what is provided by the user
# Usage: CT_DoBuildTargetTuple
# In fact this function takes the environment variables to build the target
@@ -1303,6 +1311,23 @@ CT_DoBuildTargetTuple() {
# Now on for the target LDFLAGS
CT_ARCH_TARGET_LDFLAGS="${CT_ARCH_TARGET_LDFLAGS} ${CT_ARCH_ENDIAN_LDFLAG}"
+
+ # Now, a multilib quirk. We may not be able to pass CT_ARCH_TARGET_CFLAGS
+ # and CT_ARCH_TARGET_LDFLAGS to gcc: even though GCC build appends the multilib
+ # flags afterwards, on some architectures the build breaks because some
+ # flags do not completely override each other. For example, on mips target,
+ # 'gcc -mabi=32' and 'gcc -mabi=n32' both work, but 'gcc -mabi=32 -mabi=n32'
+ # triggers an internal linker error. Likely a bug in GNU binutils, but we
+ # have to work it around for now: *do not pass the CT_ARCH_TARGET_ flags*.
+ # Instead, save them into a different variable here. Then, after the first
+ # core pass, we'll know which of them vary with multilibs (i.e. must be
+ # filtered out).
+ if [ "${CT_MULTILIB}" = "y" ]; then
+ CT_ARCH_TARGET_CFLAGS_MULTILIB="${CT_ARCH_TARGET_CFLAGS}"
+ CT_ARCH_TARGET_CFLAGS=
+ CT_ARCH_TARGET_LDFLAGS_MULTILIB="${CT_ARCH_TARGET_LDFLAGS}"
+ CT_ARCH_TARGET_LDFLAGS=
+ fi
}
# This function determines the target tuple for a given set of compiler