3b304f5b7d
* Makefile.in (WARN_CFLAGS): Add -Wwrite-strings. (tree.o): Depend on output.h. * c-decl.c (pending_invalid_xref_file, current_function_prototype_file): Constify. (pushdecl): Constify a local char *. (define_label): Constify filename parameter. * c-lex.c (init_parse): Constify parameter and return value. * c-typeck.c (c_expand_asm_operands): Constify filename parameter. * c-tree.h: Update prototypes. * c-parse.in: Constify filename member of %union, and if_stmt_file. * c-parse.y, c-parse.c, c-parse.h, objc/objc-parse.y, objc/objc-parse.c: Regenerate. * dwarfout.c (dwarfout_init): Constify main_input_filename parameter. * dwarfout.h: Update prototypes. * expr.c (expand_expr): Constify a local char *. * flags.h: Constify main_input_filename. * function.c (expand_function_end): Constify filename parameter. * genrecog.c (make_insn_sequence): Use a character array for c_test_pos. (main): Remove unused variables. * input.h: Constify input_filename, main_input_filename, and file_stack.name. Update prototypes. * output.h: Declare first_global_object_name and weak_global_object_name here, as const char *. * stmt.c (expand_asm_operands): Constify filename parameter. * toplev.c (compile_file, push_srcloc, debug_start_source_file): Constify filename parameter. (input_filename, main_input_filename): Constify. * toplev.h: Update prototypes. * tree.c: Include output.h. Don't declare first_global_object_name or weak_global_object_name. Clean up string bashing in get_file_function_name_long. * tree.h (struct tree_decl): Constify filename member. (input_filename): Constify. Update prototypes. * varasm.c (first_global_object_name, weak_global_object_name): Constify. (assemble_start_function, assemble_variable): Clean up string bashing. * gcc.c: Constify all spec-related strings initialized, transitively, from string constants. Constify all strings and string variables related to multilibs. (set_spec, read_specs): Cast argument to free to PTR. (used_arg): Do not modify multilib_matches. Use strncmp plus length comparison to compare multilib switches. * genmultilib: Constify everything declared in multilib.h. ch: * ch-tree.h: Update prototypes. Remove prototypes for functions declared elsewhere. * decl.c (define_label): Constify filename parameter. * grant.c (globalize_decl, set_default_grant_file): Constify local char * variables. Don't declare first_global_object_name or asm_out_file. * lang.c (chill_real_input_filename): Constify. * lex.c (init_parse): Constify parameter and return value. * parse.c: Don't declare input_filename. (ch_expand_asm_operands): Constify filename parameter. (parse_multi_dimension_case_action): Constify local char *. * satisfy.c (safe_satisfy_decl): Constify local char *. cp: * cp-tree.h: Constify tree_srcloc.filename, tinst_level.file, and pending_inline.filename. Update prototypes. * decl.c (define_label): Constify filename parameter. * decl2.c (warn_if_unknown_interface): Constify local char *. * input.c Constify input_source.filename. Don't declare input_filename or lineno. Constify filename parameter to feed_input. * lex.c (init_parse): Constify parameter and return value. (cp_pragma_interface, cp_pragma_implementation): Constify filename argument. (reinit_parse_for_method, reinit_parse_for_block, reinit_parse_for_expr, feed_defarg, handle_cp_pragma): Constify local char *. * pt.c: Don't declare lineno or input_filename. (print_template_context, tsubst_friend_function, tsubst_decl, tsubst, instantiate_decl): Constify local char *. * semantics.c (expand_body): Constify local char *. * tree.c (build_srcloc): Constify filename parameter. * typeck.c (c_expand_asm_operands): Constify filename parameter. f: * com.c (ffecom_subscript_check_): Constify array_name parameter. Clean up string bashing. (ffecom_arrayref_, ffecom_char_args_x_): Constify array_name parameter. (ffecom_do_entry_, ffecom_gen_sfuncdef_, ffecom_start_progunit_, ffecom_sym_transform_, ffecom_sym_transform_assign_): Constify local char *. (init_parse): Constify parameter and return value. * lex.c: Include dwarfout.h instead of prototyping dwarfout_* functions here. (ffelex_file_pop_, ffelex_file_push_): Constify filename parameter. (ffelex_hash_, ffelex_include_): Constify local char *. * std.c (ffestd_exec_end): Constify local char *. * where.c (ffewhere_file_new): Constify filename parameter. * where.h: Update prototypes. java: * check_init.c (check_init): Constify local char *. * class.c (push_class): Constify local char *. * java_tree.h: Update prototypes. * jcf-io.c (open_class): Constify filename parameter and return value. (find_class): Remove redundant string copy. Cast return from open_class. * jcf-parse.c (read_class, parse_class_file, yyparse): Constify local char *. * jcf-write.c (generate_bytecode_insns, generate_classfile): Constify local char *. * jcf.h (JCF): Constify filename and classname. (JCF_FINISH): Cast args to FREE to char * when appropriate. * lang.c (init_parse): Constify parameter and return value. * lex.c (java_get_line_col): Constify filename parameter. * parse.h: Constify parser_ctxt.filename. Update prototypes. * parse.y (java_parser_context_suspend, issue_warning_error_from_context, safe_layout_class): Constify local char *. * parse.c: Regenerate. From-SVN: r33804
319 lines
11 KiB
Bash
319 lines
11 KiB
Bash
#!/bin/sh
|
|
# Generates multilib.h.
|
|
# Copyright (C) 1994, 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
|
|
|
|
#This file is part of GNU CC.
|
|
|
|
#GNU CC is free software; you can redistribute it and/or modify
|
|
#it under the terms of the GNU General Public License as published by
|
|
#the Free Software Foundation; either version 2, or (at your option)
|
|
#any later version.
|
|
|
|
#GNU CC is distributed in the hope that it will be useful,
|
|
#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
#GNU General Public License for more details.
|
|
|
|
#You should have received a copy of the GNU General Public License
|
|
#along with GNU CC; see the file COPYING. If not, write to
|
|
#the Free Software Foundation, 59 Temple Place - Suite 330,
|
|
#Boston, MA 02111-1307, USA.
|
|
|
|
# This shell script produces a header file which the gcc driver
|
|
# program uses to pick which library to use based on the machine
|
|
# specific options that it is given.
|
|
|
|
# The first argument is a list of sets of options. The elements in
|
|
# the list are separated by spaces. Within an element, the options
|
|
# are separated by slashes or pipes. No leading dash is used on the
|
|
# options.
|
|
# Each option in a set separated by slashes is mutually incompatible
|
|
# with all other options
|
|
# in the set.
|
|
# Each option in a set separated by pipes will be used for the library
|
|
# compilation and any of the options in the set will be sufficient
|
|
# for it to be triggered.
|
|
|
|
# The optional second argument is a list of subdirectory names. If
|
|
# the second argument is non-empty, there must be as many elements in
|
|
# the second argument as there are options in the first argument. The
|
|
# elements in the second list are separated by spaces. If the second
|
|
# argument is empty, the option names will be used as the directory
|
|
# names.
|
|
|
|
# The optional third argument is a list of options which are
|
|
# identical. The elements in the list are separated by spaces. Each
|
|
# element must be of the form OPTION=OPTION. The first OPTION should
|
|
# appear in the first argument, and the second should be a synonym for
|
|
# it. Question marks are replaced with equal signs in both options.
|
|
|
|
# The optional fourth argument is a list of multilib directory
|
|
# combinations that should not be built.
|
|
|
|
# The optional fifth argument is a list of options that should be
|
|
# used whenever building multilib libraries.
|
|
|
|
# The optional sixth argument is a list of exclusions used internally by
|
|
# the compiler similar to exceptions. The difference being that exclusions
|
|
# allow matching default options that genmultilib does not know about and
|
|
# is done at runtime as opposed to being sorted out at compile time.
|
|
# Each element in the list is a seperate exclusion rule. Each rule is
|
|
# a list of options (sans preceding '-') seperated by a '/'. The options
|
|
# on the rule are grouped as an AND operation, and all options much match
|
|
# for the rule to exclude a set. Options can be preceded with a '!' to
|
|
# match a logical NOT.
|
|
|
|
# The output looks like
|
|
# #define MULTILIB_MATCHES "\
|
|
# SUBDIRECTORY OPTIONS;\
|
|
# ...
|
|
# "
|
|
# The SUBDIRECTORY is the subdirectory to use. The OPTIONS are
|
|
# multiple options separated by spaces. Each option may start with an
|
|
# exclamation point. gcc will consider each line in turn. If none of
|
|
# the options beginning with an exclamation point are present, and all
|
|
# of the other options are present, that subdirectory will be used.
|
|
# The order of the subdirectories is such that they can be created in
|
|
# order; that is, a subdirectory is preceded by all its parents.
|
|
|
|
# Here is an example (this is from the actual sparc64 case):
|
|
# genmultilib 'm64/m32 mno-app-regs|mcmodel=medany' '64 32 alt'
|
|
# 'mcmodel?medany=mcmodel?medmid' 'm32/mno-app-regs* m32/mcmodel=*'
|
|
# 'm32/!m64/mno-app-regs m32/!m64/mcmodel=medany'
|
|
# This produces:
|
|
# ". !m64 !m32 !mno-app-regs !mcmodel=medany;",
|
|
# "64 m64 !m32 !mno-app-regs !mcmodel=medany;",
|
|
# "32 !m64 m32 !mno-app-regs !mcmodel=medany;",
|
|
# "alt !m64 !m32 mno-app-regs mcmodel=medany;",
|
|
# "alt !m64 !m32 mno-app-regs !mcmodel=medany;",
|
|
# "alt !m64 !m32 !mno-app-regs mcmodel=medany;",
|
|
# "64/alt m64 !m32 mno-app-regs mcmodel=medany;",
|
|
# "64/alt m64 !m32 mno-app-regs !mcmodel=medany;",
|
|
# "64/alt m64 !m32 !mno-app-regs mcmodel=medany;",
|
|
#
|
|
# The effect is that `gcc -mno-app-regs' (for example) will append "alt"
|
|
# to the directory name when searching for libraries or startup files and
|
|
# `gcc -m32 -mcmodel=medany' (for example) will append "32/alt". Also note
|
|
# that exclusion above is moot, unless the compiler had a default of -m32,
|
|
# which would mean that all of the "alt" directories (not the 64/alt ones)
|
|
# would be ignored (not generated, nor used) since the exclusion also
|
|
# matches the multilib_default args.
|
|
|
|
# Copy the positional parameters into variables.
|
|
options=$1
|
|
dirnames=$2
|
|
matches=$3
|
|
exceptions=$4
|
|
extra=$5
|
|
exclusions=$6
|
|
|
|
echo "static const char *const multilib_raw[] = {"
|
|
|
|
# What we want to do is select all combinations of the sets in
|
|
# options. Each combination which includes a set of mutually
|
|
# exclusive options must then be output multiple times, once for each
|
|
# item in the set. Selecting combinations is a recursive process.
|
|
# Since not all versions of sh support functions, we achieve recursion
|
|
# by creating a temporary shell script which invokes itself.
|
|
rm -f tmpmultilib
|
|
cat >tmpmultilib <<\EOF
|
|
#!/bin/sh
|
|
# This recursive script basically outputs all combinations of its
|
|
# input arguments, handling mutually exclusive sets of options by
|
|
# repetition. When the script is called, ${initial} is the list of
|
|
# options which should appear before all combinations this will
|
|
# output. The output looks like a list of subdirectory names with
|
|
# leading and trailing slashes.
|
|
if [ "$#" != "0" ]; then
|
|
first=$1
|
|
shift
|
|
case "$first" in
|
|
*\|*)
|
|
all=${initial}`echo $first | sed -e 's_|_/_'g`
|
|
first=`echo $first | sed -e 's_|_ _'g`
|
|
echo ${all}/
|
|
initial="${initial}${all}/" ./tmpmultilib $@
|
|
./tmpmultilib $first $@ | grep -v "^${all}"
|
|
;;
|
|
*)
|
|
for opt in `echo $first | sed -e 's|/| |'g`; do
|
|
echo ${initial}${opt}/
|
|
done
|
|
./tmpmultilib $@
|
|
for opt in `echo $first | sed -e 's|/| |'g`; do
|
|
initial="${initial}${opt}/" ./tmpmultilib $@
|
|
done
|
|
esac
|
|
fi
|
|
EOF
|
|
chmod +x tmpmultilib
|
|
|
|
combinations=`initial=/ ./tmpmultilib ${options}`
|
|
|
|
rm -f tmpmultilib
|
|
|
|
# If there exceptions, weed them out now
|
|
if [ -n "${exceptions}" ]; then
|
|
rm -f tmpmultilib2
|
|
cat >tmpmultilib2 <<\EOF
|
|
#!/bin/sh
|
|
# This recursive script weeds out any combination of multilib
|
|
# switches that should not be generated. The output looks like
|
|
# a list of subdirectory names with leading and trailing slashes.
|
|
|
|
for opt in $@; do
|
|
case "$opt" in
|
|
EOF
|
|
|
|
for except in ${exceptions}; do
|
|
echo " /${except}/) : ;;" >> tmpmultilib2
|
|
done
|
|
|
|
cat >>tmpmultilib2 <<\EOF
|
|
*) echo ${opt};;
|
|
esac
|
|
done
|
|
EOF
|
|
chmod +x tmpmultilib2
|
|
combinations=`./tmpmultilib2 ${combinations}`
|
|
rm -f ./tmpmultilib2
|
|
fi
|
|
|
|
# Construct a sed pattern which will convert option names to directory
|
|
# names.
|
|
todirnames=
|
|
if [ -n "${dirnames}" ]; then
|
|
set x ${dirnames}
|
|
shift
|
|
for set in ${options}; do
|
|
for opts in `echo ${set} | sed -e 's|/| |'g`; do
|
|
patt="/"
|
|
for opt in `echo ${opts} | sed -e 's_|_ _'g`; do
|
|
if [ "$1" != "${opt}" ]; then
|
|
todirnames="${todirnames} -e s|/${opt}/|/${1}/|g"
|
|
patt="${patt}${1}/"
|
|
if [ "${patt}" != "/${1}/" ]; then
|
|
todirnames="${todirnames} -e s|${patt}|/${1}/|g"
|
|
fi
|
|
fi
|
|
done
|
|
shift
|
|
done
|
|
done
|
|
fi
|
|
|
|
# We need another recursive shell script to correctly handle positive
|
|
# matches. If we are invoked as
|
|
# genmultilib "opt1 opt2" "" "opt1=nopt1 opt2=nopt2"
|
|
# we must output
|
|
# opt1/opt2 opt1 opt2
|
|
# opt1/opt2 nopt1 opt2
|
|
# opt1/opt2 opt1 nopt2
|
|
# opt1/opt2 nopt1 nopt2
|
|
# In other words, we must output all combinations of matches.
|
|
rm -f tmpmultilib2
|
|
cat >tmpmultilib2 <<\EOF
|
|
#!/bin/sh
|
|
# The positional parameters are a list of matches to consider.
|
|
# ${dirout} is the directory name and ${optout} is the current list of
|
|
# options.
|
|
if [ "$#" = "0" ]; then
|
|
echo "\"${dirout} ${optout};\","
|
|
else
|
|
first=$1
|
|
shift
|
|
dirout="${dirout}" optout="${optout}" ./tmpmultilib2 $@
|
|
l=`echo ${first} | sed -e 's/=.*$//' -e 's/?/=/g'`
|
|
r=`echo ${first} | sed -e 's/^.*=//' -e 's/?/=/g'`
|
|
if expr " ${optout} " : ".* ${l} .*" > /dev/null; then
|
|
newopt=`echo " ${optout} " | sed -e "s/ ${l} / ${r} /" -e 's/^ //' -e 's/ $//'`
|
|
dirout="${dirout}" optout="${newopt}" ./tmpmultilib2 $@
|
|
fi
|
|
fi
|
|
EOF
|
|
chmod +x tmpmultilib2
|
|
|
|
# Start with the current directory, which includes only negations.
|
|
optout=
|
|
for set in ${options}; do
|
|
for opt in `echo ${set} | sed -e 's_[/|]_ _g'`; do
|
|
optout="${optout} !${opt}"
|
|
done
|
|
done
|
|
optout=`echo ${optout} | sed -e 's/^ //'`
|
|
echo "\". ${optout};\","
|
|
|
|
# Work over the list of combinations. We have to translate each one
|
|
# to use the directory names rather than the option names, we have to
|
|
# include the information in matches, and we have to generate the
|
|
# correct list of options and negations.
|
|
for combo in ${combinations}; do
|
|
# Use the directory names rather than the option names.
|
|
if [ -n "${todirnames}" ]; then
|
|
dirout=`echo ${combo} | sed ${todirnames}`
|
|
else
|
|
dirout=${combo}
|
|
fi
|
|
# Remove the leading and trailing slashes.
|
|
dirout=`echo ${dirout} | sed -e 's|^/||' -e 's|/$||g'`
|
|
|
|
# Look through the options. We must output each option that is
|
|
# present, and negate each option that is not present.
|
|
optout=
|
|
for set in ${options}; do
|
|
setopts=`echo ${set} | sed -e 's_[/|]_ _g'`
|
|
for opt in ${setopts}; do
|
|
if expr "${combo} " : ".*/${opt}/.*" > /dev/null; then
|
|
optout="${optout} ${opt}"
|
|
else
|
|
optout="${optout} !${opt}"
|
|
fi
|
|
done
|
|
done
|
|
optout=`echo ${optout} | sed -e 's/^ //'`
|
|
|
|
# Output the line with all appropriate matches.
|
|
dirout="${dirout}" optout="${optout}" ./tmpmultilib2
|
|
done
|
|
|
|
# Terminate the list of string.
|
|
echo "NULL"
|
|
echo "};"
|
|
|
|
# Output all of the matches now as option and that is the same as that, with
|
|
# a semicolon trailer. Include all of the normal options as well.
|
|
# Note, the format of the matches is reversed compared
|
|
# to what we want, so switch them around.
|
|
echo ""
|
|
echo "static const char *const multilib_matches_raw[] = {"
|
|
for match in ${matches}; do
|
|
l=`echo ${match} | sed -e 's/=.*$//' -e 's/?/=/g'`
|
|
r=`echo ${match} | sed -e 's/^.*=//' -e 's/?/=/g'`
|
|
echo "\"${r} ${l};\","
|
|
done
|
|
for set in ${options}; do
|
|
for opt in `echo ${set} | sed -e 's_[/|]_ _'g`; do
|
|
echo "\"${opt} ${opt};\","
|
|
done
|
|
done
|
|
echo "NULL"
|
|
echo "};"
|
|
|
|
# Output the default options now
|
|
echo ""
|
|
echo "static const char *multilib_extra = \"${extra}\";"
|
|
|
|
# Output the exclusion rules now
|
|
echo ""
|
|
echo "static const char *const multilib_exclusions_raw[] = {"
|
|
for rule in ${exclusions}; do
|
|
s=`echo ${rule} | sed -e 's,/, ,g'`
|
|
echo "\"${s};\","
|
|
done
|
|
echo "NULL"
|
|
echo "};"
|
|
|
|
rm -f tmpmultilib2
|
|
|
|
exit 0
|