Commit 9636e806 by Joseph Myers Committed by Joseph Myers

Fix genmultilib reuse rule checks for large sets of option combinations.

genmultilib computes combination_space, a list of all combinations of
options in MULTILIB_OPTIONS that might have multilibs built for them
(some of which may end up not having multilibs built for them, and
some of those may end up being mapped to other multilibs with
MULTILIB_REUSE).  It is then used to validate the right hand part of
MULTILIB_REUSE rules, checking with expr that combination_space
matches a basic regular expression derived from that right hand part.

There are two problems with this approach to validation:

* It requires that right hand part to have options in the same order
  as in MULTILIB_OPTIONS, in contradiction to the documentation of
  MULTILIB_REUSE saying that order does not matter there.

* combination_space can be so large that the expr call fails with an
  E2BIG error.  I have a local ARM configuration with 40 multilibs but
  3840 combinations of options from MULTILIB_OPTIONS (so 3839 listed
  in combination_space, since it doesn't list the default multilib)
  and 996 MULTILIB_REUSE rules.  This generates a combination_space
  string longer than the Linux kernel's MAX_ARG_STRLEN (PAGE_SIZE *
  32, the limit on the length of a single argv string), so that expr
  cannot be run.

This patch changes the validation approach to generate a much shorter
extended regular expression for any sequence of multilib options in
any order, and uses that for the validation instead.

Tested with a build for arm-none-eabi --with-multilib-list=aprofile
(as a configuration that uses MULTILIB_REUSE).

	* genmultilib (combination_space): Remove variable.
	Validate reuse rules against regular expression for any sequence
	of multilib options in any order.

From-SVN: r249703
parent a977dc0c
2017-06-27 Joseph Myers <joseph@codesourcery.com>
* genmultilib (combination_space): Remove variable.
Validate reuse rules against regular expression for any sequence
of multilib options in any order.
2017-06-27 Michael Collison <michael.collison@arm.com> 2017-06-27 Michael Collison <michael.collison@arm.com>
* config/aarch64/aarch64-simd.md (aarch64_combine<mode>): Directly * config/aarch64/aarch64-simd.md (aarch64_combine<mode>): Directly
......
...@@ -186,8 +186,7 @@ fi ...@@ -186,8 +186,7 @@ fi
EOF EOF
chmod +x tmpmultilib chmod +x tmpmultilib
combination_space=`initial=/ ./tmpmultilib ${options}` combinations=`initial=/ ./tmpmultilib ${options}`
combinations="$combination_space"
# If there exceptions, weed them out now # If there exceptions, weed them out now
if [ -n "${exceptions}" ]; then if [ -n "${exceptions}" ]; then
...@@ -460,6 +459,15 @@ done ...@@ -460,6 +459,15 @@ done
echo "NULL" echo "NULL"
echo "};" echo "};"
# Generate a regular expression to validate option combinations.
options_re=
for set in ${options}; do
for opt in `echo ${set} | sed -e 's_[/|]_ _g'`; do
options_re="${options_re}${options_re:+|}${opt}"
done
done
options_re="^/((${options_re})/)*\$"
# Output rules used for multilib reuse. # Output rules used for multilib reuse.
echo "" echo ""
echo "static const char *const multilib_reuse_raw[] = {" echo "static const char *const multilib_reuse_raw[] = {"
...@@ -473,7 +481,7 @@ for rrule in ${multilib_reuse}; do ...@@ -473,7 +481,7 @@ for rrule in ${multilib_reuse}; do
# in this variable, it means no multilib will be built for current reuse # in this variable, it means no multilib will be built for current reuse
# rule. Thus the reuse purpose specified by current rule is meaningless. # rule. Thus the reuse purpose specified by current rule is meaningless.
if expr "${combinations} " : ".*/${combo}/.*" > /dev/null; then if expr "${combinations} " : ".*/${combo}/.*" > /dev/null; then
if expr "${combination_space} " : ".*/${copts}/.*" > /dev/null; then if echo "/${copts}/" | grep -E "${options_re}" > /dev/null; then
combo="/${combo}/" combo="/${combo}/"
dirout=`./tmpmultilib3 "${combo}" "${todirnames}" "${toosdirnames}" "${enable_multilib}"` dirout=`./tmpmultilib3 "${combo}" "${todirnames}" "${toosdirnames}" "${enable_multilib}"`
copts="/${copts}/" copts="/${copts}/"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment