aboutsummaryrefslogtreecommitdiff
path: root/gcc/gcc.cc
diff options
context:
space:
mode:
authorKito Cheng <kito.cheng@sifive.com>2020-11-20 15:52:53 +0800
committerKito Cheng <kito.cheng@sifive.com>2022-09-02 17:23:50 +0800
commit5ca9980fc86242505ffdaaf62bca1fd5db26550b (patch)
tree521cee052ab40f5e473ae4731286addd34f6c678 /gcc/gcc.cc
parent347dec125b662bdeb6d426ead3449e1209c2ce28 (diff)
downloadgcc-5ca9980fc86242505ffdaaf62bca1fd5db26550b.zip
gcc-5ca9980fc86242505ffdaaf62bca1fd5db26550b.tar.gz
gcc-5ca9980fc86242505ffdaaf62bca1fd5db26550b.tar.bz2
Add TARGET_COMPUTE_MULTILIB hook to override multi-lib result.
Create a new hook to let target could override the multi-lib result, the motivation is RISC-V might have very complicated multi-lib re-use rule*, which is hard to maintain and use current multi-lib scripts, we even hit the "argument list too long" error when we tried to add more multi-lib reuse rule. So I think it would be great to have a target specific way to determine the multi-lib re-use rule, then we could write those rule in C, instead of expand every possible case in MULTILIB_REUSE. * Here is an example for RISC-V multi-lib rules: https://gist.github.com/kito-cheng/0289cd42d9a756382e5afeb77b42b73b gcc/ChangeLog: * common/common-target.def (compute_multilib): New. * common/common-targhooks.h (default_compute_multilib): New. * common/common-targhooks.cc (default_compute_multilib): New. * doc/tm.texi.in (TARGET_COMPUTE_MULTILIB): New. * doc/tm.texi: Regen. * gcc.cc: Include common/common-target.h. (set_multilib_dir) Call targetm_common.compute_multilib. (SWITCH_LIVE): Move to opts.h. (SWITCH_FALSE): Ditto. (SWITCH_IGNORE): Ditto. (SWITCH_IGNORE_PERMANENTLY): Ditto. (SWITCH_KEEP_FOR_GCC): Ditto. (struct switchstr): Ditto. * opts.h (SWITCH_LIVE): Move from gcc.c. (SWITCH_FALSE): Ditto. (SWITCH_IGNORE): Ditto. (SWITCH_IGNORE_PERMANENTLY): Ditto. (SWITCH_KEEP_FOR_GCC): Ditto. (struct switchstr): Ditto.
Diffstat (limited to 'gcc/gcc.cc')
-rw-r--r--gcc/gcc.cc48
1 files changed, 12 insertions, 36 deletions
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index c1f084b..1584611 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -45,6 +45,7 @@ compilation is specified by a string called a "spec". */
#include "filenames.h"
#include "spellcheck.h"
#include "opts-jobserver.h"
+#include "common/common-target.h"
@@ -3563,42 +3564,6 @@ execute (void)
}
}
-/* Find all the switches given to us
- and make a vector describing them.
- The elements of the vector are strings, one per switch given.
- If a switch uses following arguments, then the `part1' field
- is the switch itself and the `args' field
- is a null-terminated vector containing the following arguments.
- Bits in the `live_cond' field are:
- SWITCH_LIVE to indicate this switch is true in a conditional spec.
- SWITCH_FALSE to indicate this switch is overridden by a later switch.
- SWITCH_IGNORE to indicate this switch should be ignored (used in %<S).
- SWITCH_IGNORE_PERMANENTLY to indicate this switch should be ignored.
- SWITCH_KEEP_FOR_GCC to indicate that this switch, otherwise ignored,
- should be included in COLLECT_GCC_OPTIONS.
- in all do_spec calls afterwards. Used for %<S from self specs.
- The `known' field describes whether this is an internal switch.
- The `validated' field describes whether any spec has looked at this switch;
- if it remains false at the end of the run, the switch must be meaningless.
- The `ordering' field is used to temporarily mark switches that have to be
- kept in a specific order. */
-
-#define SWITCH_LIVE (1 << 0)
-#define SWITCH_FALSE (1 << 1)
-#define SWITCH_IGNORE (1 << 2)
-#define SWITCH_IGNORE_PERMANENTLY (1 << 3)
-#define SWITCH_KEEP_FOR_GCC (1 << 4)
-
-struct switchstr
-{
- const char *part1;
- const char **args;
- unsigned int live_cond;
- bool known;
- bool validated;
- bool ordering;
-};
-
static struct switchstr *switches;
static int n_switches;
@@ -9827,6 +9792,17 @@ set_multilib_dir (void)
++p;
}
+ multilib_dir =
+ targetm_common.compute_multilib (
+ switches,
+ n_switches,
+ multilib_dir,
+ multilib_defaults,
+ multilib_select,
+ multilib_matches,
+ multilib_exclusions,
+ multilib_reuse);
+
if (multilib_dir == NULL && multilib_os_dir != NULL
&& strcmp (multilib_os_dir, ".") == 0)
{